Module:Game
Jump to navigation
Jump to search
local englishGameData = require([[Module:Game/data]]).english -- DON'T use mw.loadData as it prevents # from working for length
local p = {}
function p.desktopFrontPageGamesList(frame)
local t = {}
for i,game in ipairs(englishGameData) do
local fontsize = game.FPfontsize and "|fontsize="..game.FPfontsize or ""
t[#t+1] = table.concat{ "{{Project:Game|", game.name, "|ios=yes|android=yes", fontsize, "}}" }
end
return frame:preprocess(table.concat(t))
end
function p.mobileFrontPageGamesList(frame)
local t = {}
for i,game in ipairs(englishGameData) do
t[#t+1] = table.concat{ "[[File:", game.name, " Banner.png|center|232px|link=", game.name, "|", game.name, "]]" }
end
return table.concat(t)
end
function p.navboxGamesList(frame)
local t = {}
for i,game in ipairs(englishGameData) do
t[#t+1] = table.concat{ "*[[", game.name, "]]" }
end
return table.concat(t, "\n")
end
-----------------------------
-- Random Image stuff for front page
-----------------------------
function getImageForRandom(gamename)
return table.concat{ "[[File:", gamename, " Banner.png|150x52px|link=", gamename, "]]" }
end
function chooseOptionListForRandom(min, max)
local t = {}
t[#t+1] = "<choose uncached>"
for i = min, max, 1 do
t[#t+1] = table.concat{ "<option>", getImageForRandom(englishGameData[i].name), "</option>" }
end
t[#t+1] = "</choose>"
return table.concat(t)
end
function p.getRandomLeft(frame)
local min, max = 1, math.floor(#englishGameData/2)
return frame:preprocess(chooseOptionListForRandom(min, max))
end
function p.getRandomRight(frame)
local min, max = math.floor(#englishGameData/2)+1, #englishGameData
return frame:preprocess(chooseOptionListForRandom(min, max))
end
return p