Commit 50c04744 authored by nanahira's avatar nanahira

fix participant seq

parent f58def0d
...@@ -4,7 +4,7 @@ import { ...@@ -4,7 +4,7 @@ import {
Participant, Participant,
ParticipantScore, ParticipantScore,
} from '../../participant/entities/participant.entity'; } from '../../participant/entities/participant.entity';
import _ from 'lodash'; import _, { pick } from 'lodash';
export class SingleElimination extends TournamentRuleBase { export class SingleElimination extends TournamentRuleBase {
totalRoundCount() { totalRoundCount() {
...@@ -27,6 +27,7 @@ export class SingleElimination extends TournamentRuleBase { ...@@ -27,6 +27,7 @@ export class SingleElimination extends TournamentRuleBase {
// add participants to first round // add participants to first round
const participants = _.sortBy( const participants = _.sortBy(
this.tournament.participants, this.tournament.participants,
(p) => -p.seq,
(p) => -p.id, (p) => -p.id,
); );
const neededMatchesCount = const neededMatchesCount =
...@@ -58,14 +59,16 @@ export class SingleElimination extends TournamentRuleBase { ...@@ -58,14 +59,16 @@ export class SingleElimination extends TournamentRuleBase {
nextRound() { nextRound() {
const finishedMatches = this.specificMatches(MatchStatus.Finished); const finishedMatches = this.specificMatches(MatchStatus.Finished);
const survivedParticipants = this.tournament.participants const survivedParticipants = _.sortBy(
.filter( this.tournament.participants.filter(
(p) => (p) =>
!finishedMatches.some( !finishedMatches.some(
(m) => m.participated(p.id) && m.winnerId !== p.id, (m) => m.participated(p.id) && m.winnerId !== p.id,
), ),
) ),
.reverse(); (p) => -p.seq,
(p) => -p.id,
);
const nextRoundCount = this.nextRoundCount(); const nextRoundCount = this.nextRoundCount();
const matches = this.specificMatches(MatchStatus.Pending).filter( const matches = this.specificMatches(MatchStatus.Pending).filter(
(m) => m.round === nextRoundCount && !m.isThirdPlaceMatch, (m) => m.round === nextRoundCount && !m.isThirdPlaceMatch,
......
...@@ -34,6 +34,7 @@ export class Swiss extends TournamentRuleBase { ...@@ -34,6 +34,7 @@ export class Swiss extends TournamentRuleBase {
if (r === 1) { if (r === 1) {
const participants = _.sortBy( const participants = _.sortBy(
this.tournament.participants, this.tournament.participants,
(p) => -p.seq,
(p) => -p.id, (p) => -p.id,
); );
for (const match of matches) { 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