Skip to content

Commit 39abb2d

Browse files
Rathozclaude
andcommitted
feat(standings): support legacy rXbgN definite status in swiss adaptor
Maps the legacy `r<round>bg<team>` input to `r<round>bg` on the opponent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a9ac199 commit 39abb2d

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--- Triple Comment to Enable our LLS Plugin
2+
describe('Standings Legacy Swiss', function()
3+
local StandingTableLegacySwiss = require('Module:Standings/Table/Legacy/Swiss')
4+
5+
describe('team input', function()
6+
it('maps r<round>bg<team> to r<round>bg on the opponent', function()
7+
local args = {
8+
rounds = '5',
9+
team1 = 'alpha',
10+
team2 = 'bravo',
11+
r3bg1 = 'up',
12+
r5bg1 = 'stayup',
13+
r4bg2 = 'down',
14+
}
15+
16+
local alpha = StandingTableLegacySwiss.parseTeamInput(args, 1)
17+
assert.are_equal('alpha', alpha[1])
18+
assert.are_equal('up', alpha.r3bg)
19+
assert.are_equal('stayup', alpha.r5bg)
20+
assert.is_nil(alpha.r4bg)
21+
22+
local bravo = StandingTableLegacySwiss.parseTeamInput(args, 2)
23+
assert.are_equal('down', bravo.r4bg)
24+
assert.is_nil(bravo.r3bg)
25+
end)
26+
27+
it('ignores rounds beyond the number of rounds', function()
28+
local opponent = StandingTableLegacySwiss.parseTeamInput({rounds = '3', team1 = 'alpha', r4bg1 = 'up'}, 1)
29+
assert.is_nil(opponent.r4bg)
30+
end)
31+
end)
32+
end)

‎lua/wikis/commons/Standings/Table/Legacy/Swiss.lua‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ end
9090

9191
---@param args table
9292
---@param teamIndex integer
93-
---@return {type: OpponentType, [1]: string, tiebreaker: string?, startingpoints: string?, r1: string?}?
93+
---@return {type: OpponentType, [1]: string, tiebreaker: string?, startingpoints: string?, r1bg: string?}?
9494
function StandingTableLegacySwiss.parseTeamInput(args, teamIndex)
9595
local team = args['team' .. teamIndex]
9696
if not team then
@@ -100,7 +100,15 @@ function StandingTableLegacySwiss.parseTeamInput(args, teamIndex)
100100
local tiebreaker = args['temp_tie' .. teamIndex]
101101
local startingPoints = args['temp_p' .. teamIndex]
102102

103-
return {type = Opponent.team, team, tiebreaker = tiebreaker, startingpoints = startingPoints}
103+
-- Legacy `r<round>bg<team>` maps to `r<round>bg` on the opponent
104+
local definiteStatuses = Table.map(Array.range(1, tonumber(args.rounds) or 1), function(roundIndex)
105+
return 'r' .. roundIndex .. 'bg', args['r' .. roundIndex .. 'bg' .. teamIndex]
106+
end)
107+
108+
return Table.merge(
109+
{type = Opponent.team, team, tiebreaker = tiebreaker, startingpoints = startingPoints},
110+
definiteStatuses
111+
)
104112
end
105113

106114
---@param args table

0 commit comments

Comments
 (0)