Skip to content

Commit

Permalink
Add paint graph
Browse files Browse the repository at this point in the history
  • Loading branch information
TheApplePieGod committed Jan 11, 2025
1 parent b467be8 commit 43e8db1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions client/src/components/sidebar/game/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export const GamePage: React.FC<Props> = React.memo((props) => {
<ResourceGraph active={showStats} property="paintPercent" propertyDisplayName="Coverage %" />
<br />
<ResourceGraph active={showStats} property="moneyAmount" propertyDisplayName="Chips" />
<br />
<ResourceGraph active={showStats} property="totalPaint" propertyDisplayName="Paint" />
</div>
) : (
<div>Select a game to see stats</div>
Expand Down
11 changes: 10 additions & 1 deletion client/src/components/sidebar/game/team-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,23 @@ export const UnitsTable: React.FC<UnitsTableProps> = ({ teamStat, teamIdx }) =>
['Mopper', <UnitsIcon teamIdx={teamIdx} robotType="mopper" key="5" />]
]

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 = [
[
'Count',
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])
]
]
}
Expand Down
9 changes: 8 additions & 1 deletion client/src/playback/RoundStat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const EMPTY_ROBOT_COUNTS: Record<schema.RobotType, number> = {

export class TeamRoundStat {
robotCounts: Record<schema.RobotType, number> = { ...EMPTY_ROBOT_COUNTS }
robotPaints: Record<schema.RobotType, number> = { ...EMPTY_ROBOT_COUNTS }
moneyAmount: number = 0
totalPaint: number = 0
paintPercent: number = 0
resourcePatterns: number = 0

Expand All @@ -24,6 +26,7 @@ export class TeamRoundStat {

// Copy any internal objects here
newStat.robotCounts = { ...this.robotCounts }
newStat.robotPaints = { ...this.robotPaints }

return newStat
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 43e8db1

Please sign in to comment.