Commit 50c04744 authored by nanahira's avatar nanahira

fix participant seq

parent f58def0d
......@@ -4,7 +4,7 @@ import {
Participant,
ParticipantScore,
} from '../../participant/entities/participant.entity';
import _ from 'lodash';
import _, { pick } from 'lodash';
export class SingleElimination extends TournamentRuleBase {
totalRoundCount() {
......@@ -27,6 +27,7 @@ export class SingleElimination extends TournamentRuleBase {
// add participants to first round
const participants = _.sortBy(
this.tournament.participants,
(p) => -p.seq,
(p) => -p.id,
);
const neededMatchesCount =
......@@ -58,14 +59,16 @@ export class SingleElimination extends TournamentRuleBase {
nextRound() {
const finishedMatches = this.specificMatches(MatchStatus.Finished);
const survivedParticipants = this.tournament.participants
.filter(
const survivedParticipants = _.sortBy(
this.tournament.participants.filter(
(p) =>
!finishedMatches.some(
(m) => m.participated(p.id) && m.winnerId !== p.id,
),
)
.reverse();
),
(p) => -p.seq,
(p) => -p.id,
);
const nextRoundCount = this.nextRoundCount();
const matches = this.specificMatches(MatchStatus.Pending).filter(
(m) => m.round === nextRoundCount && !m.isThirdPlaceMatch,
......
......@@ -34,6 +34,7 @@ export class Swiss extends TournamentRuleBase {
if (r === 1) {
const participants = _.sortBy(
this.tournament.participants,
(p) => -p.seq,
(p) => -p.id,
);
for (const match of matches) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment