Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0a18a68
Add styles for stats summary cards
SlothyMan Jun 24, 2026
29068bb
Clean up Miscellaneous.scss by removing empty line
SlothyMan Jun 24, 2026
71e47d6
chore: update visual snapshots
SlothyMan Jun 24, 2026
5e90353
chore: update visual snapshots
github-actions[bot] Jun 24, 2026
23caa33
Add TournamentInputStats module for player input stats
SlothyMan Jun 24, 2026
8fdc2fc
Add TournamentPlayerStatsTable module
SlothyMan Jun 24, 2026
bc516ef
Create Display
SlothyMan Jun 24, 2026
a04531b
Add TournamentPlayerStats calculator module
SlothyMan Jun 24, 2026
7f94b9d
Add GetTournamentPlayerStatsCopyPaste module
SlothyMan Jun 24, 2026
54d54a1
Rename Calculator to Calculator.lua
SlothyMan Jun 25, 2026
5e0b1db
Rename Display to Display.lua
SlothyMan Jun 25, 2026
856cd5b
Rename Table to Table.lua
SlothyMan Jun 25, 2026
75a4989
Rename GetTournamentPlayerStatsCopyPaste to GetTournamentPlayerStatsC…
SlothyMan Jun 25, 2026
35260f6
Rename TournamentInputStats to TournamentInputStats.lua
SlothyMan Jun 25, 2026
16b2d66
Refactor TournamentPlayerStats structure and rendering
SlothyMan Jun 25, 2026
c4c5faa
Refactor TournamentPlayerStats display module
SlothyMan Jun 25, 2026
5dbb8f2
Refactor _generateCopyPaste to use HtmlWidgets
SlothyMan Jun 25, 2026
f8fc5cc
Refactor TournamentInputStats for improved logic and classes
SlothyMan Jun 25, 2026
b0df068
Refactor player stats structure and methods
SlothyMan Jun 25, 2026
efe6e44
Change class names from navigation to stats-summary
SlothyMan Jun 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions lua/wikis/apexlegends/GetTournamentPlayerStatsCopyPaste.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
-- @Liquipedia
-- page=Module:GetTournamentPlayerStatsCopyPaste
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Lua = require('Module:Lua')

local Arguments = Lua.import('Module:Arguments')
local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local HtmlWidgets = Lua.import('Module:Widget/Html')

---@class TournamentPlayerStatsCopyPaste
local CopyPaste = Class.new()

---@param args table
---@param key string
---@param default boolean
---@return boolean
local function readBool(args, key, default)
local value = args[key]

if value == nil or value == '' then
return default
end

value = tostring(value):lower()

if value == '1' or value == 'true' or value == 'yes' then
return true
end

if value == '0' or value == 'false' or value == 'no' then
return false
end

return default
end

---@param args table
---@return string[]
local function getStatFields(args)
local stats = {}

if readBool(args, 'games', false) then
table.insert(stats, 'games')
end
if readBool(args, 'kills', true) then
table.insert(stats, 'kills')
end
if readBool(args, 'assists', true) then
table.insert(stats, 'assists')
end
if readBool(args, 'knocks', false) then
table.insert(stats, 'knocks')
end
if readBool(args, 'damage', false) then
table.insert(stats, 'damage')
end
if readBool(args, 'damageTaken', false) then
table.insert(stats, 'damageTaken')
end

return stats
end

---@param statFields string[]
---@return string
local function makePlayerRow(statFields)
local parts = {'{{Json|name='}

for _, field in ipairs(statFields) do
table.insert(parts, field .. '=')
end

return table.concat(parts, '|') .. '}}'
end

---@param display string
---@return Renderable
function CopyPaste._generateCopyPaste(display)
return HtmlWidgets.Pre{
classes = {'selectall'},
children = mw.text.nowiki(display)
}
end

---@param frame Frame
---@return Renderable
function CopyPaste.run(frame)
local args = Arguments.getArgs(frame)

local id = args.id or ''
local tournament = args.tournament or ''
local playerCount = tonumber(args.players) or 20
local statFields = getStatFields(args)

assert(id ~= '', 'GetTournamentPlayerStatsCopyPaste: missing id')
assert(tournament ~= '', 'GetTournamentPlayerStatsCopyPaste: missing tournament')
assert(playerCount > 0, 'GetTournamentPlayerStatsCopyPaste: players must be greater than 0')

local rows = Array.mapRange(1, playerCount, function()
return '|' .. makePlayerRow(statFields)
end)

local output = table.concat({
'{{TournamentPlayerStatsStore',
'|id=' .. id,
'|tournament=' .. tournament,
'|players={{Json',
table.concat(rows, '\n'),
'}}',
'}}',
}, '\n')

return CopyPaste._generateCopyPaste(output)
end

return CopyPaste
Loading
Loading