Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: quest_shiny_probability #1094

Merged
merged 3 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/locales/lib/human/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@
"with_ar": "With AR",
"both": "Both",
"without_ar": "Without AR",
"shiny_probability": "Shiny: {{p}}",
"exclude_quest_multi": "Exclude {{reward}}",
"cluster_limit_0": "{{variable_0}} limit ({{variable_1}}) has been hit",
"cluster_limit_1": "Please zoom in or narrow your filters",
Expand Down
1 change: 1 addition & 0 deletions packages/types/lib/scanner.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export interface Quest {
quest_gender_id: Gender
quest_costume_id: number
quest_shiny: number
quest_shiny_probability?: number
mega_pokemon_id: number
mega_amount: number
candy_pokemon_id: 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 @@ -83,6 +83,7 @@ type Quest {
quest_gender_id: Int
quest_costume_id: Int
quest_shiny: Int
quest_shiny_probability: Float
mega_pokemon_id: Int
mega_amount: Int
candy_pokemon_id: Int
Expand Down
1 change: 1 addition & 0 deletions server/src/models/Pokestop.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ class Pokestop extends Model {
'quest_costume_id',
'quest_gender_id',
'quest_shiny',
'quest_shiny_probability',
)
break
case 9:
Expand Down
53 changes: 37 additions & 16 deletions src/features/pokestop/PokestopPopup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,28 @@ export function PokestopPopup({
<Divider light flexItem className="popup-divider" />
) : null}
<RewardInfo {...quest} />
<QuestConditions {...quest} />
<Grid
xs={9}
style={{
textAlign: 'center',
maxHeight: 150,
overflow: 'auto',
}}
>
<QuestConditions {...quest} />
{quest.quest_shiny_probability && (
<>
<br />
<Typography variant="caption">
{t('shiny_probability', {
p: readableProbability(
quest.quest_shiny_probability,
),
})}
</Typography>
</>
)}
</Grid>
</React.Fragment>
))}
{hasLure && (
Expand Down Expand Up @@ -512,6 +533,15 @@ const RewardInfo = ({ with_ar, ...quest }) => {
)
}

const readableProbability = (x) => {
if (x <= 0) return '🚫'
const x_1 = Math.round(1 / x)
const percent = Math.round(x * 100)
return Math.abs(1 / x_1 - x) < Math.abs(percent * 0.01 - x)
? `1/${x_1}`
: `${percent}%`
}

/**
*
* @param {Omit<import('@rm/types').Quest, 'key'>} props
Expand All @@ -528,22 +558,16 @@ const QuestConditions = ({
const madQuestText = useStorage((s) => s.userSettings.pokestops.madQuestText)

if (madQuestText && quest_task) {
return (
<Grid xs={9} textAlign="center">
<Typography variant="caption">{quest_task}</Typography>
</Grid>
)
return <Typography variant="caption">{quest_task}</Typography>
}

if (quest_title && !quest_title.includes('geotarget')) {
const normalized = `quest_title_${quest_title.toLowerCase()}`
if (i18n.exists(normalized)) {
return (
<Grid xs={9} textAlign="center">
<Typography variant="caption">
<Trans i18nKey={normalized}>{{ amount_0: quest_target }}</Trans>
</Typography>
</Grid>
<Typography variant="caption">
<Trans i18nKey={normalized}>{{ amount_0: quest_target }}</Trans>
</Typography>
)
}
}
Expand Down Expand Up @@ -615,10 +639,7 @@ const QuestConditions = ({
}
}
return (
<Grid
xs={9}
style={{ textAlign: 'center', maxHeight: 150, overflow: 'auto' }}
>
<>
{primaryCondition}
{type1 && (
<>
Expand All @@ -636,7 +657,7 @@ const QuestConditions = ({
</Typography>
</>
)}
</Grid>
</>
)
}

Expand Down
1 change: 1 addition & 0 deletions src/services/queries/pokestop.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const quest = gql`
quest_gender_id
quest_costume_id
quest_shiny
quest_shiny_probability
mega_pokemon_id
mega_amount
candy_pokemon_id
Expand Down