Skip to content

Commit 43e8db1

Browse files
Add paint graph
1 parent b467be8 commit 43e8db1

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

client/src/components/sidebar/game/game.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ export const GamePage: React.FC<Props> = React.memo((props) => {
122122
<ResourceGraph active={showStats} property="paintPercent" propertyDisplayName="Coverage %" />
123123
<br />
124124
<ResourceGraph active={showStats} property="moneyAmount" propertyDisplayName="Chips" />
125+
<br />
126+
<ResourceGraph active={showStats} property="totalPaint" propertyDisplayName="Paint" />
125127
</div>
126128
) : (
127129
<div>Select a game to see stats</div>

client/src/components/sidebar/game/team-table.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,23 @@ export const UnitsTable: React.FC<UnitsTableProps> = ({ teamStat, teamIdx }) =>
110110
['Mopper', <UnitsIcon teamIdx={teamIdx} robotType="mopper" key="5" />]
111111
]
112112

113-
let data: [string, number[]][] = [['Count', [0, 0, 0, 0, 0, 0]]]
113+
let data: [string, number[]][] = [
114+
['Count', [0, 0, 0, 0, 0, 0]],
115+
['Paint', [0, 0, 0, 0, 0, 0]]
116+
]
114117
if (teamStat) {
115118
data = [
116119
[
117120
'Count',
118121
Object.values(schema.RobotType)
119122
.filter((k) => typeof k === 'number' && k !== schema.RobotType.NONE)
120123
.map((k) => teamStat.robotCounts[k as schema.RobotType])
124+
],
125+
[
126+
'Paint',
127+
Object.values(schema.RobotType)
128+
.filter((k) => typeof k === 'number' && k !== schema.RobotType.NONE)
129+
.map((k) => teamStat.robotPaints[k as schema.RobotType])
121130
]
122131
]
123132
}

client/src/playback/RoundStat.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ const EMPTY_ROBOT_COUNTS: Record<schema.RobotType, number> = {
1515

1616
export class TeamRoundStat {
1717
robotCounts: Record<schema.RobotType, number> = { ...EMPTY_ROBOT_COUNTS }
18+
robotPaints: Record<schema.RobotType, number> = { ...EMPTY_ROBOT_COUNTS }
1819
moneyAmount: number = 0
20+
totalPaint: number = 0
1921
paintPercent: number = 0
2022
resourcePatterns: number = 0
2123

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

2527
// Copy any internal objects here
2628
newStat.robotCounts = { ...this.robotCounts }
29+
newStat.robotPaints = { ...this.robotPaints }
2730

2831
return newStat
2932
}
@@ -98,9 +101,11 @@ export default class RoundStat {
98101
}
99102
}
100103

101-
// Clear robot counts for recomputing
104+
// Clear values for recomputing
102105
for (const stat of this.teams.values()) {
106+
stat.totalPaint = 0
103107
stat.robotCounts = { ...EMPTY_ROBOT_COUNTS }
108+
stat.robotPaints = { ...EMPTY_ROBOT_COUNTS }
104109
}
105110

106111
// Compute total robot counts
@@ -111,6 +116,8 @@ export default class RoundStat {
111116
if (body.dead) continue
112117

113118
teamStat.robotCounts[body.robotType]++
119+
teamStat.robotPaints[body.robotType] += body.paint
120+
teamStat.totalPaint += body.paint
114121
}
115122

116123
const timems = Date.now() - time

0 commit comments

Comments
 (0)