[checked revision] | [checked revision] |
No edit summary |
m (Syncing content across wikis from Call of Duty Esports Wiki, if something seems broken as a result let me know) |
||
Line 1: | Line 1: | ||
− | + | local util_args = require('Module:ArgsUtil') |
|
− | local |
+ | local util_cargo = require('Module:CargoUtil') |
+ | local util_esports = require('Module:EsportsUtil') |
||
+ | local util_html = require('Module:HtmlUtil') |
||
+ | local util_map = require('Module:MapUtil') |
||
+ | local util_table = require('Module:TableUtil') |
||
+ | local util_text = require('Module:TextUtil') |
||
+ | local util_toggle = require('Module:ToggleUtil') |
||
+ | local util_tournament = require('Module:TournamentUtil') |
||
+ | local util_vars = require('Module:VarsUtil') |
||
+ | local i18n = require('Module:i18nUtil') |
||
+ | local lang = mw.getLanguage('en') |
||
+ | |||
+ | local Results = require('Module:PlayerResultsAbstract'):extends() |
||
+ | |||
+ | function Results:init() |
||
+ | self:super('init', 'Player') |
||
+ | self.limitOverviewpage = 10 |
||
+ | self.limitEverything = 500 |
||
+ | self.COLUMNS = { 'Game', 'Date', 'PlaceDisplay', 'PrizeDisplay', 'Tournament', 'TeamDisplay', 'Roster' } |
||
+ | end |
||
local p = {} |
local p = {} |
||
− | local s = {} |
||
− | function |
+ | function p.main(frame) |
+ | local args = util_args.merge() |
||
− | return Sprite{ |
||
+ | return Results():run(args) |
||
− | id, |
||
− | type = 'League' |
||
− | } |
||
end |
end |
||
− | function |
+ | function Results:getSubject(args) |
+ | return args[1] or mw.title.getCurrentTitle().baseText |
||
− | if frame == mw.getCurrentFrame() then |
||
+ | end |
||
− | args = require( 'Module:ProcessArgs').norm() |
||
− | else |
||
− | frame = mw.getCurrentFrame() |
||
− | end |
||
− | |||
− | local player = args[1] or tostring(mw.title.getCurrentTitle()) |
||
− | local tournamentType = args.type or '' |
||
− | local limit = args[3] or ((args.show == 'everything') and 5000 or 10) |
||
− | |||
− | local result = p.load(player, tournamentType, limit) |
||
− | |||
− | mw.log(result) |
||
− | |||
− | local m_team = require('Module:Team') |
||
− | local League = require('Module:League').league |
||
− | local placement = mw.loadData('Module:Placementnames') |
||
− | local Game = require('Module:Game').game |
||
+ | -- cargo |
||
− | local tbl = mw.html.create('table') |
||
+ | function Results:getTables(args) |
||
− | tbl:addClass("wikitable sortable hoverable-rows"):css("font-size","90%") |
||
+ | local tables = self:super('getTables', args) |
||
− | :tag("tr") |
||
+ | table.insert(tables, 1, 'TournamentPlayers=TP') |
||
− | :tag("th"):css({ background = "var(--tournament-results-bar)" }):attr("colspan","30") |
||
+ | if util_args.castAsBool(args.noredirects) then return tables end |
||
− | :wikitext(player .. ' Tournament Results'):done() |
||
+ | tables[#tables+1] = 'PlayerRedirects=PR' |
||
− | :done() |
||
+ | return tables |
||
− | :tag("tr") |
||
− | :tag("th"):css("width","60"):wikitext("Game"):done() |
||
− | :tag("th"):css("width","60"):wikitext("Date"):done() |
||
− | :tag("th"):css("width","60"):wikitext("Place"):done() |
||
− | :tag("th"):css("width","80"):wikitext('<abbr title="This prize was won by the team and does not necessarily reflect money earned by the player">Prize</abbr>'):done() |
||
− | :tag("th"):css("width","250"):wikitext("Event"):done() |
||
− | --:tag("th"):css("width","150"):wikitext("Last Result"):done() |
||
− | :tag("th"):css("width","250"):wikitext("Team"):done() |
||
− | :tag("th"):wikitext("Roster"):done() |
||
− | :done() |
||
− | |||
− | local earnings = {} |
||
− | |||
− | for _,row in ipairs(result) do |
||
− | mw.log('result') |
||
− | place = placement[string.lower(row["Place"])] or { bgcolor = "", hiddensort = "", fontcolor = "red", display = "Invalid Placement Name[[Category:Pages With Invalid Placement Names]]" } |
||
− | tr = tbl:tag("tr") |
||
− | tr:tag('td'):wikitext(Game{row['Game']}):done() |
||
− | tr:tag("td"):css({ ['white-space'] = 'nowrap' }):wikitext(row["Date"]):done() -- Need to format this right still |
||
− | :tag("td") |
||
− | :css({ ["background-color"] = "#" .. place["bgcolor"], color = place["fontcolor"], ["text-align"] = "center" }) |
||
− | :wikitext('<span style="display:none;">' .. place.hiddensort .. "</span>'''" .. place.display .. "'''") |
||
− | :done() |
||
− | :tag("td"):wikitext(row["PrizeMarkup"]):done() |
||
− | tdEvent = tr:tag("td"):wikitext(s.LeagueSprite(row.League) .. " [[" .. row["EventLink"] .. "|" .. row["Event"]) |
||
− | if row["Phase"] ~= "" then |
||
− | tdEvent:wikitext(" - " .. row["Phase"]) |
||
− | end |
||
− | tdEvent:wikitext("]]"):done() |
||
− | |||
− | tr:tag("td"):wikitext(m_team.rightmediumlinked(row.TeamLink)) |
||
− | |||
− | teammates = {} |
||
− | teammatenames = mw.text.split(row["RosterNames"],",",true) |
||
− | teammatelinks = mw.text.split(row["RosterLinks"],",",true) |
||
− | roles = mw.text.split(row["Roles"],",",true) |
||
− | |||
− | for index,teammatelink in ipairs(teammatelinks) do |
||
− | if mw.ustring.lower(teammatelink) == mw.ustring.lower(player--[[row["ThisName"]]) then -- TODO |
||
− | teammates[#teammates+1] = (roles[index] or '') .. " '''" .. teammatenames[index] .. "'''" |
||
− | else |
||
− | teammates[#teammates+1] = (roles[index] or '') .. " [[" .. teammatelink .. "|" .. teammatenames[index] .. "]]" |
||
− | end |
||
− | end |
||
− | tr:tag("td"):wikitext(table.concat(teammates, " • ")) |
||
− | |||
− | if row["Prize"] ~= "" then |
||
− | earnings[row["PrizeUnit"]] = (earnings[row["PrizeUnit"]] or 0) + tonumber(row["Prize"],10) |
||
− | end |
||
− | |||
− | end |
||
− | |||
− | local td = tbl:tag("tr") |
||
− | :tag("th"):attr("colspan","30"):wikitext("Total Prize: ") |
||
− | |||
− | local earningstable = {} |
||
− | |||
− | for currency, amount in pairs(earnings) do |
||
− | earningstable[#earningstable+1] = currency .. " " .. mw.getLanguage('en'):formatNum(amount) |
||
− | end |
||
− | |||
− | td:wikitext(table.concat(earningstable," • ")):done() |
||
− | |||
− | text = tostring(tbl) |
||
− | |||
− | frame:callParserFunction{name="#vardefine:hasnewresults",args={"yes"}} |
||
− | |||
− | return text |
||
− | |||
end |
end |
||
− | function |
+ | function Results:getJoin(args) |
+ | local join = self:super('getJoin', args) |
||
− | if frame == mw.getCurrentFrame() then |
||
+ | table.insert(join, 1, 'TP.PageAndTeam=Res.PageAndTeam') |
||
− | args = require( 'Module:ProcessArgs').norm() |
||
+ | if util_args.castAsBool(args.noredirects) then return join end |
||
− | else |
||
+ | table.insert(join, 2, 'TP.Player=PR.AllName') |
||
− | frame = mw.getCurrentFrame() |
||
+ | return join |
||
− | end |
||
+ | end |
||
− | |||
− | local player = args[1] or tostring(mw.title.getCurrentTitle()) |
||
− | |||
− | local m_team = require('Module:Team') |
||
− | local League = require('Module:League').league |
||
− | local placement = mw.loadData('Module:Placementnames') |
||
− | local Game = require('Module:Game').game |
||
− | |||
− | local result = p.load(player, 'offline', 5) |
||
− | |||
− | local tbl = mw.html.create('table') |
||
− | tbl:addClass("wikitable sortable hoverable-rows"):css("font-size","90%") |
||
− | :tag("tr") |
||
− | :tag("th"):css({ background = "var(--tournament-results-bar)" }):attr("colspan","30") |
||
− | :wikitext('Recent Tournament Results [[' .. player .. '/Tournament Results|(View All)]]'):done() |
||
− | :done() |
||
− | :tag("tr") |
||
− | :tag("th"):css("width","60"):wikitext("Game"):done() |
||
− | :tag("th"):css("width","60"):wikitext("Date"):done() |
||
− | :tag("th"):css("width","60"):wikitext("Place"):done() |
||
− | :tag("th"):css("width","80"):wikitext('<abbr title="This prize was won by the team and does not necessarily reflect money earned by the player">Prize</abbr>'):done() |
||
− | :tag("th"):css("width","250"):wikitext("Event"):done() |
||
− | --:tag("th"):css("width","150"):wikitext("Last Result"):done() |
||
− | :tag("th"):css("width","250"):wikitext("Team"):done() |
||
− | --:tag("th"):wikitext("Roster"):done() |
||
− | :done() |
||
− | |||
− | local earnings = {} |
||
+ | function Results:getFields(args) |
||
− | for _,row in ipairs(result) do |
||
+ | local fields = self:super('getFields', args) |
||
− | mw.log('result') |
||
+ | fields[#fields+1] = 'TP.Player=ThisName' |
||
− | place = placement[string.lower(row["Place"])] or { bgcolor = "", hiddensort = "", fontcolor = "red", display = "Invalid Placement Name[[Category:Pages With Invalid Placement Names]]" } |
||
+ | return fields |
||
− | tr = tbl:tag("tr") |
||
+ | end |
||
− | tr:tag('td'):wikitext(Game{row['Game']}):done() |
||
+ | |||
− | tr:tag("td"):css({ ['white-space'] = 'nowrap' }):wikitext(row["Date"]):done() -- Need to format this right still |
||
+ | function Results:getOrderBy(args) |
||
− | :tag("td") |
||
+ | local orderBy = self:super('getOrderBy', args) |
||
− | :css({ ["background-color"] = "#" .. place["bgcolor"], color = place["fontcolor"], ["text-align"] = "center" }) |
||
+ | return ('%s, TP.TeamOrder DESC'):format(orderBy) |
||
− | :wikitext('<span style="display:none;">' .. place.hiddensort .. "</span>'''" .. place.display .. "'''") |
||
+ | end |
||
− | :done() |
||
+ | |||
− | :tag("td"):wikitext(row["PrizeMarkup"]):done() |
||
+ | function Results:getSubjectWhereCondition(args, subject) |
||
− | tdEvent = tr:tag("td"):wikitext(s.LeagueSprite(row.League) .. " [[" .. row["EventLink"] .. "|" .. row["Event"]) |
||
+ | if util_args.castAsBool(args.noredirects) then |
||
− | if row["Phase"] ~= "" then |
||
+ | return ('TP.Player = "%s"'):format(subject) |
||
− | tdEvent:wikitext(" - " .. row["Phase"]) |
||
− | end |
||
− | tdEvent:wikitext("]]"):done() |
||
− | |||
− | tr:tag("td"):wikitext(m_team.rightshortlinked(row.TeamLink)) |
||
− | |||
− | if row["Prize"] ~= "" then |
||
− | earnings[row["PrizeUnit"]] = (earnings[row["PrizeUnit"]] or 0) + tonumber(row["Prize"],10) |
||
− | end |
||
− | |||
end |
end |
||
+ | return ('PR.OverviewPage="%s"'):format(subject) |
||
− | |||
− | local td = tbl:tag("tr") |
||
− | --:tag("th"):attr("colspan","30"):wikitext("Total Prize: ") |
||
− | |||
− | local earningstable = {} |
||
− | |||
− | td:wikitext(table.concat(earningstable," • ")):done() |
||
− | |||
− | text = tostring(tbl) |
||
− | |||
− | frame:callParserFunction{name="#vardefine:hasnewresults",args={"yes"}} |
||
− | |||
− | return text |
||
− | |||
end |
end |
||
+ | function Results:getTypeWhereCondition(args) |
||
− | function p.load(player, tournamentType, limit) |
||
+ | if args.type then return ('T.EventType="%s"'):format(args.type) end |
||
− | local fieldstable = { |
||
+ | end |
||
− | "TournamentResults.TeamLink=TeamLink", |
||
+ | |||
− | "TournamentResults.Prize_Markup=PrizeMarkup", |
||
+ | -- format rows |
||
− | "TournamentResults.PrizeOther=PrizeOther", |
||
+ | function Results:getOneMember(link, row) |
||
− | "TournamentResults.Prize=Prize", |
||
+ | return util_esports.playerLinkedOrBold(link, row.ThisName) |
||
− | "TournamentResults.PrizeUnit=PrizeUnit", |
||
+ | end |
||
− | "TournamentResults.Date=Date", |
||
− | "TournamentResults.Place=Place", |
||
− | "TournamentResults.Event=Event", |
||
− | "TournamentResults.Phase=Phase", |
||
− | "CONCAT(TournamentResults._pageName)=EventLink", |
||
− | "TournamentRosters.RosterLinks__full=RosterLinks", |
||
− | "TournamentRosters.Roster=RosterNames", |
||
− | 'TournamentRosters.Roster_Linked=Roster', |
||
− | "TournamentRosters.Roles=Role", |
||
− | "TournamentRosters.Roles_Markup=Roles", |
||
− | --"TournamentResults.LastResult=LastResult", |
||
− | --"TournamentResults.LastOpponent_Markup=LastOpponent", |
||
− | "Tournaments.League=League", |
||
− | 'Tournaments.Game=Game', |
||
− | "CONCAT(PlayerRedirects.AllName)=ThisName", |
||
− | } |
||
− | |||
− | local cargotables = "TournamentRosters, TournamentResults, Tournaments, PlayerRedirects" |
||
− | local cargojoin = 'TournamentRosters._pageName = TournamentResults.RosterPage, TournamentResults._pageName=Tournaments._pageName, TournamentRosters.RosterLinks HOLDS PlayerRedirects.AllName' |
||
− | local cargofields = table.concat(fieldstable,",") |
||
− | local cargowhere = 'PlayerRedirects._pageName="' .. player .. '" AND TournamentRosters.TeamLink = TournamentResults.TeamLink' |
||
− | local cargogroupBy = "TournamentResults.UniqueLine" |
||
− | local cargoorderBy = "TournamentResults.Date desc" |
||
+ | -- output |
||
− | if tournamentType and tournamentType ~= '' then |
||
+ | function Results:makeHeaderText(subject) |
||
− | cargowhere = cargowhere .. ' AND Tournaments.EventType = "' .. tournamentType .. '" ' |
||
+ | return i18n.print('TournamentResults', subject) |
||
− | end |
||
− | if not limit then |
||
− | limit = 5000 |
||
− | end |
||
− | |||
− | local cargoquery = { where = cargowhere, join = cargojoin, orderBy = cargoorderBy, groupBy=cargogroupBy, limit=limit } |
||
− | local result = mw.ext.cargo.query(cargotables, cargofields, cargoquery) |
||
− | mw.log('return result') |
||
− | mw.log(result) |
||
− | |||
− | return result |
||
end |
end |
||
Revision as of 16:39, 31 August 2021
To edit the documentation or categories for this module, click here.
local util_args = require('Module:ArgsUtil')
local util_cargo = require('Module:CargoUtil')
local util_esports = require('Module:EsportsUtil')
local util_html = require('Module:HtmlUtil')
local util_map = require('Module:MapUtil')
local util_table = require('Module:TableUtil')
local util_text = require('Module:TextUtil')
local util_toggle = require('Module:ToggleUtil')
local util_tournament = require('Module:TournamentUtil')
local util_vars = require('Module:VarsUtil')
local i18n = require('Module:i18nUtil')
local lang = mw.getLanguage('en')
local Results = require('Module:PlayerResultsAbstract'):extends()
function Results:init()
self:super('init', 'Player')
self.limitOverviewpage = 10
self.limitEverything = 500
self.COLUMNS = { 'Game', 'Date', 'PlaceDisplay', 'PrizeDisplay', 'Tournament', 'TeamDisplay', 'Roster' }
end
local p = {}
function p.main(frame)
local args = util_args.merge()
return Results():run(args)
end
function Results:getSubject(args)
return args[1] or mw.title.getCurrentTitle().baseText
end
-- cargo
function Results:getTables(args)
local tables = self:super('getTables', args)
table.insert(tables, 1, 'TournamentPlayers=TP')
if util_args.castAsBool(args.noredirects) then return tables end
tables[#tables+1] = 'PlayerRedirects=PR'
return tables
end
function Results:getJoin(args)
local join = self:super('getJoin', args)
table.insert(join, 1, 'TP.PageAndTeam=Res.PageAndTeam')
if util_args.castAsBool(args.noredirects) then return join end
table.insert(join, 2, 'TP.Player=PR.AllName')
return join
end
function Results:getFields(args)
local fields = self:super('getFields', args)
fields[#fields+1] = 'TP.Player=ThisName'
return fields
end
function Results:getOrderBy(args)
local orderBy = self:super('getOrderBy', args)
return ('%s, TP.TeamOrder DESC'):format(orderBy)
end
function Results:getSubjectWhereCondition(args, subject)
if util_args.castAsBool(args.noredirects) then
return ('TP.Player = "%s"'):format(subject)
end
return ('PR.OverviewPage="%s"'):format(subject)
end
function Results:getTypeWhereCondition(args)
if args.type then return ('T.EventType="%s"'):format(args.type) end
end
-- format rows
function Results:getOneMember(link, row)
return util_esports.playerLinkedOrBold(link, row.ThisName)
end
-- output
function Results:makeHeaderText(subject)
return i18n.print('TournamentResults', subject)
end
return p