diff --git a/src/routes/wish/tally/index.svelte b/src/routes/wish/tally/index.svelte index e71fd785..f2435ad4 100644 --- a/src/routes/wish/tally/index.svelte +++ b/src/routes/wish/tally/index.svelte @@ -35,6 +35,12 @@ standard: 200000, }; + const spliceCount = { + characters: 8, + weapons: 7, + standard: 0, + }; + let selectedType = types[0]; let type = selectedType.value; let banner = banners.characters[banners.characters.length - 1]; @@ -66,6 +72,8 @@ let chart; let chart2; + let error; + function onChangeType() { type = selectedType.value; banner = banners[type][banners[type].length - 1]; @@ -139,16 +147,25 @@ rareList = rareList; if (type !== 'standard') { + let totalCount = 0; + let totalGuaranteed = 0; for (let i = 0; i < featured.items.length; i++) { const feat = featured.items[i]; const item = data.list.find((e) => e.name === feat); - console.log(feat, item); + + totalCount += item.count; + totalGuaranteed += item.guaranteed; + featuredValues[i] = { total: item.count, - guaranteed: ((item.count - item.guaranteed) / (data.total.legendary - item.guaranteed)) * 100, percentage: (item.count / data.total.legendary) * 100, }; } + + for (let i = 0; i < featured.items.length; i++) { + featuredValues[i].guaranteed = + ((totalCount - totalGuaranteed) / (data.total.legendary - totalGuaranteed)) * 100; + } } else { featuredValues = [ { @@ -289,6 +306,7 @@ }); } catch (err) { console.error(err); + error = err; } } @@ -307,6 +325,7 @@ return { label: `${name} & ${bannersDual[name][1].name} ${bannersDual[name][1].image}`, value: i, image }; else return { label: name, value: i, image }; }) + .slice(spliceCount[type]) .reverse(); @@ -339,6 +358,8 @@
{#if loading} + {:else if !loading && error !== undefined} +

Data is not available

{:else}