Skip to content

Commit

Permalink
feat: add support for guarding_pokemon_display
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed May 5, 2024
1 parent ef7db5c commit 0579fc4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/types/lib/scanner.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ export interface Device {

export type FullDevice = FullModel<Device, DeviceModel>

export interface PokemonDisplay {
form: number
costume: number
gender: number
shiny: boolean
temp_evolution: number
alignment: number
badge: number
location_card: number
}

export interface Gym {
id: string
lat: number
Expand All @@ -41,6 +52,7 @@ export interface Gym {
raid_pokemon_id: number
updated: number
guarding_pokemon_id: number
guarding_pokemon_display: PokemonDisplay
available_slots: number
team_id: number
raid_level: number
Expand Down
1 change: 1 addition & 0 deletions server/src/graphql/typeDefs/scanner.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Gym {
raid_pokemon_id: Int
updated: Int
guarding_pokemon_id: Int
guarding_pokemon_display: JSON
available_slots: Int
team_id: Int
raid_level: Int
Expand Down
1 change: 1 addition & 0 deletions server/src/models/Gym.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const gymFields = [
'team_id',
'in_battle',
'guarding_pokemon_id',
'guarding_pokemon_display',
'total_cp',
'power_up_points',
'power_up_level',
Expand Down
14 changes: 13 additions & 1 deletion src/features/gym/GymPopup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ const ExtraGymInfo = ({
updated,
total_cp,
guarding_pokemon_id,
guarding_pokemon_display,
}) => {
const { t, i18n } = useTranslation()
const Icons = useMemory((s) => s.Icons)
Expand All @@ -643,12 +644,23 @@ const ExtraGymInfo = ({
)

const numFormatter = new Intl.NumberFormat(i18n.language)
guarding_pokemon_display ||= {}

return (
<Grid container alignItems="center" justifyContent="center">
{!!guarding_pokemon_id && updated > gymValidDataLimit && (
<ExtraInfo title="defender">
<TextWithIcon src={Icons.getPokemon(guarding_pokemon_id)}>
<TextWithIcon
src={Icons.getPokemon(
guarding_pokemon_id,
guarding_pokemon_display.form,
0,
guarding_pokemon_display.gender,
guarding_pokemon_display.costume,
guarding_pokemon_display.alignment,
guarding_pokemon_display.shiny,
)}
>
{t(`poke_${guarding_pokemon_id}`)}
</TextWithIcon>
</ExtraInfo>
Expand Down
1 change: 1 addition & 0 deletions src/services/queries/gym.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const gym = gql`
team_id
in_battle
guarding_pokemon_id
guarding_pokemon_display
total_cp
badge
power_up_level
Expand Down

0 comments on commit 0579fc4

Please sign in to comment.