Commit 6d18e1ab authored by xiaoye's avatar xiaoye

修复比分

parent fc7834d4
Pipeline #40063 passed with stages
in 1 minute and 16 seconds
......@@ -22,6 +22,7 @@ class Participant {
this.id = obj.id;
this.deckbuf = obj.deckbuf ?? '';
this.quit = obj.quit ?? false;
this.score = obj.score;
if (obj.deckbuf)
this.deck = YGOProDeck.fromUpdateDeckPayload(Base64.toUint8Array(this.deckbuf));
}
......@@ -44,34 +45,6 @@ class Participant {
const data = this.deck?.toYdkString() ?? '';
return new Blob([data], { type: 'text/plain' });
}
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 : 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,
win : m.win,
draw : m.draw,
bye : m.bye,
lose : m.lose
}
}
getTieBreaker = (participants : Array<Participant>, matches : Array<Match>) : void => {
let tieBreaker = 0;
matches.filter(i => this.id == i.player1.id || this.id == i.player2.id).forEach(i => {
const id = this.id == i.player1.id ? i.player2.id : i.player1.id;
const p = participants.find(p => p.id == id )?.score.score ?? 0;
tieBreaker += p;
});
this.score.tieBreaker = tieBreaker;
}
}
export default Participant;
......@@ -108,12 +108,6 @@ class TabulatorAPI {
response.data.data.matches.forEach((i : MatchObject) => {
matches.push(new Match(i, participants));
});
participants.forEach(i => {
i.getScore(matches, tournament);
});
participants.forEach(i => {
i.getTieBreaker(participants, matches);
});
if (tournament.status != 'Ready') {
participants.sort((a, b) => {
return b.score.score - a.score.score
......
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