Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file modified lua/spec/snapshots/dota2 rankings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lua/spec/snapshots/squad_row_apexlegends.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lua/spec/snapshots/squad_row_counterstrike.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lua/spec/snapshots/squad_row_dota2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lua/spec/snapshots/squad_row_leagueoflegends.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lua/spec/snapshots/squad_row_mobilelegends.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lua/spec/snapshots/squad_row_overwatch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lua/spec/snapshots/squad_row_rocketleague.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lua/spec/snapshots/squad_row_starcraft2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lua/spec/snapshots/squad_row_valorant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions lua/wikis/commons/Squad/Controller.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
-- @Liquipedia
-- page=Module:Squad/Controller
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Lua = require('Module:Lua')

local Array = Lua.import('Module:Array')
local Arguments = Lua.import('Module:Arguments')
local Context = Lua.import('Module:Widget/ComponentContext')
local FnUtil = Lua.import('Module:FnUtil')
local Info = Lua.import('Module:Info', {loadData = true})
local SquadUtils = Lua.import('Module:Squad/Utils')
local Table = Lua.import('Module:Table')

local SquadContexts = Lua.import('Module:Widget/Contexts/Squad')
local SquadDisplay = Lua.import('Module:Widget/Squad/Container')
local SquadHeader = Lua.import('Module:Widget/Squad/Header')
local SquadPlayerDisplay = Lua.import('Module:Widget/Squad/Player')

local SquadController = {}

---@param squadData SquadWrapper
---@param adjustLpdb function?
---@return Component
function SquadController.execute(squadData, adjustLpdb)
local squadPlayers = Array.map(squadData.players, function(player)
return SquadUtils.readSquadPersonArgs(Table.merge(
player,
{status = squadData.squadStatus, type = squadData.squadType}
))
end)

if adjustLpdb then
Array.forEach(squadPlayers, FnUtil.curry(adjustLpdb, squadData))
end

Array.forEach(squadPlayers, function (squadPlayer)
squadPlayer:save()
end)

local squadTable = Context.Provider{
def = SquadContexts.ColumnVisibility,
value = SquadUtils.analyzeColumnVisibility(squadPlayers, squadData.squadStatus),
children = {
SquadDisplay{
status = squadData.squadStatus,
title = squadData.title,
type = squadData.squadType,
header = SquadHeader{status = squadData.squadStatus},
children = Array.map(squadPlayers, function(squadPlayer)
return SquadPlayerDisplay{squadPlayer = squadPlayer}
end)
}
}
}
if not Info.config.squads.hasPosition then
return squadTable
end
return Context.Provider{def = SquadContexts.RoleTitle, value = 'Position', children = {squadTable}}
end

---@param frame Frame
---@return Widget
function SquadController.run(frame, adjustLpdb)
if not Info.config.squads.allowManual then
error('This wiki does not use manual squad tables')
end

local args = Arguments.getArgs(frame)
local squadData = SquadUtils.readWrapperArgs(args)
return SquadController.execute(squadData, adjustLpdb)
end

---@param players table[]
---@param squadStatus SquadStatus
---@param squadType SquadType
---@param customTitle string?
---@return Widget
function SquadController.runAuto(players, squadStatus, squadType, customTitle, adjustLpdb)
local mappedPlayers = Array.map(players, SquadUtils.convertAutoParameters)
local squadData = SquadUtils.createWrapperData(mappedPlayers, squadType, squadStatus, customTitle)
return SquadController.execute(squadData, adjustLpdb)
end

return SquadController
14 changes: 3 additions & 11 deletions lua/wikis/commons/Squad/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@

local Lua = require('Module:Lua')

local Info = Lua.import('Module:Info', {loadData = true})

local Squad = Lua.import('Module:Widget/Squad/Core')
local SquadRow = Lua.import('Module:Squad/Row')
local SquadUtils = Lua.import('Module:Squad/Utils')
local Squad = Lua.import('Module:Squad/Controller')

local CustomSquad = {}

---@param frame Frame
---@return Widget
function CustomSquad.run(frame)
if not Info.config.squads.allowManual then
error('This wiki does not use manual squad tables')
end

return SquadUtils.defaultRunManual(frame, Squad, SquadUtils.defaultRow(SquadRow))
return Squad.run(frame)
end

---@param players table[]
Expand All @@ -31,7 +23,7 @@ end
---@param customTitle string?
---@return Widget
function CustomSquad.runAuto(players, squadStatus, squadType, customTitle)
return SquadUtils.defaultRunAuto(players, squadStatus, squadType, Squad, SquadUtils.defaultRow(SquadRow), customTitle)
return Squad.runAuto(players, squadStatus, squadType, customTitle)
end

return CustomSquad
211 changes: 0 additions & 211 deletions lua/wikis/commons/Squad/Row.lua

This file was deleted.

Loading
Loading