From 43e8db1cf710967b8a061205ad2cb2bc88686efe Mon Sep 17 00:00:00 2001 From: TheApplePieGod Date: Sat, 11 Jan 2025 16:25:00 -0500 Subject: [PATCH] Add paint graph --- client/src/components/sidebar/game/game.tsx | 2 ++ client/src/components/sidebar/game/team-table.tsx | 11 ++++++++++- client/src/playback/RoundStat.ts | 9 ++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/client/src/components/sidebar/game/game.tsx b/client/src/components/sidebar/game/game.tsx index fce0fe32..20892242 100644 --- a/client/src/components/sidebar/game/game.tsx +++ b/client/src/components/sidebar/game/game.tsx @@ -122,6 +122,8 @@ export const GamePage: React.FC = React.memo((props) => {
+
+ ) : (
Select a game to see stats
diff --git a/client/src/components/sidebar/game/team-table.tsx b/client/src/components/sidebar/game/team-table.tsx index 4f5b5dfd..bc7aca68 100644 --- a/client/src/components/sidebar/game/team-table.tsx +++ b/client/src/components/sidebar/game/team-table.tsx @@ -110,7 +110,10 @@ export const UnitsTable: React.FC = ({ teamStat, teamIdx }) => ['Mopper', ] ] - let data: [string, number[]][] = [['Count', [0, 0, 0, 0, 0, 0]]] + let data: [string, number[]][] = [ + ['Count', [0, 0, 0, 0, 0, 0]], + ['Paint', [0, 0, 0, 0, 0, 0]] + ] if (teamStat) { data = [ [ @@ -118,6 +121,12 @@ export const UnitsTable: React.FC = ({ teamStat, teamIdx }) => Object.values(schema.RobotType) .filter((k) => typeof k === 'number' && k !== schema.RobotType.NONE) .map((k) => teamStat.robotCounts[k as schema.RobotType]) + ], + [ + 'Paint', + Object.values(schema.RobotType) + .filter((k) => typeof k === 'number' && k !== schema.RobotType.NONE) + .map((k) => teamStat.robotPaints[k as schema.RobotType]) ] ] } diff --git a/client/src/playback/RoundStat.ts b/client/src/playback/RoundStat.ts index 6a18981d..14b0d56f 100644 --- a/client/src/playback/RoundStat.ts +++ b/client/src/playback/RoundStat.ts @@ -15,7 +15,9 @@ const EMPTY_ROBOT_COUNTS: Record = { export class TeamRoundStat { robotCounts: Record = { ...EMPTY_ROBOT_COUNTS } + robotPaints: Record = { ...EMPTY_ROBOT_COUNTS } moneyAmount: number = 0 + totalPaint: number = 0 paintPercent: number = 0 resourcePatterns: number = 0 @@ -24,6 +26,7 @@ export class TeamRoundStat { // Copy any internal objects here newStat.robotCounts = { ...this.robotCounts } + newStat.robotPaints = { ...this.robotPaints } return newStat } @@ -98,9 +101,11 @@ export default class RoundStat { } } - // Clear robot counts for recomputing + // Clear values for recomputing for (const stat of this.teams.values()) { + stat.totalPaint = 0 stat.robotCounts = { ...EMPTY_ROBOT_COUNTS } + stat.robotPaints = { ...EMPTY_ROBOT_COUNTS } } // Compute total robot counts @@ -111,6 +116,8 @@ export default class RoundStat { if (body.dead) continue teamStat.robotCounts[body.robotType]++ + teamStat.robotPaints[body.robotType] += body.paint + teamStat.totalPaint += body.paint } const timems = Date.now() - time