Commit ac934640 authored by nanahira's avatar nanahira

Update src/tournament-rules/rules/swiss.ts,...

Update src/tournament-rules/rules/swiss.ts, src/tournament/entities/Tournament.entity.ts, src/tournament/tournament.service.ts files
parent 30f4c110
Pipeline #37942 passed with stages
in 3 minutes and 5 seconds
...@@ -82,13 +82,13 @@ export class Swiss extends TournamentRuleBase { ...@@ -82,13 +82,13 @@ export class Swiss extends TournamentRuleBase {
++bye; ++bye;
} }
} }
const score = data.win * this.settings.winScore +
data.draw * this.settings.drawScore +
bye * (participant.quit ? 0 : this.settings.byeScore);
return { return {
...data, ...data,
bye, bye,
score: score,
data.win * this.settings.winScore +
data.draw * this.settings.drawScore +
bye * this.settings.byeScore,
}; };
} }
...@@ -100,6 +100,7 @@ export class Swiss extends TournamentRuleBase { ...@@ -100,6 +100,7 @@ export class Swiss extends TournamentRuleBase {
const opponents = opponentIds.map((id) => this.participantMap.get(id)); const opponents = 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 } : {})
}; };
} }
} }
...@@ -248,10 +248,8 @@ export class Tournament extends DescBase { ...@@ -248,10 +248,8 @@ export class Tournament extends DescBase {
p.score = new ParticipantScore(); p.score = new ParticipantScore();
Object.assign(p.score, rule.participantScore(p)); Object.assign(p.score, rule.participantScore(p));
}); });
this.participants.forEach((p) => { const editScores = this.participants.map((p) => rule.participantScoreAfter(p));
const editScore = rule.participantScoreAfter(p); this.participants.forEach((p, i) => Object.assign(p, editScores[i]))
Object.assign(p.score, editScore);
});
this.participants = _.sortBy( this.participants = _.sortBy(
this.participants, this.participants,
(p) => -p.score.score, (p) => -p.score.score,
......
...@@ -306,7 +306,9 @@ export class TournamentService extends CrudService(Tournament, { ...@@ -306,7 +306,9 @@ export class TournamentService extends CrudService(Tournament, {
).toException(); ).toException();
} }
participants = sortAfterSwiss( participants = sortAfterSwiss(
participants.slice(0, dto.swissMaxPlayers), participants
.filter((p) => !p.quit)
.slice(0, dto.swissMaxPlayers),
); );
} }
} else if (dto.ygobbsCompt) { } else if (dto.ygobbsCompt) {
......
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