Commit 9d194e19 authored by xiaoye's avatar xiaoye

update searcher in tournament

parent 7f023636
......@@ -65,14 +65,14 @@
id : i.id,
next : i.childMatchId,
player1: {
id: i.player1Id ? i.player1Id.toString() : '',
name: i.player1Id ? getName(i.player1Id) : '',
winner: i.winnerId ? i.player1Id == i.winnerId : undefined
id: i.player1.id ? i.player1.id.toString() : '',
name: i.player1.id ? getName(i.player1.id) : '',
winner: i.winnerId ? i.player1.id == i.winnerId : undefined
},
player2: {
id: i.player2Id ? i.player2Id.toString() : '',
name: i.player2Id ? getName(i.player2Id) : '',
winner: i.winnerId ? i.player2Id == i.winnerId : undefined
id: i.player2.id ? i.player2.id.toString() : '',
name: i.player2.id ? getName(i.player2.id) : '',
winner: i.winnerId ? i.player2.id == i.winnerId : undefined
}
});
});
......
This diff is collapsed.
import { MatchObject } from './type.ts';
import Participant from './participant.ts'
import Participant from './participant.ts';
interface player {
id : number;
score : number;
name : string;
}
class Match {
id : number;
......@@ -7,10 +13,8 @@ class Match {
round : number;
isThirdPlaceMatch : boolean;
status : string;
player1Score : number;
player2Score : number;
player1Id : number;
player2Id : number;
player1 : player;
player2 : player;
winnerId : number | null;
childMatchId : number;
......@@ -20,10 +24,18 @@ class Match {
this.round = obj.round;
this.isThirdPlaceMatch = obj.isThirdPlaceMatch;
this.status = obj.status;
this.player1Id = obj.player1Id;
this.player2Id = obj.player2Id;
this.player1Score = obj.player1Score;
this.player2Score = obj.player2Score;
const name1 = obj.player1?.name.split('+') ?? [];
this.player1 = {
id : obj.player1Id,
name : (name1.length == 2 && !Number.isNaN(name1[0]) && name1[0].length > 3) ? name1[1] : obj.player1?.name ?? '',
score : obj.player1Score
};
const name2 = obj.player2?.name.split('+') ?? [];
this.player2 = {
id : obj.player2Id,
name : (name2.length == 2 && !Number.isNaN(name2[0]) && name2[0].length > 3) ? name2[1] : obj.player2?.name ?? '',
score : obj.player2Score
};
this.winnerId = obj.winnerId as number | null;
this.childMatchId = obj.childMatchId;
}
......
......@@ -12,7 +12,7 @@ class Participant {
deck : YGOProDeck | undefined;
constructor(obj: ParticipantObject) {
const name = obj.name.split('+')
const name = obj.name.split('+');
this.name = (name.length == 2 && !Number.isNaN(name[0]) && name[0].length > 3) ? name[1] : obj.name;
this.tournamentId = obj.tournamentId;
this.id = obj.id;
......
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