Commit b5fc8f01 authored by xiaoye's avatar xiaoye

修复比分错误

parent 3facc8b5
Pipeline #40049 passed with stages
in 2 minutes and 44 seconds
......@@ -20,6 +20,8 @@ class Match {
childMatchId : number;
constructor(obj : MatchObject, p : Array<Participant>) {
console.log(obj.player1Score)
console.log(obj.player2Score)
this.id = obj.id;
this.tournamentId = obj.tournamentId;
this.round = obj.round;
......
......@@ -46,11 +46,13 @@ class Participant {
}
getScore = (matches : Array<Match>, t : Tournament) : void => {
const max = Math.max(...matches.filter(i => i.status == 'Finished' || i.status == 'Running').map(i => i.round));
const joins = matches.filter(i => this.id == i.player1.id || this.id == i.player2.id);
const m = {
win : matches.filter(i => this.id == i.winnerId).length,
draw : matches.filter(i => (this.id == i.player1.id || this.id == i.player2.id) && Number.isNaN(i.winnerId)).length,
lose : matches.filter(i => (this.id == i.player1.id || this.id == i.player2.id) && !Number.isNaN(i.winnerId) && i.winnerId != this.id).length,
bye : Math.max(...matches.filter(i => i.status == 'Finished' || i.status == 'Running').map(i => i.round)) - matches.filter(i => this.id == i.player1.id || this.id == i.player2.id).length
win : joins.filter(i => this.id == i.winnerId && i.status == "Finished").length,
draw : joins.filter(i => i.winnerId === null && i.status == "Finished").length,
lose : joins.filter(i => i.winnerId !== null && i.winnerId != this.id && i.status == "Finished").length,
bye : max - joins.length
};
this.score = {
score : m.win * t.ruleSettings.winScore + m.draw * t.ruleSettings.drawScore + m.bye * t.ruleSettings.byeScore,
......
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