Moduł:Recenzje serii gier
Dokumentacja modułu
[stwórz] [ ]
Zobacz podstrony tego modułu.
local getArgs = require('Moduł:Arguments').getArgs
local yesno = require('Moduł:Yesno')
local p = {}
local columns = {
['mc'] = nil,
['gr'] = nil,
['fam'] = nil,
['sales'] = nil,
}
local function sortByNumber(a,b)
return a['num'] < b['num']
end;
local function checkColumn(game, column)
if(game[column] ~= nil and game[column] ~= "" and columns[column] ~= false) then
columns[column] = true;
end;
end;
local function buildGameEntry(args, num)
local game = {}
game['num'] = num;
game['name'] = args["gra"..num];
game['mc'] = args["mc"..num];
game['gr'] = args["gr"..num];
game['fam'] = args["fam"..num];
game['sales'] = args["sprzedaż"..num];
checkColumn(game, 'gr');
checkColumn(game, 'fam');
checkColumn(game, 'mc');
checkColumn(game, 'sales');
return game;
end;
function p.main(frame)
local args = getArgs(frame)
return p._main(frame, args)
end
function p._main(frame, args)
-- Get specified values of column display parameters. Nil = Unspecified.
if(args["mc"]) then
columns['mc'] = yesno(args["mc"]);
end
if(args["gr"]) then
columns['gr'] = yesno(args["gr"]);
end
if(args["fam"]) then
columns['fam'] = yesno(args["fam"]);
end
if(args["sprzedaż"]) then
columns['sales'] = yesno(args["sprzedaż"]);
end
local games = {};
local gameRead = {};
-- Look for locally provided graN parameters first. Build a table containing all the arguments.
for k, v in pairs(args) do
if(string.find(k, "gra%d+")) then
local num = tonumber(string.match(k, "%d+"))
if(num ~= nil) then
if(gameRead[num] == nil) then
gameRead[num] = true;
table.insert(games, buildGameEntry(args,num));
end;
end;
end;
end;
-- Did we find any games specified on the arguments?
if(#games > 0) then
-- Sort by entry.
table.sort(games, sortByNumber);
end;
local ret = "{| class=\"wikitable\" style=\"font-size: 90%; float: right; clear: right; margin:0.5em 0 0.5em 1em;\"\n"
ret = ret .."|+ style=\"font-size: 111.11%;\" | "
if args.title then
ret = ret .. args.title
elseif columns['sales'] then
if columns['fam'] then
ret = ret .. "Sprzedaż i oceny z recenzji"
elseif columns['gr'] or columns['mc'] then
ret = ret .. "Sprzedaż i średnia ocen z recenzji"
else
ret = ret .. "Sprzedaż"
end
elseif columns['fam'] then
if columns['gr'] or columns['mc'] then
ret = ret .. "Oceny z recenzji"
else
ret = ret .. "Oceny z recenzji w „[[Famitsū]]”"
end
else
ret = ret .. "Średnia ocen z recenzji"
end
if args.aktualizacja then
ret = ret .. "<br /><small>Stan z " .. args.aktualizacja ..".</small>"
end
ret = ret .. " \n"
ret = ret .. "! scope=\"col\" | Gra \n"
if columns['sales'] then
ret = ret .. "! scope=\"col\" | " .. (args["sprzedaż nagłówek"] or "Sprzedaż") .. " \n"
end
if columns['fam'] then
if columns['gr'] or columns['mc'] then
ret = ret .. "! scope=\"col\" | " .. (args["fam nagłówek"] or "„[[Famitsū]]”") .. " \n"
else
ret = ret .. "! scope=\"col\" | " .. (args["fam nagłówek"] or "Ocena") .. " \n"
end
end
if columns['gr'] then
ret = ret .. "! scope=\"col\" | " .. (args["gr nagłówek"] or "[[GameRankings]]") .. " \n"
end
if columns['mc'] then
ret = ret .. "! scope=\"col\" | " .. (args["mc nagłówek"] or "[[Metacritic]]") .. " \n"
end
-- Print the reviews
for i,game in ipairs(games) do
ret = ret .. "|-\n"
ret = ret .. "! scope=\"row\" style=\"font-weight: normal; text-align: left;\" | ''" .. game['name'] .. "''"
if(game['updateLink']) then
ret = ret .. " " .. game['updateLink'];
end;
ret = ret .. "\n"
if columns['sales'] then
ret = ret .. "| style=\"text-align: center;\" | " .. (game['sales'] or '') .. " \n"
end
if columns['fam'] then
ret = ret .. "| style=\"text-align: center;\" | " .. (game['fam'] or '') .. " \n"
end
if columns['gr'] then
ret = ret .. "| style=\"text-align: center;\" | " .. (game['gr'] or '') .. " \n"
end
if columns['mc'] then
ret = ret .. "| style=\"text-align: center;\" | " .. (game['mc'] or '') .. " \n"
end
end;
ret = ret .. "|}"
return ret
end
return p