Skip to content

Commit 211e0ea

Browse files
committed
feat: max battle stats display
Requires UnownHash/Golbat#307.
1 parent ce32ce1 commit 211e0ea

9 files changed

Lines changed: 47 additions & 4 deletions

File tree

packages/locales/lib/human/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,8 @@
825825
"placed_pokemon": "Placed Pokémon",
826826
"attack_bonus": "Attack Bonus",
827827
"battle_bonus": "Battle Bonus",
828+
"station_battle_hp": "{{value}} HP",
829+
"station_battle_cp_multiplier": "CP Multiplier: {{value}}",
828830
"copy_coordinates": "Copy Coordinates",
829831
"enable_station_popup_coords": "Show Power Spot Coords",
830832
"station_icons": "Power Spot Icons",

packages/types/lib/scanner.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ export interface Station<Parsed extends boolean = false> {
385385
battle_pokemon_bread_mode: number
386386
battle_pokemon_move_1: number
387387
battle_pokemon_move_2: number
388+
battle_pokemon_stamina?: number
389+
battle_pokemon_cp_multiplier?: number
388390

389391
total_stationed_pokemon: number
390392
total_stationed_gmax: number

packages/types/lib/server.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export interface DbContext {
4646
hasShowcaseForm: boolean
4747
hasShowcaseType: boolean
4848
hasStationedGmax: boolean
49+
hasBattlePokemonStats: boolean
4950
hasPokemonShinyStats?: boolean
5051
connection?: number
5152
}

server/src/graphql/typeDefs/scanner.graphql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ type Station {
297297
battle_pokemon_bread_mode: Int
298298
battle_pokemon_move_1: Int
299299
battle_pokemon_move_2: Int
300+
battle_pokemon_stamina: Int
301+
battle_pokemon_cp_multiplier: Float
300302
}
301303

302304
type StationPokemon {

server/src/models/Station.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ class Station extends Model {
2020
* @param {import("@rm/types").DbContext} ctx
2121
* @returns {Promise<import("@rm/types").FullStation[]>}
2222
*/
23-
static async getAll(perms, args, { isMad, hasStationedGmax }) {
23+
static async getAll(
24+
perms,
25+
args,
26+
{ isMad, hasStationedGmax, hasBattlePokemonStats },
27+
) {
2428
const { areaRestrictions } = perms
2529
const { stationUpdateLimit, stationInactiveLimitDays } =
2630
config.getSafe('api')
@@ -98,6 +102,9 @@ class Station extends Model {
98102
select.push(
99103
hasStationedGmax ? 'total_stationed_gmax' : 'stationed_pokemon',
100104
)
105+
if (hasBattlePokemonStats) {
106+
select.push('battle_pokemon_stamina', 'battle_pokemon_cp_multiplier')
107+
}
101108

102109
if (!onlyAllStations) {
103110
query.whereNotNull('battle_pokemon_id').andWhere('battle_end', '>', ts)

server/src/services/DbManager.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ class DbManager extends Logger {
155155
'showcase_pokemon_form_id' in columns,
156156
'showcase_pokemon_type_id' in columns,
157157
])
158-
const hasStationedGmax =
159-
'total_stationed_gmax' in (await schema('station').columnInfo())
158+
const stationColumns = await schema('station').columnInfo()
159+
const hasStationedGmax = 'total_stationed_gmax' in stationColumns
160+
const hasBattlePokemonStats =
161+
'battle_pokemon_stamina' in stationColumns &&
162+
'battle_pokemon_cp_multiplier' in stationColumns
160163
const [hasLayerColumn] = isMad
161164
? await schema('trs_quest')
162165
.columnInfo()
@@ -213,6 +216,7 @@ class DbManager extends Logger {
213216
hasShowcaseForm,
214217
hasShowcaseType,
215218
hasStationedGmax,
219+
hasBattlePokemonStats,
216220
hasShortcode,
217221
hasPokemonShinyStats,
218222
}
@@ -235,7 +239,6 @@ class DbManager extends Logger {
235239
// Add support for HTTP authentication
236240
httpAuth: this.endpoints[i].httpAuth,
237241
pvpV2: true,
238-
hasPokemonShinyStats: false,
239242
}
240243

241244
Object.entries(this.models).forEach(([category, sources]) => {

src/features/station/StationPopup.jsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ function StationMedia({
269269
battle_pokemon_bread_mode,
270270
battle_level,
271271
battle_end,
272+
battle_pokemon_stamina,
273+
battle_pokemon_cp_multiplier,
272274
}) {
273275
const { t: tById } = useTranslateById()
274276
const { t } = useTranslation()
@@ -282,6 +284,14 @@ function StationMedia({
282284
}
283285
return poke?.types || []
284286
})
287+
const battleStaminaDisplay =
288+
typeof battle_pokemon_stamina === 'number'
289+
? battle_pokemon_stamina.toLocaleString()
290+
: null
291+
const battleCpMultiplierDisplay =
292+
typeof battle_pokemon_cp_multiplier === 'number'
293+
? battle_pokemon_cp_multiplier.toLocaleString()
294+
: null
285295

286296
return isBattleActive ? (
287297
<CardMedia>
@@ -329,6 +339,18 @@ function StationMedia({
329339
{t(`max_battle_${battle_level}`)}
330340
</Typography>
331341
)}
342+
{battleStaminaDisplay && (
343+
<Typography variant="caption" align="center">
344+
{t('station_battle_hp', { value: battleStaminaDisplay })}
345+
</Typography>
346+
)}
347+
{battleCpMultiplierDisplay && (
348+
<Typography variant="caption" align="center">
349+
{t('station_battle_cp_multiplier', {
350+
value: battleCpMultiplierDisplay,
351+
})}
352+
</Typography>
353+
)}
332354
</Stack>
333355
</Box>
334356
</CardMedia>

src/features/station/StationTile.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ const trackedBattleKeys = [
103103
'battle_start',
104104
'battle_end',
105105
'is_battle_available',
106+
'battle_pokemon_stamina',
107+
'battle_pokemon_cp_multiplier',
106108
'total_stationed_pokemon',
107109
'total_stationed_gmax',
108110
'updated',

src/services/queries/station.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const battle = gql`
2929
battle_pokemon_bread_mode
3030
battle_pokemon_move_1
3131
battle_pokemon_move_2
32+
battle_pokemon_stamina
33+
battle_pokemon_cp_multiplier
3234
total_stationed_pokemon
3335
total_stationed_gmax
3436
}

0 commit comments

Comments
 (0)