Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
tabulator-another
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
tabulator-another
Commits
4781ea09
Commit
4781ea09
authored
Jul 27, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update src/tournament-rules/base.ts, src/tournament-rules/rules/swiss.ts files
parent
67c38b67
Pipeline
#39596
failed with stages
in 2 minutes and 24 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
27 deletions
+93
-27
src/tournament-rules/base.ts
src/tournament-rules/base.ts
+37
-13
src/tournament-rules/rules/swiss.ts
src/tournament-rules/rules/swiss.ts
+56
-14
No files found.
src/tournament-rules/base.ts
View file @
4781ea09
...
@@ -48,20 +48,44 @@ export class TournamentRuleBase {
...
@@ -48,20 +48,44 @@ export class TournamentRuleBase {
return
this
.
tournament
.
matches
.
filter
((
m
)
=>
m
.
status
===
status
);
return
this
.
tournament
.
matches
.
filter
((
m
)
=>
m
.
status
===
status
);
}
}
participantScore
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
private
scoreMap
:
Map
<
number
,
ParticipantScore
>
|
null
=
null
;
protected
getScoreMap
():
Map
<
number
,
ParticipantScore
>
{
if
(
this
.
scoreMap
)
return
this
.
scoreMap
;
const
finishedMatches
=
this
.
specificMatches
(
MatchStatus
.
Finished
);
const
finishedMatches
=
this
.
specificMatches
(
MatchStatus
.
Finished
);
return
{
const
map
=
new
Map
<
number
,
ParticipantScore
>
();
win
:
finishedMatches
.
filter
((
m
)
=>
m
.
winnerId
===
participant
.
id
).
length
,
lose
:
finishedMatches
.
filter
(
for
(
const
match
of
finishedMatches
)
{
(
m
)
=>
const
{
player1Id
,
player2Id
,
winnerId
}
=
match
;
m
.
winnerId
&&
m
.
winnerId
!==
participant
.
id
&&
if
(
!
player1Id
||
!
player2Id
)
continue
;
m
.
participated
(
participant
.
id
),
).
length
,
if
(
!
winnerId
)
{
draw
:
finishedMatches
.
filter
(
for
(
const
pid
of
[
player1Id
,
player2Id
])
{
(
m
)
=>
!
m
.
winnerId
&&
m
.
participated
(
participant
.
id
),
const
score
=
map
.
get
(
pid
)
??
{
win
:
0
,
lose
:
0
,
draw
:
0
};
).
length
,
score
.
draw
+=
1
;
};
map
.
set
(
pid
,
score
);
}
}
else
{
const
loserId
=
winnerId
===
player1Id
?
player2Id
:
player1Id
;
const
winScore
=
map
.
get
(
winnerId
)
??
{
win
:
0
,
lose
:
0
,
draw
:
0
};
winScore
.
win
+=
1
;
map
.
set
(
winnerId
,
winScore
);
const
loseScore
=
map
.
get
(
loserId
)
??
{
win
:
0
,
lose
:
0
,
draw
:
0
};
loseScore
.
lose
+=
1
;
map
.
set
(
loserId
,
loseScore
);
}
}
this
.
scoreMap
=
map
;
return
map
;
}
participantScore
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
return
this
.
getScoreMap
().
get
(
participant
.
id
)
??
{
win
:
0
,
lose
:
0
,
draw
:
0
};
}
}
participantScoreAfter
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
participantScoreAfter
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
...
...
src/tournament-rules/rules/swiss.ts
View file @
4781ea09
...
@@ -70,34 +70,76 @@ export class Swiss extends TournamentRuleBase {
...
@@ -70,34 +70,76 @@ export class Swiss extends TournamentRuleBase {
return
matches
;
return
matches
;
}
}
private
participantRoundsMap
:
Map
<
number
,
Set
<
number
>>
|
null
=
null
;
private
getParticipantRoundsMap
():
Map
<
number
,
Set
<
number
>>
{
if
(
this
.
participantRoundsMap
)
return
this
.
participantRoundsMap
;
const
map
=
new
Map
<
number
,
Set
<
number
>>
();
for
(
const
match
of
this
.
tournament
.
matches
)
{
const
round
=
match
.
round
;
if
(
!
map
.
has
(
round
))
{
map
.
set
(
round
,
new
Set
());
}
const
set
=
map
.
get
(
round
);
if
(
match
.
player1Id
)
set
.
add
(
match
.
player1Id
);
if
(
match
.
player2Id
)
set
.
add
(
match
.
player2Id
);
}
this
.
participantRoundsMap
=
map
;
return
map
;
}
participantScore
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
participantScore
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
const
data
=
super
.
participantScore
(
participant
);
const
baseScore
=
super
.
participantScore
(
participant
);
const
roundsMap
=
this
.
getParticipantRoundsMap
();
let
bye
=
0
;
let
bye
=
0
;
for
(
let
i
=
1
;
i
<=
this
.
currentRoundCount
();
++
i
)
{
for
(
let
i
=
1
;
i
<=
this
.
currentRoundCount
();
++
i
)
{
if
(
const
roundSet
=
roundsMap
.
get
(
i
);
!
this
.
tournament
.
matches
.
some
(
if
(
!
roundSet
?.
has
(
participant
.
id
))
{
(
m
)
=>
m
.
round
===
i
&&
m
.
participated
(
participant
.
id
),
)
)
{
++
bye
;
++
bye
;
}
}
}
}
const
score
=
data
.
win
*
this
.
settings
.
winScore
+
data
.
draw
*
this
.
settings
.
drawScore
+
const
score
=
baseScore
.
win
*
this
.
settings
.
winScore
+
baseScore
.
draw
*
this
.
settings
.
drawScore
+
bye
*
(
participant
.
quit
?
0
:
this
.
settings
.
byeScore
);
bye
*
(
participant
.
quit
?
0
:
this
.
settings
.
byeScore
);
return
{
return
{
...
data
,
...
baseScore
,
bye
,
bye
,
score
,
score
,
};
};
}
}
participantScoreAfter
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
private
opponentMap
:
Map
<
number
,
Set
<
number
>>
|
null
=
null
;
const
opponentIds
=
this
.
specificMatches
(
MatchStatus
.
Finished
)
.
filter
((
m
)
=>
m
.
participated
(
participant
.
id
))
private
getOpponentMap
():
Map
<
number
,
Set
<
number
>>
{
.
map
((
m
)
=>
m
.
opponentId
(
participant
.
id
));
if
(
this
.
opponentMap
)
return
this
.
opponentMap
;
const
map
=
new
Map
<
number
,
Set
<
number
>>
();
const
finished
=
this
.
specificMatches
(
MatchStatus
.
Finished
);
for
(
const
match
of
finished
)
{
const
[
p1
,
p2
]
=
[
match
.
player1Id
,
match
.
player2Id
];
if
(
!
p1
||
!
p2
)
continue
;
if
(
!
map
.
has
(
p1
))
map
.
set
(
p1
,
new
Set
());
if
(
!
map
.
has
(
p2
))
map
.
set
(
p2
,
new
Set
());
const
opponents
=
opponentIds
.
map
((
id
)
=>
this
.
participantMap
.
get
(
id
));
map
.
get
(
p1
).
add
(
p2
);
map
.
get
(
p2
).
add
(
p1
);
}
this
.
opponentMap
=
map
;
return
map
;
}
participantScoreAfter
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
const
opponentIds
=
this
.
getOpponentMap
().
get
(
participant
.
id
)
??
new
Set
();
const
opponents
=
Array
.
from
(
opponentIds
).
map
((
id
)
=>
this
.
participantMap
.
get
(
id
));
return
{
return
{
tieBreaker
:
_
.
sumBy
(
opponents
,
(
p
)
=>
p
.
score
.
score
),
tieBreaker
:
_
.
sumBy
(
opponents
,
(
p
)
=>
p
.
score
.
score
),
...(
participant
.
quit
?
{
score
:
-
1
}
:
{})
...(
participant
.
quit
?
{
score
:
-
1
}
:
{})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment