From 1a17c8a3d7e1e3033caea496d833590518906f18 Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 10 Apr 2022 15:42:52 -0500 Subject: Show farming stuff in the infobox sometimes --- src/lib/profile.ts | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src') 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 = {} + 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 -- cgit