Skip to content

Commit fd74b0b

Browse files
wormaniaCypherX
andauthored
change(statistics): Move gender-specific statistics to a hover tooltip (pokeclicker#5921)
Co-authored-by: CypherX <cypherx00@gmail.com>
1 parent 67cb2ef commit fd74b0b

File tree

2 files changed

+60
-44
lines changed

2 files changed

+60
-44
lines changed

src/components/statisticsModal.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@ <h5 class="modal-title">Statistics</h5>
3939
<td class="text-left tight text-muted" data-bind="text: App.game.statistics[$data]().toLocaleString('en-US')">-</td>
4040
</tr>
4141
<!-- /ko -->
42+
<!-- ko foreach: App.game.statistics.genderStatisticGroups -->
43+
<tr>
44+
<td class="text-left" data-bind="text: GameConstants.camelCaseToString($data[0])">-</td>
45+
<td class="text-left tight text-muted"
46+
data-bind="tooltip: {
47+
title: `Male: ${App.game.statistics[$data[1]]().toLocaleString('en-US')}
48+
<br/>
49+
Female: ${App.game.statistics[$data[2]]().toLocaleString('en-US')}
50+
<br/>
51+
Genderless: ${App.game.statistics[$data[3]]().toLocaleString('en-US')}`,
52+
html: true,
53+
trigger: 'hover',
54+
placement: 'top',
55+
boundary: 'window'
56+
},
57+
text: App.game.statistics[$data[0]]().toLocaleString('en-US')">
58+
</td>
59+
</tr>
60+
<!-- /ko -->
4261
</tbody>
4362
</table>
4463
</div>

src/modules/DataStore/StatisticStore/index.ts

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -168,50 +168,8 @@ export default class Statistics implements Saveable {
168168
'totalFarmPoints',
169169
'totalBattlePoints',
170170
'totalContestTokens',
171-
'totalPokemonCaptured',
172-
'totalPokemonDefeated',
173-
'totalPokemonEncountered',
174-
'totalPokemonHatched',
175-
'totalShinyPokemonCaptured',
176-
'totalShinyPokemonDefeated',
177-
'totalShinyPokemonEncountered',
178-
'totalShinyPokemonHatched',
179-
'totalMalePokemonCaptured',
180-
'totalMalePokemonDefeated',
181-
'totalMalePokemonEncountered',
182-
'totalMalePokemonHatched',
183-
'totalFemalePokemonCaptured',
184-
'totalFemalePokemonDefeated',
185-
'totalFemalePokemonEncountered',
186-
'totalFemalePokemonHatched',
187-
'totalGenderlessPokemonCaptured',
188-
'totalGenderlessPokemonDefeated',
189-
'totalGenderlessPokemonEncountered',
190-
'totalGenderlessPokemonHatched',
191-
'totalShinyMalePokemonCaptured',
192-
'totalShinyMalePokemonDefeated',
193-
'totalShinyMalePokemonEncountered',
194-
'totalShinyMalePokemonHatched',
195-
'totalShinyFemalePokemonCaptured',
196-
'totalShinyFemalePokemonDefeated',
197-
'totalShinyFemalePokemonEncountered',
198-
'totalShinyFemalePokemonHatched',
199-
'totalShinyGenderlessPokemonCaptured',
200-
'totalShinyGenderlessPokemonDefeated',
201-
'totalShinyGenderlessPokemonEncountered',
202-
'totalShinyGenderlessPokemonHatched',
203-
'totalShadowPokemonCaptured',
204-
'totalShadowPokemonDefeated',
205-
'totalShadowMalePokemonCaptured',
206-
'totalShadowMalePokemonDefeated',
207-
'totalShadowFemalePokemonCaptured',
208-
'totalShadowFemalePokemonDefeated',
209-
'totalShadowGenderlessPokemonCaptured',
210-
'totalShadowGenderlessPokemonDefeated',
211-
'totalShinyTrainerPokemonSeen',
212171
'undergroundItemsFound',
213172
'undergroundLayersMined',
214-
'undergroundLayersFullyMined',
215173
'undergroundTrades',
216174
'totalManualHarvests',
217175
'totalBerriesHarvested',
@@ -234,6 +192,12 @@ export default class Statistics implements Saveable {
234192
'safariStepsTaken',
235193
'safariItemsObtained',
236194
];
195+
196+
hiddenObservables = [
197+
'totalShinyTrainerPokemonSeen',
198+
'undergroundLayersFullyMined',
199+
];
200+
237201
arrayObservables = [
238202
'gymsDefeated',
239203
'dungeonsCleared',
@@ -273,8 +237,35 @@ export default class Statistics implements Saveable {
273237
'routeKills',
274238
];
275239

240+
statisticGenders = ['', 'Male', 'Female', 'Genderless'];
241+
242+
baseGenderObservables = [
243+
'total{{GENDER}}PokemonCaptured',
244+
'total{{GENDER}}PokemonDefeated',
245+
'total{{GENDER}}PokemonEncountered',
246+
'total{{GENDER}}PokemonHatched',
247+
'totalShiny{{GENDER}}PokemonCaptured',
248+
'totalShiny{{GENDER}}PokemonDefeated',
249+
'totalShiny{{GENDER}}PokemonEncountered',
250+
'totalShiny{{GENDER}}PokemonHatched',
251+
'totalShadow{{GENDER}}PokemonCaptured',
252+
'totalShadow{{GENDER}}PokemonDefeated',
253+
];
254+
255+
genderStatisticGroups = this.baseGenderObservables.map((observableString) => {
256+
return this.statisticGenders.map((gender) => {
257+
return observableString.replace('{{GENDER}}', gender);
258+
});
259+
});
260+
261+
genderObservables = this.genderStatisticGroups.flat();
262+
276263
constructor() {
277-
this.observables.forEach((prop) => {
264+
[].concat(
265+
this.observables,
266+
this.hiddenObservables,
267+
this.genderObservables,
268+
).forEach((prop) => {
278269
this[prop] = ko.observable<number>(0).extend({ numeric: 0 });
279270
});
280271

@@ -394,6 +385,8 @@ export default class Statistics implements Saveable {
394385
// process all of them together
395386
[].concat(
396387
this.observables,
388+
this.hiddenObservables,
389+
this.genderObservables,
397390
this.arrayObservables,
398391
this.objectObservables,
399392
this.autogeneratedObservables,
@@ -407,7 +400,11 @@ export default class Statistics implements Saveable {
407400
return;
408401
}
409402

410-
this.observables.forEach((prop) => { this[prop](json[prop] || 0); });
403+
[].concat(
404+
this.observables,
405+
this.hiddenObservables,
406+
this.genderObservables,
407+
).forEach((prop) => { this[prop](json[prop] || 0); });
411408

412409
this.arrayObservables.forEach((array) => {
413410
json[array]?.forEach((el, index) => {

0 commit comments

Comments
 (0)