Last active
January 27, 2024 03:37
-
-
Save brian6932/75e03c4d8a518b4a825464d9d0b0b465 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fishCount = ~~customData.get(`fish_count`) | |
let caught = customData.get(`fish`) ?? [] | |
if (!Array.isArray(caught)) | |
switch (typeof caught) { | |
case `string`: | |
const | |
fishes = Uint16Array.of(1, 15, 21, 22, 23, 34, 41, 1406, 1443), | |
emojis = [] | |
for (let emoji of caught.trim()) | |
if (fishes.includes((emoji = emoji.codePointAt(0)) - 128010)) | |
emojis.push(emoji) | |
caught = emojis | |
break | |
case `object`: | |
try { | |
caught = new Uint32Array(caught) | |
.filter(emoji => fishes.includes(emoji - 128010)) | |
} | |
catch { | |
caught = [] | |
} | |
break | |
default: | |
caught = [].concat(caught) | |
} | |
let stats = `` | |
new function () { | |
this[`types caught`] = caught.reduce((emojis, emoji, idx) => { | |
if (emoji && caught.indexOf(emoji) === idx) | |
emojis += String.fromCodePoint(emoji) | |
return emojis | |
}, ``) | |
if (fishCount) { | |
this[`longest recorded fish`] = (+customData.get(`fish_len`) % 1443 || undefined)?.toString().concat(`cm`) | |
const | |
unlucky = +customData.get(`fish_unlucky`) || undefined, | |
unluckyRecord = +customData.get(`fish_unlucky_record`) || undefined | |
this[`attempts since last catch`] = unlucky?.toString().concat(`x`) | |
if (unlucky !== unluckyRecord) | |
this[`longest unlucky streak`] = unluckyRecord?.toString().concat(`x`) | |
} | |
this[`total fish invocations`] = (+customData.get(`fish_total`) || undefined)?.toString().concat(`x`) | |
for (const key in this) | |
if (this[key]) | |
stats += ` \u{2022} ${key}: ${this[key]}` | |
}; | |
`You've caught a total of ${fishCount} fish${fishCount === 1 ? `` : `es`}` + stats |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment