diff options
author | mat <github@matdoes.dev> | 2022-04-10 15:42:52 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-04-10 15:42:52 -0500 |
commit | 1a17c8a3d7e1e3033caea496d833590518906f18 (patch) | |
tree | 21b33b1b29b37ad092ff94b66b2d28445fb96573 /src | |
parent | 586c1b742b824444f1f067b9da2acd3c3ff2a895 (diff) | |
download | skyblock-stats-1a17c8a3d7e1e3033caea496d833590518906f18.tar.gz skyblock-stats-1a17c8a3d7e1e3033caea496d833590518906f18.tar.bz2 skyblock-stats-1a17c8a3d7e1e3033caea496d833590518906f18.zip |
Show farming stuff in the infobox sometimes
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/profile.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/lib/profile.ts b/src/lib/profile.ts index 106e261..e5716b5 100644 --- a/src/lib/profile.ts +++ b/src/lib/profile.ts @@ -39,6 +39,47 @@ export function generateInfobox(data: CleanMemberProfile): string[] { if (data.profile.minionCount >= data.profile.maxUniqueMinions) result.push(`🤖 Minion count: ${data.profile.minionCount}`) + const farmingContestsWonByCrop: Record<string, number> = {} + const farmingContestsWon = data.member.farmingContests.list.reduce( + (previous, current) => { + return previous + current.crops.reduce((previousCropSum, currentCrop) => { + const wonContest = currentCrop.position === 1 + if (wonContest) { + farmingContestsWonByCrop[currentCrop.item] = (farmingContestsWonByCrop[currentCrop.item] ?? 0) + 1 + return previousCropSum + 1 + } + return previousCropSum + }, 0) + }, 0 + ) + + if (farmingContestsWon >= 50) { + let mostContestsWonCrop = '' + let mostContestsWonCropCount = 0 + for (const [crop, count] of Object.entries(farmingContestsWonByCrop)) { + if (count > mostContestsWonCropCount) { + mostContestsWonCrop = crop + mostContestsWonCropCount = count + } + } + + const cropEmoji = { + cactus: '🌵', + carrot: '🥕', + cocoa_beans: '🍫', + melon_slice: '🍉', + // i couldn't find a better emoji lmao + nether_wart: '🌶', + potato: '🥔', + pumpkin: '🎃', + red_mushroom: '🍄', + sugar_cane: '🎋', + wheat: '🌾', + }[mostContestsWonCrop] ?? '🌾' + + result.push(`${cropEmoji} Farming contests won: ${farmingContestsWon}`) + } + if (data.member.stats) { let mostSignificantKillsStat: StatItem | null = null let mostSignificantDeathsStat: StatItem | null = null |