Refactor EventFight handling to include team relation names and update type definitions
All checks were successful
SteamWarCI Build successful
All checks were successful
SteamWarCI Build successful
This commit is contained in:
@@ -25,28 +25,44 @@ export class EventModel {
|
||||
private remapFights(v: Array<EventFight>, rels: Array<ResponseRelation>) {
|
||||
return v.map((fight) => {
|
||||
let f = JSON.parse(JSON.stringify(fight)) as EventFight;
|
||||
|
||||
let blueTeamRelation = f.blueTeam.name;
|
||||
let redTeamRelation = f.redTeam.name;
|
||||
|
||||
let relations = rels.filter((relation) => relation.fight === f.id);
|
||||
|
||||
relations.forEach((relation) => {
|
||||
let str = "";
|
||||
if (relation.type === "FIGHT") {
|
||||
str += `${relation.fromPlace === 0 ? "Gewinner" : "Verlierer"} von ${relation.fromFight?.blueTeam.name} vs ${relation.fromFight?.redTeam.name} (${new Date(
|
||||
str = `${relation.fromPlace === 0 ? "Gewinner" : "Verlierer"} von ${relation.fromFight?.blueTeam.name} vs ${relation.fromFight?.redTeam.name} (${new Date(
|
||||
relation.fromFight?.start ?? 0
|
||||
).toLocaleTimeString("de-DE", {
|
||||
timeStyle: "short",
|
||||
})})`;
|
||||
} else {
|
||||
str += `${relation.fromPlace + 1}. Platz von ${relation.fromGroup?.name}`;
|
||||
str = `${relation.fromPlace + 1}. Platz von ${relation.fromGroup?.name}`;
|
||||
}
|
||||
|
||||
if (relation.team === "BLUE") {
|
||||
f.blueTeam.name += ` (${str})`;
|
||||
blueTeamRelation = str;
|
||||
} else {
|
||||
f.redTeam.name += ` (${str})`;
|
||||
redTeamRelation = str;
|
||||
}
|
||||
});
|
||||
|
||||
return f;
|
||||
return {
|
||||
...f,
|
||||
blueTeam: {
|
||||
...f.blueTeam,
|
||||
nameWithRelation: `${f.blueTeam.name} (${blueTeamRelation})`,
|
||||
},
|
||||
redTeam: {
|
||||
...f.redTeam,
|
||||
nameWithRelation: `${f.redTeam.name} (${redTeamRelation})`,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export type EventFightModel = (typeof EventModel.prototype.fights)[number];
|
||||
|
||||
Reference in New Issue
Block a user