이 모듈에 대한 설명문서는 모듈:TeamCard/설명문서에서 만들 수 있습니다
local p = {}
local getArgs = require('Module:Arguments').getArgs
local Logic = require('Module:Logic')
local getLocal = require('Module:Localisation').getCountryName
local getFlag = require('Module:Flags')
local getTeam = require('Module:Team')
local getIcon
local placementCell = require('Module:Placement')._placement
local args
local GLOBALDATE
local TEAM, TEAM2, TEAM3, TEAMRR
local TABLE_HEIGHT
local TABLE_HEIGHT_ADD = 0
local HEIGHT_ROW, HEIGHT_ROW_PLACEMENT = 26, 30
local MAX_PLAYERS
local DEFAULT_ROW_NUMBER
local IMCOUNT, PCOUNT, CCOUNT = 1, 1, 1
local SETCARD2, SETCARD3
local PLAYERS = {}
function p.draw(frame)
args = getArgs(frame)
args = p._parseArgs(frame)
if args.iconModule then
getIcon = mw.loadData(args.iconModule)
end
local wrapper = p._createTable()
local shouldDisableLpdbStorage = Logic.readBool(mw.ext.VariablesLua.var('disable_LPDB_storage'))
local shouldDisableSmwStorage = Logic.readBool(mw.ext.VariablesLua.var('disable_SMW_storage'))
if not(shouldDisableLpdbStorage or shouldDisableSmwStorage or TEAM == 'TBD' or args.team2 or args.team3) and (args.disable_storage or args.nostorage or 'false') ~= 'true' and mw.title.getCurrentTitle():inNamespaces(0) then
p._saveToLpdb()
end
return wrapper
end
function p._parseArgs(frame)
GLOBALDATE = args.date or p._var('tournament_date', p._var('tournament_edate', p._var('tournament_sdate', os.date('%F'))))
DEFAULT_ROW_NUMBER = tonumber(args.defaultRowNumber or '5')
MAX_PLAYERS = tonumber(args.maxPlayers or '10')
SETCARD2 = (args.t2p1 or args.t2c1) and true or false
SETCARD3 = (args.t3p1 or args.t3c1) and true or false
if args.placement then
TABLE_HEIGHT_ADD = TABLE_HEIGHT_ADD + HEIGHT_ROW_PLACEMENT
end
if args.preview then
TABLE_HEIGHT_ADD = TABLE_HEIGHT_ADD + HEIGHT_ROW
end
TEAM = p._getTeamName(frame, args.team, args.link)
args.image = p._queryLogo(args.image, TEAM)
if args.team2 then
TEAM2 = p._getTeamName(frame, args.team2, args.link2)
IMCOUNT = 2
args.image2 = p._queryLogo(args.image2, TEAM2)
if args.team3 then
TEAM3 = p._getTeamName(frame, args.team3, args.link3)
IMCOUNT = 3
args.image3 = p._queryLogo(args.image3, TEAM3)
end
end
args.c1 = args.c1 or args.c
args.c1link = args.c1link or args.clink
args.c1flag = args.c1flag or args.cflag
args.c1team = args.c1team or args.cteam
args.t2c1 = args.t2c1 or args.t2c
args.t2c1link = args.t2c1link or args.t2clink
args.t2c1flag = args.t2c1flag or args.t2cflag
args.t3c1 = args.t3c1 or args.t3c
args.t3c1link = args.t3c1link or args.t3clink
args.t3c1flag = args.t3c1flag or args.t3cflag
args.t2type = (args.t2title and args.t2title == 'Staff' and 'Staff') or args.t2type
args.t3type = (args.t3title and args.t3title == 'Staff' and 'Staff') or args.t3type
return args
end
function p._getTeamName(frame, team, link)
local name = link or team
if name then
name = getTeam.page(frame, name, GLOBALDATE)
end
name = name or 'TBD'
if name ~= 'TBD' then
nameRR = mw.ext.TeamLiquidIntegration.resolve_redirect(name)
else
nameRR = name
end
if not(TEAM) then
TEAMRR = nameRR
mw.ext.VariablesLua.vardefine('team', name)
mw.ext.VariablesLua.vardefine('teamRR', nameRR)
end
return name
end
function p._queryLogo(image, name)
local lpdbResult
if not image then
lpdbResult = mw.ext.LiquipediaDB.lpdb('datapoint', {
limit = 1,
conditions = '[[type::teamcardimage]] AND [[name::' .. mw.ext.TeamLiquidIntegration.resolve_redirect(name) ..']] AND [[extradata_startdate::<=' .. GLOBALDATE ..']] AND [[extradata_enddate::>' .. GLOBALDATE ..']]',
query = 'image'
})[1] or {}
if not lpdbResult.image then
lpdbResult = mw.ext.LiquipediaDB.lpdb('team', {
limit = 1,
conditions = '[[pagename::' .. string.gsub( (args.resolveTeam and mw.ext.TeamLiquidIntegration.resolve_redirect(name) or name):gsub("^%l", string.upper), ' ', '_') .. ']]',
query = 'logo'
})[1] or {}
if not lpdbResult.logo or lpdbResult.logo == '' then
lpdbResult.ttimage = getTeam.imageFile(nil, name, GLOBALDATE)
if not lpdbResult.ttimage then
image = mw.loadData('Module:TeamCard/default')[(mw.ext.VariablesLua.var('tournament_game') or 'default')]
if not image then
error('Add an entry for ' .. (mw.ext.VariablesLua.var('tournament_game') or 'default') .. ' to Module:TeamCard/default')
end
end
end
end
end
image = 'File:' .. (image or lpdbResult.image or (lpdbResult.logo ~= '' and lpdbResult.logo) or lpdbResult.ttimage)
image = string.gsub(image, 'File:File:', 'File:')
return image
end
function p._createTable()
local wrapper = mw.html.create('div')
local teamcard = p._createOuterTable(args, wrapper)
-- Inner cards
p._setTableHeights()
local inner = teamcard:tag('div')
:addClass('teamcard-inner')
p._createInnerTable( args, inner, '1', string.lower(args.t1type or 'default') )
if SETCARD2 then
p._createInnerTable( args, inner, '2', string.lower(args.t2type or 'sub') )
if SETCARD3 then
p._createInnerTable( args, inner, '3', string.lower(args.t3type or 'former') )
end
end
-- Logo card
p._createLogoTable(args, inner)
if args.inotes then
local notesFooter = wrapper:tag('div')
:addClass('toccolours')
:addClass('mw-collapsible')
:addClass('mw-collapsed')
:attr('id', 'mw-customcollapsible-' .. (args.class or TEAM):gsub(' ','_') .. 'notes')
:css('box-shadow', '3px 3px 5px 0px rgba(0, 0, 0, 0.5)')
:css('z-index', '501')
:css('position', 'absolute')
:css('margin-left', '-15px')
:css('margin-top', '-5px')
:tag('div')
:css('margin-left', '-15px')
:css('margin-bottom', '-10pt')
:wikitext(args.inotes)
end
return wrapper
end
function p._setTableHeights()
local mostPlayers = DEFAULT_ROW_NUMBER
for i=(DEFAULT_ROW_NUMBER + 1), MAX_PLAYERS do
if args['p' .. i] then
if i > mostPlayers and not (i == 6 and not args.c1) then mostPlayers = mostPlayers + 1 end
end
if args['t2p' .. i] then
if i > mostPlayers and not (i == 6 and not args.t2c1) then mostPlayers = mostPlayers + 1 end
end
if args['t3p' .. i] then
if i > mostPlayers and not (i == 6 and not args.t3c1) then mostPlayers = mostPlayers + 1 end
end
end
if args.c2 and args.c2OnNewLine then
mostPlayers = mostPlayers + 1
end
for i=3, 5 do
if args['c' .. i] then
mostPlayers = mostPlayers + 1
end
end
TABLE_HEIGHT = 28 + (HEIGHT_ROW * mostPlayers) + TABLE_HEIGHT_ADD
if SETCARD2 or SETCARD3 then
TABLE_HEIGHT = TABLE_HEIGHT + 27
end
-- Compare current table height, minimal height and predefined height then set tables to highest value
local TCheight = tonumber(args.TCheight or p._var('TCheight', '0'))
TABLE_HEIGHT = math.max(TABLE_HEIGHT, tonumber(args.defaultHeight or '121'), TCheight)
-- Indicator for tallest card; use {{#vardefine:TCheight|}} to standardize height
if tonumber(p._var('maxTCheight', '0')) - TABLE_HEIGHT < 0 then
mw.ext.VariablesLua.vardefine('maxTCheight', TABLE_HEIGHT)
mw.log('maxTCheight', TABLE_HEIGHT)
end
args.imagesize = args.imagesize or ('190x' .. tostring(math.floor(TABLE_HEIGHT/IMCOUNT)-10) .. 'px')
end
function p._createOuterTable(args, root)
local teamcard = root:tag('div')
:attr('data-toggle-area', '1')
:addClass('teamcard toggle-area toggle-area-1')
if args.showroster == 'true' then
teamcard:addClass('teamcard-opened')
end
local headerText
if TEAM ~= 'TBD' then
headerText = '[[' .. TEAM .. '|' .. args.team .. ']]'
if TEAM2 then
if (TEAM2 or 'TBD') ~= 'TBD' then
headerText = headerText .. ' / [[' .. TEAM2 .. '|' .. args.team2 .. ']]'
else
headerText = headerText .. ' / TBD'
end
if TEAM3 then
if (TEAM3 or 'TBD') ~= 'TBD' then
headerText = headerText .. ' / [[' .. TEAM3 .. '|' .. args.team3 .. ']]'
else
headerText = headerText .. ' / TBD'
end
end
end
else
headerText = 'TBD'
end
local header = teamcard:tag('center')
:wikitext('<b>' .. headerText .. '</b>')
if args.inotes then
header:css('display', 'inline-block')
:css('vertical-align', 'bottom')
:css('width', '100%')
:css('max-inline-size', 'calc(200px - 26px)')
local notes = teamcard:tag('div')
:css('font-size', '59%')
:css('display', 'inline-block')
:css('position', 'absolute')
--:css('margin-left', '-7px')
:css('margin-top', '6px')
:css('white-space', 'nowrap')
:css('width', '26px')
:css('text-align', 'right')
local span = notes:tag('span')
:addClass('mw-customtoggle-' .. (args.class or TEAM):gsub(' ','_') .. 'notes')
:tag('abbr')
:attr('title', 'Click to Toggle')
:css('cursor', 'pointer')
:wikitext('Notes')
elseif args.notes then
header:wikitext('<sup title="'.. args.notes..'">' .. args.notes .. '</sup>[[Category:Pages with TeamCard using notes parameter]]')
end
if args.ref then
header:wikitext(args.ref .. '[[Category:Pages with TeamCard using ref parameter]]')
end
return teamcard
end
function p._createInnerTable(args, root, num, cardType)
local prefix = ''
if num ~= '1' then
prefix = 't' .. num
end
local output = root:tag('table')
:addClass('wikitable wikitable-bordered list')
:attr('data-toggle-area-content', num)
:css('height', tostring(TABLE_HEIGHT) .. 'px')
if num == '1' and args.hideroster == 'true' or TEAM2 or TEAM3 then
output:css('display', 'none')
end
local rowNum = 1
if num == '1' then
-- Show the default number of player rows
for i=1, DEFAULT_ROW_NUMBER do
p._newRow(output, i, prefix .. 'p' .. tostring(i), cardType, '')
end
rowNum = DEFAULT_ROW_NUMBER+1
end
-- Show the rest of the player rows (up to max limit) if they're filled in
for i=rowNum, MAX_PLAYERS do
if args[prefix .. 'p' .. tostring(i)] then
p._newRow(output, i, prefix .. 'p' .. tostring(i), cardType, '')
else
break
end
end
-- Show coaches if filled in
if (num == '1' and p._var('teamcard_coaches') ~= '') or args[prefix .. 'c1'] then
if args[prefix .. 'c2'] and not(args.c2OnNewLine) then
-- two coaches one row
p._newRowDouble(output, prefix .. 'c', cardType, 'coach')
else
-- row for every coach
for i=1, 5 do
if args[prefix .. 'c' .. tostring(i)] then
p._newRow(output, i, prefix .. 'c' .. tostring(i), cardType, 'coach')
else
break
end
end
end
end
-- Show toggle button for cards
p._createButtons(output, tonumber(num))
-- Additional Information
if args.placement then
local placeRow = output:tag('tr')
local placeCell = placeRow:tag('td')
:attr('colspan', '2')
:css('height', HEIGHT_ROW_PLACEMENT .. 'px')
:addClass('teamcard-placement')
placementCell{parent = placeCell, placement = args.placement, text = args.placementicon}
end
if args.preview then
local previewRow = output:tag('tr')
:tag('td')
:attr('colspan', '2')
:addClass('teamcard-preview')
:css('height', HEIGHT_ROW .. 'px')
:wikitext('[' .. args.preview .. ' Preview]')
end
end
function p._newRow(root, rowNum, prefix, teamcardType, playerType)
local prefixPos = args[prefix .. 'pos']
local prefixPosLegacy
if teamcardType ~= 'default' then
prefixPosLegacy = args[string.sub(prefix, 1, 2) .. 'pos' .. tostring(rowNum)]
elseif playerType == '' then
prefixPosLegacy = args['pos' .. tostring(rowNum)]
end
-- Make a new row
local row = root:tag('tr')
if args[prefix ..'dnp'] then
row:css('background-color', 'rgba(229, 229, 229, 0.5)')
end
if args[prefix ..'leave'] then
row:css('background-color', 'rgba(249, 199, 199, 0.5)')
end
-- Position
local position
if getIcon then
if prefixPos then
position = getIcon[ string.lower(prefixPos) ]
elseif prefixPosLegacy then
position = getIcon[ string.lower(prefixPosLegacy) ]
elseif playerType == 'coach' then
position = getIcon[ 'coach' ]
elseif teamcardType == 'sub' then
position = getIcon[ 'substitute' ]
elseif teamcardType == 'staff' then
position = getIcon[ 'staff' ]
else
position = getIcon[ string.lower(tostring(rowNum)) ] or tostring(rowNum)
end
else
if (prefixPos or prefixPosLegacy) and teamcardType == 'default' then
position = (prefixPos or prefixPosLegacy)
elseif prefixPos then
position = prefixPos
elseif playerType == 'coach' then
position = '<abbr title="Coach">C</abbr>'
elseif teamcardType == 'sub' then
position = '<abbr title="Substitute">S</abbr>'
elseif teamcardType == 'staff' then
position = '<abbr title="Staff">S</abbr>'
else
position = tostring(rowNum)
end
end
-- Position
local cell = row:tag('th'):wikitext(position)
if playerType == 'coach' and rowNum == 1 and args['coachborder'] ~= 'false' then
cell:css('border-top-width', '2px !important')
end
-- Player
local cell = row:tag('td')
if playerType == 'coach' and rowNum == 1 and args['coachborder'] ~= 'false' then
cell:css('border-top-width', '2px !important')
end
-- Did not play/DNP indicator
if args[prefix ..'dnp'] then
if args[prefix ..'team'] then
cell:wikitext('<div style="float:right; margin:6px 1px 0 0; font-size:60%"><abbr title="Did not play">DNP</abbr></div>')
else
cell:wikitext('<div style="float:right; margin:4px 1px 0 0; font-size:60%"><abbr title="Did not play">DNP</abbr></div>')
end
end
-- Left the team before the tournament ended/LEFT indicator
if args[prefix ..'leave'] then
if args[prefix ..'team'] then
cell:wikitext('<div style="float:right; margin:6px 1px 0 0; font-size:60%"><abbr title="Left the team before the tournament ended">LEFT</abbr></div>')
else
cell:wikitext('<div style="float:right; margin:4px 1px 0 0; font-size:60%"><abbr title="Left the team before the tournament ended">LEFT</abbr></div>')
end
end
-- Team icon
if args[prefix ..'team'] then
cell:wikitext(getTeam.part(frame, args[prefix ..'team'], GLOBALDATE))
end
-- Show flag
local data
args[prefix ..'link'] = args[prefix ..'link'] or args[prefix]
if args[prefix ..'link'] then
data = p._queryPlayer(args[prefix ..'link'])[1]
if data then
args[prefix ..'flag'] = data.nationality
end
end
if args[prefix ..'flag'] then
cell:wikitext(getFlag._Flag(args[prefix ..'flag']) .. ' ')
else
cell:wikitext('<span class=flag>[[File:Space filler flag.png|link=]]</span> ')
end
-- Show id
if args[prefix] then
if args[prefix ..'leave'] then
cell:wikitext('<s>[[' .. args[prefix ..'link'] .. '|' .. args[prefix] .. ']]</s>')
else
cell:wikitext('[[' .. args[prefix ..'link'] .. '|' .. args[prefix] .. ']]')
end
p._playervariables(prefix, args[prefix ..'flag'], args[prefix ..'link'], args[prefix], teamcardType, playerType)
else
cell:wikitext('<abbr title="To Be Determined">TBD</abbr> ')
end
-- Player preview
if args[prefix .. 'preview'] then
cell:wikitext('[[File:Writers_Icon.png|15px|link=' .. args[prefix .. 'preview'] .. '|Preview]]')
end
end
function p._newRowDouble(root, prefix, teamcardType, playerType)
-- Make a new row
local row = root:tag('tr')
-- Row identifier
local cell = row:tag('th'):wikitext('<abbr title="Coaches">C</abbr>')
if playerType == 'coach' and args['coachborder'] ~= 'false' then
cell:css('border-top-width', '2px !important')
end
-- Player
local cell = row:tag('td')
if playerType == 'coach' and args['coachborder'] ~= 'false' then
cell:css('border-top-width', '2px !important')
end
for i=1, 2 do
-- Show flag
local data
args[prefix .. i ..'link'] = args[prefix .. i ..'link'] or args[prefix .. i]
if args[prefix .. i ..'link'] then
data = p._queryPlayer(args[prefix .. i ..'link'])[1]
if data then
args[prefix .. i ..'flag'] = data.nationality
end
end
if args[prefix .. i ..'flag'] then
cell:wikitext(getFlag._Flag(args[prefix .. i ..'flag']) .. ' ')
else
cell:wikitext('<span class=flag>[[File:Space filler flag.png|link=]]</span> ')
end
-- Show id
cell:wikitext('[[' .. args[prefix .. i ..'link'] .. '|' .. args[prefix .. i] .. ']] ')
p._playervariables(prefix .. i, args[prefix .. i ..'flag'], args[prefix .. i ..'link'], args[prefix .. i], teamcardType, playerType)
end
end
function p._queryPlayer(player)
local results = mw.ext.LiquipediaDB.lpdb('player', {
limit = 1,
conditions = '[[pagename::' .. string.gsub(mw.ext.TeamLiquidIntegration.resolve_redirect(player), ' ', '_') .. ']]',
query = 'nationality',
})
return results
end
function p._playervariables(prefix, flag, name, displayname, teamcardType, playerType)
--cases for (normal behaviour), (teamcard 2+3 noVar), (teamcard 2+3)
if (teamcardType == 'default' and args[prefix ..'dnp'] == nil) or (args.noVarDefault and teamcardType ~= 'default' and args[prefix ..'played'] and args[prefix ..'dnp'] == nil) or (args.noVarDefault == nil and teamcardType ~= 'default' and args[prefix ..'dnp'] == nil) then
local prefixVar
local playerTeam = args.resolveTeam and TEAMRR or TEAM
if playerType == 'coach' or teamcardType == 'staff' then
prefixVar = playerTeam .. '_c' .. CCOUNT
prefix = 'c' .. CCOUNT
else
prefixVar = playerTeam .. '_p' .. PCOUNT
prefix = 'p' .. PCOUNT
end
name = string.gsub(mw.ext.TeamLiquidIntegration.resolve_redirect(name), ' ', '_')
PLAYERS[prefix] = name
PLAYERS[prefix .. 'flag'] = getLocal(flag, 'false')
PLAYERS[prefix .. 'dn'] = displayname
mw.ext.VariablesLua.vardefine(prefixVar .. 'flag', getLocal(flag, 'false'))
mw.ext.VariablesLua.vardefine(prefixVar, name)
mw.ext.VariablesLua.vardefine(prefixVar .. 'dn', displayname)
if playerType == 'coach' or teamcardType == 'staff' then
CCOUNT = CCOUNT + 1
else
PCOUNT = PCOUNT + 1
end
end
end
function p._createButtons(root, cardnumber)
local button1title, button2title, toggleArea1, toggleArea2
local teamcard1title = args.t1title or 'Main Roster'
local teamcard2title = args.t2title or 'Substitutes'
local teamcard3title = args.t3title or 'Former'
if cardnumber == 1 then
button1title = teamcard2title
button2title = teamcard3title
toggleArea1 = '2'
toggleArea2 = '3'
elseif cardnumber == 2 then
button1title = teamcard1title
button2title = teamcard3title
toggleArea1 = '1'
toggleArea2 = '3'
elseif cardnumber == 3 then
button1title = teamcard1title
button2title = teamcard2title
toggleArea1 = '1'
toggleArea2 = '2'
end
if SETCARD2 and SETCARD3 then
local buttonRow = root:tag('tr')
:tag('td')
:attr('colspan', '2')
:css('height', '27px')
:css('padding', '0px !important')
:wikitext('<span class="toggle-area-button btn btn-primary" data-toggle-area-btn="' .. toggleArea1 .. '" style="width:50%; height:100%; padding:2px; border:0; border-right:1px solid rgb(187, 187, 187); text-overflow:ellipsis; overflow:hidden;">' .. button1title .. '</span><span class="toggle-area-button btn btn-primary" data-toggle-area-btn="' .. toggleArea2 .. '" style="width:50%; height:100%; padding:2px; border:0; text-overflow:ellipsis; overflow:hidden;">' .. button2title .. '</span>')
elseif SETCARD2 then
local buttonRow = root:tag('tr')
:tag('td')
:attr('colspan', '2')
:css('height', '27px')
:css('padding', '0px !important')
:wikitext('<span class="toggle-area-button btn btn-primary" data-toggle-area-btn="' .. toggleArea1 .. '" style="width:100%; height:100%; padding:2px; border:0; text-overflow:ellipsis; overflow:hidden;">' .. button1title .. '</span>')
end
end
function p._createLogoTable(args, root)
local logoTable = root:tag('table'):addClass('wikitable wikitable-bordered logo')
local logoRow = logoTable:tag('tr'):css('height', tostring(math.floor(TABLE_HEIGHT/IMCOUNT-0.5)) .. 'px;')
:tag('td')
:addClass(TEAM == 'TBD' and 'teamlogo-tbd' or '')
:wikitext('[[' .. args.image .. '|' .. args.imagesize .. '|center|link=]]')
if args.image2 then
local logoRow = logoTable:tag('tr'):css('height', tostring(math.floor(TABLE_HEIGHT/IMCOUNT-0.5)) .. 'px;')
:tag('td')
:addClass(TEAM2 == 'TBD' and 'teamlogo-tbd' or '')
:wikitext('[[' .. args.image2 .. '|' .. args.imagesize .. '|center|link=]]')
end
if args.image3 then
local logoRow = logoTable:tag('tr'):css('height', tostring(math.floor(TABLE_HEIGHT/IMCOUNT-0.5)) .. 'px;')
:tag('td')
:addClass(TEAM3 == 'TBD' and 'teamlogo-tbd' or '')
:wikitext('[[' .. args.image3 .. '|' .. args.imagesize .. '|center|link=]]')
end
if args.qualifier then
local logoRow = logoTable:tag('tr')
:tag('td')
:attr('colspan', '2')
:addClass('teamcard-qualifier')
:wikitext(args.qualifier)
end
end
function p._saveToLpdb()
local playerPrize = p._prizePlayers()
local smw_prefix = args.smw_prefix or args['smw prefix'] or p._var('smw prefix', p._var('smw_prefix'))
mw.ext.LiquipediaDB.lpdb_placement('ranking' .. (smw_prefix ~= '' and '_' .. smw_prefix or '') .. '_' .. string.lower(TEAM), {
tournament = p._var('tournament name pp', p._var('tournament_name', mw.title.getCurrentTitle().text)),
series = p._var('tournament_series'),
parent = smw_prefix ~= '' and (string.gsub(mw.title.getCurrentTitle().text, ' ', '_') .. '/' .. (string.gsub(smw_prefix, '_', '')):gsub("^%l", string.upper)) or (p._var('tournament_subpage') == 'true' and p._var('tournament_parent')),
parentname = smw_prefix ~= '' and p._var('tournament_name') or (p._var('tournament_subpage') == 'true' and p._var('tournament_parent_name')),
image = args.image,
startdate = p._var('tournament_sdate', p._var('tournament_date')),
date = p._var('enddate_' .. TEAM, args.date or p._var('tournament_edate', p._var('tournament_date'))),
participant = args.resolveTeam and TEAMRR or TEAM,
players = mw.ext.LiquipediaDB.lpdb_create_json(PLAYERS),
mode = p._var('tournament_mode', 'team'),
publishertier = p._var('tournament_publisher_tier'),
icon = p._var('tournament_icon'),
extradata = mw.ext.LiquipediaDB.lpdb_create_json({
status = p._var('placement_' .. TEAM) ~= '' and p._var('tournament_status') or '',
publisherpremier = p._var('tournament_publisher_major') ~= '' and 'true' or '',
lis = p._var('tournament_lis'),
series2 = p._var('tournament_series2'),
patch = p._var('tournament_patch'),
individualprizemoney = playerPrize
})
})
end
function p._prizePlayers()
local prizeTeam = mw.ext.LiquipediaDB.lpdb('placement', {
conditions = '[[pagename::' .. string.gsub(mw.title.getCurrentTitle().text, ' ', '_') .. ']] AND [[participant::' .. TEAM .. ']]',
query = 'prizemoney'
})[1] or {}
prizeTeam = tonumber(prizeTeam.prizemoney or 0)
local prizePlayer = 0
if PCOUNT > 1 and prizeTeam > 0 then
prizePlayer = prizeTeam / (PCOUNT-1)
end
mw.ext.VariablesLua.vardefine('prizemoney_individual', prizePlayer)
return prizePlayer
end
function p._var(name, default)
return (mw.ext.VariablesLua.var(name) ~= '') and mw.ext.VariablesLua.var(name) or default or ''
end
return p