Skip to content

Commit

Permalink
feat: support pokemon display in showcases
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Sep 16, 2024
1 parent 4825010 commit d39ebab
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
5 changes: 1 addition & 4 deletions packages/types/lib/scanner.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,9 @@ export interface Invasion {
slot_3_form: number
}

export interface ShowcaseEntry {
export interface ShowcaseEntry extends PokemonDisplay {
rank: number
pokemon_id: number
form: number
costume: number
gender: Gender
score: number
}

Expand Down
12 changes: 1 addition & 11 deletions src/features/gym/GymPopup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -652,17 +652,7 @@ const ExtraGymInfo = ({
{!!guarding_pokemon_id && updated > gymValidDataLimit && (
<ExtraInfo title="defender">
<TextWithIcon
src={Icons.getPokemon(
guarding_pokemon_id,
gpd.form,
Date.now() > gpd.temp_evolution_finish_ms
? 0
: gpd.temp_evolution,
gpd.gender,
gpd.costume,
gpd.alignment,
gpd.shiny,
)}
src={Icons.getPokemonByDisplay(guarding_pokemon_id, gpd)}
>
{gpd.badge === 1 && (
<>
Expand Down
15 changes: 13 additions & 2 deletions src/features/pokestop/PokestopPopup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { NameTT } from '@components/popups/NameTT'
import { TimeStamp } from '@components/popups/TimeStamps'
import { useAnalytics } from '@hooks/useAnalytics'
import { parseQuestConditions } from '@utils/parseConditions'
import { Img } from '@components/Img'

/**
*
Expand Down Expand Up @@ -846,8 +847,10 @@ const NoBorderCell = styled(TableCell, {
textAlign,
}))

const ShowcaseEntry = ({ rank, score, pokemon_id, form, costume, gender }) => {
const ShowcaseEntry = (entry) => {
const { rank, score, pokemon_id, badge } = entry
const Icons = useMemory((s) => s.Icons)
const { t } = useTranslation()
return (
<TableRow>
<NoBorderCell>
Expand All @@ -862,10 +865,18 @@ const ShowcaseEntry = ({ rank, score, pokemon_id, form, costume, gender }) => {
{pokemon_id && (
<NoBorderCell>
<img
src={Icons.getPokemon(pokemon_id, form, 0, gender, costume)}
src={Icons.getPokemonByDisplay(pokemon_id, entry)}
alt="rank"
height={20}
/>
{badge === 1 && (
<Img
src={Icons.getMisc('bestbuddy')}
alt={t('best_buddy')}
maxHeight={15}
maxWidth={15}
/>
)}
</NoBorderCell>
)}
</TableRow>
Expand Down
18 changes: 18 additions & 0 deletions src/services/Assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,24 @@ export class UAssets {
}
}

/**
* @param {string|number} pokemonId
* @param {PokemonDisplay} pokemonDisplay
*/
getPokemonByDisplay(pokemonId, pokemonDisplay) {
return this.getPokemon(
pokemonId,
pokemonDisplay.form,
Date.now() > pokemonDisplay.temp_evolution_finish_ms
? 0
: pokemonDisplay.temp_evolution,
pokemonDisplay.gender,
pokemonDisplay.costume,
pokemonDisplay.alignment,
pokemonDisplay.shiny,
)
}

/** @param {number | string} [typeId] */
getTypes(typeId = 0) {
try {
Expand Down

0 comments on commit d39ebab

Please sign in to comment.