Skip to content

Commit 9951d28

Browse files
committed
feat: add candy to general page
1 parent 91969c9 commit 9951d28

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

components/account/Misc/Currencies.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import CoinDisplay from 'components/common/CoinDisplay';
22
import { Stack, Typography } from '@mui/material';
33
import { IconWithText, TitleAndValue } from '@components/common/styles';
44
import HtmlTooltip from '../../Tooltip';
5+
import { numberWithCommas, prefix } from '@utility/helpers';
6+
import Tooltip from '@components/Tooltip';
7+
import React from 'react';
58

69
const imgStyle = { style: { width: 32, height: 32, objectFit: 'contain' } };
710
const Currencies = ({
@@ -12,8 +15,11 @@ const Currencies = ({
1215
SilverPens,
1316
gems,
1417
KeysAll,
15-
minigamePlays
18+
minigamePlays,
19+
candies
1620
}) => {
21+
const minDays = (candies?.special?.min / 24).toFixed(2).replace('.00', '');
22+
const maxDays = (candies?.special?.max / 24).toFixed(2).replace('.00', '');
1723
return <Stack>
1824
<CoinDisplay className={'box'} money={money}/>
1925
<Typography mt={2} mb={1} textAlign={'center'}>Currencies</Typography>
@@ -57,6 +63,16 @@ const Currencies = ({
5763
<IconWithText stat={amount} icon={rawName} img={imgStyle}/>
5864
</HtmlTooltip>
5965
})}
66+
<Tooltip maxWidth={350} title={<Stack>
67+
<Typography variant={'body1'} component={'span'}>Candies</Typography>
68+
<Typography variant={'body2'}>Guaranteed: {numberWithCommas(candies?.guaranteed)} hrs ({(candies?.guaranteed / 24).toFixed(2)} days)</Typography>
69+
<Typography variant={'body2'}>Variant: {numberWithCommas(candies?.special?.min)} - {numberWithCommas(candies?.special?.max)} hrs ({numberWithCommas(minDays)} - {numberWithCommas(maxDays)} days)</Typography>
70+
</Stack>}>
71+
<Stack alignItems={'center'}>
72+
<img width={32} height={32} src={`${prefix}data/TimeCandy1.png`} alt=""/>
73+
<Typography variant={'body1'} component={'span'}>{numberWithCommas(candies?.guaranteed)}</Typography>
74+
</Stack>
75+
</Tooltip>
6076
</Stack>
6177
</Stack>
6278
};

parsers/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
import { getSaltLick } from './saltLick';
4242
import { getDungeons } from './dungeons';
4343
import { applyMealsMulti, getCooking, getKitchens } from './cooking';
44-
import { applyBonusDesc, getJewelBonus, getLab, getLabBonus, isLabEnabledBySorcererRaw } from './lab';
44+
import { getJewelBonus, getLab, getLabBonus, isLabEnabledBySorcererRaw } from './lab';
4545
import { classes } from '../data/website-data';
4646
import { getGuild } from './guild';
4747
import { getPrinter } from './printer';
@@ -124,7 +124,7 @@ const serializeData = (idleonData, charNames, companion, guildData, serverVars,
124124
accountData.prayers = getPrayers(idleonData, accountData.storage);
125125
accountData.cards = getCards(idleonData, accountData);
126126
accountData.guild = getGuild(idleonData, guildData);
127-
accountData.currencies = getCurrencies(accountData, idleonData);
127+
accountData.currencies = getCurrencies(accountData, idleonData, processedData);
128128
accountData.stamps = getStamps(idleonData, accountData);
129129
accountData.obols = getObols(idleonData);
130130
accountData.looty = getLooty(idleonData);

parsers/misc.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,48 @@ export const getLooty = (idleonData) => {
149149
};
150150
};
151151

152-
export const getCurrencies = (account, idleonData) => {
152+
export const getCurrencies = (account, idleonData, processedData) => {
153153
const keys = idleonData?.CurrenciesOwned?.['KeysAll'] || idleonData?.CYKeysAll;
154154
if (idleonData?.CurrenciesOwned) {
155155
return {
156156
...idleonData?.CurrenciesOwned,
157157
KeysAll: getKeysObject(keys)
158158
};
159159
}
160+
const normalCandyTimes = {
161+
'1_HR_Time_Candy': 1,
162+
'2_HR_Time_Candy': 2,
163+
'4_HR_Time_Candy': 4,
164+
'12_HR_Time_Candy': 12,
165+
'24_HR_Time_Candy': 24,
166+
'72_HR_Time_Candy': 72
167+
};
168+
169+
const specialCandy = {
170+
'Steamy_Time_Candy': { min: 1 / 6, max: 24 },
171+
'Spooky_Time_Candy': { min: 1 / 3, max: 12 },
172+
'Cosmic_Time_Candy': { min: 5, max: 500 }
173+
};
174+
const allItems = [...account?.storage,
175+
...(processedData?.charactersData || [])?.map(({ inventory }) => inventory)?.flat()];
176+
const allCandies = allItems?.filter(({ Type } = {}) => Type === 'TIME_CANDY');
177+
const guaranteedCandies = allCandies?.reduce((sum, { displayName, amount }) => {
178+
if (specialCandy[displayName]) return sum;
179+
const hours = normalCandyTimes[displayName];
180+
return sum + (hours * amount);
181+
}, 0);
182+
const specialCandies = allCandies?.reduce((sum, { displayName, amount }) => {
183+
const hours = specialCandy[displayName];
184+
if (!hours) return sum;
185+
186+
return {
187+
min: sum?.min + (hours?.min * amount),
188+
max: sum?.max + (hours?.max * amount)
189+
}
190+
}, { min: 0, max: 0 })
160191

161192
return {
193+
candies: { guaranteed: guaranteedCandies, special: specialCandies },
162194
WorldTeleports: idleonData?.CYWorldTeleports,
163195
KeysAll: getKeysObject(keys),
164196
ColosseumTickets: idleonData?.CYColosseumTickets,

0 commit comments

Comments
 (0)