Skip to content

Commit

Permalink
IV: Add an info button to the right of the RP value
Browse files Browse the repository at this point in the history
  • Loading branch information
nitoyon committed Jan 26, 2025
1 parent 26a0533 commit 1fc4412
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@
"strength2": "Strength",
"rating": "Rating",

"helps per 5 hours": "Helps per 5 hours",
"strength, ingredients, skill count": "Strength, ingredients and skill count",
"the amount under the following condition": "We are showing the amount under the following conditions.",
"use strength tab if you want to change these condition": "If you want to change these conditions, please use the [$t(strength2)] tab.", "helps per 5 hours": "Helps per 5 hours",
"berry rate": "Berry rate",
"berry strength": "Berry strength (determined by the type of berry and the Pokémon level)",
"berry count": "The amount of Berries per help",
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@
"strength2": "エナジー",
"rating": "個体評価",

"strength, ingredients, skill count": "エナジー、食材数、スキル回数",
"the amount under the following condition": "次の条件のときの量を表示しています。",
"use strength tab if you want to change these condition": "これらの条件を変えたい場合は、[$t(strength2)] タブを利用してください。",
"helps per 5 hours": "5時間のおてつだい回数",
"berry rate": "きのみ確率",
"berry strength": "きのみエナジー (きのみの種類とポケモンのレベルで決まる値)",
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@
"strength2": "에너지",
"rating": "개체값 평가",

"strength, ingredients, skill count": "에너지, 재료 수, 스킬 횟수",
"the amount under the following condition": "다음 조건에서의 양을 표시하고 있습니다.",
"use strength tab if you want to change these condition": "이 조건을 변경하려면 [$t(strength2)] 탭을 사용하세요.",
"helps per 5 hours": "5시간 동안의 도우미 횟수",
"berry rate": "열매 확률",
"berry strength": "열매 에너지 (열매 종류와 포켓몬의 레벨로 결정되는 값)",
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@
"strength2": "能量",
"rating": "个体评价",

"strength, ingredients, skill count": "能量、食材数、技能次数",
"the amount under the following condition": "显示在以下条件下的数量。",
"use strength tab if you want to change these condition": "如果您想更改这些条件,请使用[$t(strength2)] 标签。",
"helps per 5 hours": "5小时的帮助次数",
"berry rate": "树果几率",
"berry strength": "树果能量 (由树果种类和宝可梦的等级决定)",
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@
"strength2": "能量",
"rating": "個体評價",

"strength, ingredients, skill count": "能量、食材數、技能次數",
"the amount under the following condition": "顯示在以下條件下的數量。",
"use strength tab if you want to change these condition": "如果您想更改這些條件,請使用[$t(strength2)] 標籤。",
"helps per 5 hours": "5小時的幫助次數",
"berry rate": "樹果機率",
"berry strength": "樹果能量 (由樹果類型和寶可夢等級決定)",
Expand Down
2 changes: 1 addition & 1 deletion src/ui/IvCalc/RpLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const RpLabel = React.memo(({rp, iv, showIcon, onClick}: {
rp: number,
iv: PokemonIv,
showIcon?: boolean,
onClick?: () => {},
onClick?: () => void,
}) => {
const { t } = useTranslation();
const isEstimated = iv.level > rpEstimateThreshold;
Expand Down
72 changes: 71 additions & 1 deletion src/ui/IvCalc/RpView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ import { Trans, useTranslation } from 'react-i18next';

const RpView = React.memo(({pokemonIv, width}: {pokemonIv: PokemonIv, width: number}) => {
const { t } = useTranslation();
const [rpInfoOpen, setRpInfoOpen] = React.useState(false);
const [rpValueOpen, setRpValueOpen] = React.useState(false);
const [rpType, setRpType] = React.useState<"berry"|"ingredient"|"skill">("berry");

const onRpInfoClick = React.useCallback(() => {
setRpInfoOpen(true);
}, []);
const onRpInfoClose = React.useCallback(() => {
setRpInfoOpen(false);
}, []);
const onBerryInfoClick = React.useCallback(() => {
setRpValueOpen(true);
setRpType("berry");
Expand Down Expand Up @@ -46,7 +53,7 @@ const RpView = React.memo(({pokemonIv, width}: {pokemonIv: PokemonIv, width: num

return (<>
<div>
<RpLabel rp={rpResult.rp} iv={pokemonIv} showIcon/>
<RpLabel rp={rpResult.rp} iv={pokemonIv} showIcon onClick={onRpInfoClick}/>
<BerryIngSkillView
berryValue={round1(rpResult.berryRp)}
berryProb={round1(rp.berryRatio * 100)}
Expand All @@ -65,6 +72,7 @@ const RpView = React.memo(({pokemonIv, width}: {pokemonIv: PokemonIv, width: num
skillProb={round1(rp.skillRatio * 100)}
skillSubValue={strength.skillCount.toFixed(2) + t('times unit')}
onSkillInfoClick={onSkillInfoClick}/>
<RpInfoDialog open={rpInfoOpen} onClose={onRpInfoClose}/>
<RpValueDialog open={rpValueOpen} onClose={onRpValueClose}
rp={rp} rpResult={rpResult} rpType={rpType}/>
</div>
Expand All @@ -75,6 +83,68 @@ const RpView = React.memo(({pokemonIv, width}: {pokemonIv: PokemonIv, width: num
</>);
});

const RpInfoDialog = React.memo(({open, onClose}: {
open: boolean,
onClose: () => void,
}) => {
const { t } = useTranslation();
return <StyledRpInfoDialog open={open} onClose={onClose}>
<article>
<h2>{t('rp')}</h2>
<p><Trans i18nKey="rp formula" components={{
link: <a href={t('rp formula doc url')}>{t('rp formula doc title')}</a>
}}/></p>
<p>{t('estimated beyond level', {level: rpEstimateThreshold})}</p>

<h2>{t('strength, ingredients, skill count')}</h2>
<p>{t('the amount under the following condition')}</p>
<ul>
<li>{t('period')}: {t('1day')}</li>
<li>{t('favorite berry')}: {t('none')}</li>
<li>{t('good camp ticket')}: {t('none')}</li>
<li>{t('area bonus')}: 0%</li>
<li>{t('helping bonus')}: {t('none')}</li>
<li>{t('skills.Energy for Everyone S')}: 18 × 3</li>
<li>{t('sleep score')}: 100</li>
<li>{t('tap frequency')} ({t('awake')}): {t('every minute')}</li>
<li>{t('tap frequency')} ({t('asleep')}): {t('none')}</li>
</ul>
<p>{t('use strength tab if you want to change these condition')}</p>
<p>{t('estimated beyond level', {level: rpEstimateThreshold})}</p>
</article>
<DialogActions>
<Button onClick={onClose}>{t('close')}</Button>
</DialogActions>
</StyledRpInfoDialog>;
});

const StyledRpInfoDialog = styled(Dialog)({
'& article': {
margin: '1rem 1rem 0 1rem',
'& > h2': {
fontSize: '1rem',
margin: '0.8rem 0 0 0',
lineHeight: 1.2,
'&:first-of-type': {
margin: 0,
}
},
'& > p': {
fontSize: '0.8rem',
margin: '0.3rem 0',
},
'& > ul': {
margin: '0.5rem 0',
padding: '0 0 0 1.5rem',
'& > li': {
margin: '0.2rem 0',
fontSize: '0.8rem',
},
},
}
});


const StyledRpDialog = styled(Dialog)({
'& header': {
margin: '1rem',
Expand Down

0 comments on commit 1fc4412

Please sign in to comment.