Skip to content

Commit 33c51ad

Browse files
authored
Merge pull request #1094 from WatWowMap/shinyprob
feat: quest_shiny_probability
2 parents 2b7fef9 + 15b9c15 commit 33c51ad

File tree

6 files changed

+42
-16
lines changed

6 files changed

+42
-16
lines changed

packages/locales/lib/human/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@
376376
"with_ar": "With AR",
377377
"both": "Both",
378378
"without_ar": "Without AR",
379+
"shiny_probability": "Shiny: {{p}}",
379380
"exclude_quest_multi": "Exclude {{reward}}",
380381
"cluster_limit_0": "{{variable_0}} limit ({{variable_1}}) has been hit",
381382
"cluster_limit_1": "Please zoom in or narrow your filters",

packages/types/lib/scanner.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export interface Quest {
121121
quest_gender_id: Gender
122122
quest_costume_id: number
123123
quest_shiny: number
124+
quest_shiny_probability?: number
124125
mega_pokemon_id: number
125126
mega_amount: number
126127
candy_pokemon_id: number

server/src/graphql/typeDefs/scanner.graphql

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type Quest {
8383
quest_gender_id: Int
8484
quest_costume_id: Int
8585
quest_shiny: Int
86+
quest_shiny_probability: Float
8687
mega_pokemon_id: Int
8788
mega_amount: Int
8889
candy_pokemon_id: Int

server/src/models/Pokestop.js

+1
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ class Pokestop extends Model {
875875
'quest_costume_id',
876876
'quest_gender_id',
877877
'quest_shiny',
878+
'quest_shiny_probability',
878879
)
879880
break
880881
case 9:

src/features/pokestop/PokestopPopup.jsx

+37-16
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,28 @@ export function PokestopPopup({
120120
<Divider light flexItem className="popup-divider" />
121121
) : null}
122122
<RewardInfo {...quest} />
123-
<QuestConditions {...quest} />
123+
<Grid
124+
xs={9}
125+
style={{
126+
textAlign: 'center',
127+
maxHeight: 150,
128+
overflow: 'auto',
129+
}}
130+
>
131+
<QuestConditions {...quest} />
132+
{quest.quest_shiny_probability && (
133+
<>
134+
<br />
135+
<Typography variant="caption">
136+
{t('shiny_probability', {
137+
p: readableProbability(
138+
quest.quest_shiny_probability,
139+
),
140+
})}
141+
</Typography>
142+
</>
143+
)}
144+
</Grid>
124145
</React.Fragment>
125146
))}
126147
{hasLure && (
@@ -512,6 +533,15 @@ const RewardInfo = ({ with_ar, ...quest }) => {
512533
)
513534
}
514535

536+
const readableProbability = (x) => {
537+
if (x <= 0) return '🚫'
538+
const x_1 = Math.round(1 / x)
539+
const percent = Math.round(x * 100)
540+
return Math.abs(1 / x_1 - x) < Math.abs(percent * 0.01 - x)
541+
? `1/${x_1}`
542+
: `${percent}%`
543+
}
544+
515545
/**
516546
*
517547
* @param {Omit<import('@rm/types').Quest, 'key'>} props
@@ -528,22 +558,16 @@ const QuestConditions = ({
528558
const madQuestText = useStorage((s) => s.userSettings.pokestops.madQuestText)
529559

530560
if (madQuestText && quest_task) {
531-
return (
532-
<Grid xs={9} textAlign="center">
533-
<Typography variant="caption">{quest_task}</Typography>
534-
</Grid>
535-
)
561+
return <Typography variant="caption">{quest_task}</Typography>
536562
}
537563

538564
if (quest_title && !quest_title.includes('geotarget')) {
539565
const normalized = `quest_title_${quest_title.toLowerCase()}`
540566
if (i18n.exists(normalized)) {
541567
return (
542-
<Grid xs={9} textAlign="center">
543-
<Typography variant="caption">
544-
<Trans i18nKey={normalized}>{{ amount_0: quest_target }}</Trans>
545-
</Typography>
546-
</Grid>
568+
<Typography variant="caption">
569+
<Trans i18nKey={normalized}>{{ amount_0: quest_target }}</Trans>
570+
</Typography>
547571
)
548572
}
549573
}
@@ -615,10 +639,7 @@ const QuestConditions = ({
615639
}
616640
}
617641
return (
618-
<Grid
619-
xs={9}
620-
style={{ textAlign: 'center', maxHeight: 150, overflow: 'auto' }}
621-
>
642+
<>
622643
{primaryCondition}
623644
{type1 && (
624645
<>
@@ -636,7 +657,7 @@ const QuestConditions = ({
636657
</Typography>
637658
</>
638659
)}
639-
</Grid>
660+
</>
640661
)
641662
}
642663

src/services/queries/pokestop.js

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const quest = gql`
4343
quest_gender_id
4444
quest_costume_id
4545
quest_shiny
46+
quest_shiny_probability
4647
mega_pokemon_id
4748
mega_amount
4849
candy_pokemon_id

0 commit comments

Comments
 (0)