feat(web): add combat_deaths to MatchResult and display in sandbox
- Add combat_deaths field to MatchResult interface (types.ts, engine.ts) - Display combat kills count in sandbox match result panel - Combat deaths were already tracked in engine (CombatDeaths []int) but not exposed in the web UI types or displayed to users Closes: bf-2wjo
This commit is contained in:
parent
bed7f14797
commit
46915d1437
3 changed files with 6 additions and 3 deletions
|
|
@ -55,6 +55,7 @@ export interface MatchResult {
|
|||
scores: number[];
|
||||
energy: number[];
|
||||
bots_alive: number[];
|
||||
combat_deaths?: number[];
|
||||
}
|
||||
|
||||
export interface GameState {
|
||||
|
|
|
|||
|
|
@ -870,9 +870,10 @@ function loadMonaco(): Promise<any> {
|
|||
function formatResult(result: any, replay: any, _numPlayers: number): string {
|
||||
const winnerName = result.winner >= 0 ? replay.players[result.winner].name : 'Draw';
|
||||
const winnerClass = result.winner === 0 ? 'win' : result.winner >= 0 ? 'loss' : 'draw';
|
||||
const scoreRows = replay.players.map((p: any, i: number) =>
|
||||
`<div class="result-player"><span class="player-dot" style="background:${PLAYER_COLORS[i % PLAYER_COLORS.length]}"></span>${p.name}: ${result.scores[i]} pts, ${result.bots_alive[i]} bots alive</div>`
|
||||
).join('');
|
||||
const scoreRows = replay.players.map((p: any, i: number) => {
|
||||
const combatDeaths = result.combat_deaths?.[i] ?? 0;
|
||||
return `<div class="result-player"><span class="player-dot" style="background:${PLAYER_COLORS[i % PLAYER_COLORS.length]}"></span>${p.name}: ${result.scores[i]} pts, ${result.bots_alive[i]} bots alive, ${combatDeaths} combat kills</div>`;
|
||||
}).join('');
|
||||
return `
|
||||
<div class="result-banner ${winnerClass}">
|
||||
<strong>${result.winner >= 0 ? winnerName + ' wins!' : 'Draw'}</strong>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ export interface MatchResult {
|
|||
scores: number[];
|
||||
energy: number[];
|
||||
bots_alive: number[];
|
||||
combat_deaths?: number[];
|
||||
}
|
||||
|
||||
export interface ReplayPlayer {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue