Skip to content

Commit c785861

Browse files
committed
global cheese counter
1 parent a75e909 commit c785861

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,16 @@ export const GamePage: React.FC<Props> = React.memo((props) => {
143143
<div /*className="flex items-center gap-2"*/>
144144
{/* Note: to keep animation smooth, we should still keep the elements rendered, but we pass showStats into
145145
them so that they don't render any data (since we're likely hiding stats to prevent lag) */}
146+
<ResourceGraph
147+
active={showStats}
148+
property="globalCheeseAmount"
149+
propertyDisplayName="Global Cheese "
150+
/>
151+
<br />
146152
<ResourceGraph
147153
active={showStats}
148154
property="cheeseAmount"
149-
propertyDisplayName="Cheese Amount "
155+
propertyDisplayName="Cheese Transferred "
150156
/>
151157
<br />
152158
<ResourceGraph

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export const ResourceTable: React.FC<ResourceTableProps> = ({ map, teamStat, tea
6262
let catDamagePercent = 0
6363
let ratKingCount = 0
6464
let ratKingPercent = 0
65+
let globalCheese = 0
6566

6667
if (map && teamStat) {
6768
cheeseAmount = teamStat.cheeseAmount
@@ -70,6 +71,7 @@ export const ResourceTable: React.FC<ResourceTableProps> = ({ map, teamStat, tea
7071
catDamagePercent = teamStat.catDamagePercent
7172
ratKingCount = teamStat.ratKingCount
7273
ratKingPercent = teamStat.ratKingPercent
74+
globalCheese = teamStat.globalCheeseAmount
7375
}
7476

7577
const formatPercent = (val: number) => (val * 100).toFixed(1).toString() + '%'
@@ -131,6 +133,7 @@ export const ResourceTable: React.FC<ResourceTableProps> = ({ map, teamStat, tea
131133
</div>
132134
</div>
133135
</div>
136+
<div className="flex items-center w-full mt-2 mb-1 text-xs font-bold justify-around">Global Cheese Amount: {globalCheese}</div>
134137
</div>
135138
)
136139
}
@@ -148,9 +151,9 @@ export const UnitsTable: React.FC<UnitsTableProps> = ({ teamStat, teamIdx }) =>
148151
['Baby Rats', <UnitsIcon teamIdx={teamIdx} img="rat" key="3" />]
149152
]
150153

151-
let data: [string, number[]][] = [['Count', [0, 0, 0, 0]]]
154+
let data: [string, number[]][] = [['Count:', [0, 0, 0, 0]]]
152155
if (teamStat) {
153-
data = [['Count', [teamStat.dirtAmount, teamStat.ratTrapAmount, teamStat.catTrapAmount, teamStat.babyRatCount]]]
156+
data = [['Count:', [teamStat.dirtAmount, teamStat.ratTrapAmount, teamStat.catTrapAmount, teamStat.babyRatCount]]]
154157
}
155158

156159
return (

client/src/playback/RoundStat.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,13 @@ export default class RoundStat {
7676
let totalCheese = 0
7777
let totalCatDamage = 0
7878
let totalRatKings = 0
79+
80+
7981
for (let i = 0; i < delta.teamIdsLength(); i++) {
82+
const combinedStat = delta.teamAliveRatKings(i)!
8083
totalCheese += delta.teamCheeseTransferred(i)!
8184
totalCatDamage += delta.teamCatDamage(i)!
82-
totalRatKings += delta.teamAliveRatKings(i)!
85+
totalRatKings += (combinedStat%10) //lmao
8386
}
8487

8588
for (let i = 0; i < delta.teamIdsLength(); i++) {
@@ -88,10 +91,14 @@ export default class RoundStat {
8891
const teamStat = this.teams.get(team) ?? assert.fail(`team ${i} not found in team stats in round`)
8992

9093
teamStat.cheeseAmount = delta.teamCheeseTransferred(i) ?? assert.fail('missing cheese amount')
94+
teamStat.globalCheeseAmount = Math.floor(delta.teamAliveRatKings(i)! / 10)
9195
teamStat.cheesePercent = totalCheese ? teamStat.cheeseAmount / totalCheese : 0
9296
teamStat.catDamageAmount = delta.teamCatDamage(i) ?? assert.fail('missing cat damage amount')
9397
teamStat.catDamagePercent = totalCatDamage ? teamStat.catDamageAmount / totalCatDamage : 0
98+
9499
teamStat.ratKingCount = delta.teamAliveRatKings(i) ?? assert.fail('missing rat king count')
100+
teamStat.ratKingCount %= 10
101+
95102
teamStat.ratKingPercent = totalRatKings ? teamStat.ratKingCount / totalRatKings : 0
96103
teamStat.dirtAmount = delta.teamDirtAmounts(i) ?? assert.fail('missing dirt amount')
97104
teamStat.ratTrapAmount = delta.teamRatTrapCount(i) ?? assert.fail('missing rat trap amount')

0 commit comments

Comments
 (0)