Commit 9d194e19 authored by xiaoye's avatar xiaoye

update searcher in tournament

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