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 {
++bye;
}
}
const score = data.win * this.settings.winScore +
data.draw * this.settings.drawScore +
bye * (participant.quit ? 0 : this.settings.byeScore);
return {
...data,
bye,
score:
data.win * this.settings.winScore +
data.draw * this.settings.drawScore +
bye * this.settings.byeScore,
score,
};
}
......@@ -100,6 +100,7 @@ export class Swiss extends TournamentRuleBase {
const opponents = opponentIds.map((id) => this.participantMap.get(id));
return {
tieBreaker: _.sumBy(opponents, (p) => p.score.score),
...(participant.quit ? { score: -1 } : {})
};
}
}
......@@ -248,10 +248,8 @@ export class Tournament extends DescBase {
p.score = new ParticipantScore();
Object.assign(p.score, rule.participantScore(p));
});
this.participants.forEach((p) => {
const editScore = rule.participantScoreAfter(p);
Object.assign(p.score, editScore);
});
const editScores = this.participants.map((p) => rule.participantScoreAfter(p));
this.participants.forEach((p, i) => Object.assign(p, editScores[i]))
this.participants = _.sortBy(
this.participants,
(p) => -p.score.score,
......
......@@ -306,7 +306,9 @@ export class TournamentService extends CrudService(Tournament, {
).toException();
}
participants = sortAfterSwiss(
participants.slice(0, dto.swissMaxPlayers),
participants
.filter((p) => !p.quit)
.slice(0, dto.swissMaxPlayers),
);
}
} 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