Skip to content

Instantly share code, notes, and snippets.

@treuks
Last active February 21, 2023 14:47
Show Gist options
  • Save treuks/b0c3a6f7da0b1929cb383f987c111b7b to your computer and use it in GitHub Desktop.
Save treuks/b0c3a6f7da0b1929cb383f987c111b7b to your computer and use it in GitHub Desktop.
//const bait_list = ["πŸͺ±", "πŸͺ°", "πŸ¦—"];
//
// Fish game:
//
// You can execute the alias to catch a fish.
// Given your current unluck percentage, which will increase over time
// you get a higher chance to catch a fish
//
//
// This will put a unique twist on the original alias,
// Instead of the luck percentage always being the same,
// The harder you are unlucky, the more lucky you will become in the future
// Which will in a way get you to be "addicted" to the gameplay,
// and you will feel rewarded.
//
// Rare : 100
// Normal: 50
// Trash : 10
//
class Fish {
constructor(emoji, rarity, lengthmodifier, description) {
this.emoji = emoji;
this.rarity = rarity;
this.lengthmodifier = lengthmodifier;
this.description = description;
}
}
const socks = new Fish("🧦", "Trash", 0.5, "Okay I'll take them just leave me alone please!!");
const skull = new Fish("πŸ’€", "Trash", 0.7, "Uhhhh.. where the fuck did you..?");
const scorpion = new Fish("πŸ¦‚", "Trash", 0.8, "Well.. this is not a fish.. ");
const shell = new Fish("🐚", "Trash", 0.45, "Ooo, well this is not a fish, but it's a nice shell.");
const frog = new Fish("🐸", "Normal", 0.45, "Surprised you managed to catch this one");
const turtle = new Fish("🐒", "Normal", 0.5, "A sea turtle.. might be handy, for sure");
const bass = new Fish("🐟", "Normal", 1, "Oh, bass! My friend Billy really likes these.");
const clownfish = new Fish("🐠", "Normal", 0.8, "Wonder if it makes good jokes.. okay, sorry.");
const octopus = new Fish("πŸ™", "Rare", 1.5, "Good catch.. indeed.. surprised you managed to see this one");
const squid = new Fish("πŸ¦‘", "Rare", 1.2, "A squid.. wHOA WHOA! BE CAREFUL, I JUST CLEANED THE FLOORS");
const crab = new Fish("πŸ¦€", "Rare", 1, "Look at how rusty your rod is.. You probably had to spend a lot of time to catch this");
const blowfish = new Fish("🐑", "Rare", 1, "Being this fish blows.. probably..");
const shark = new Fish("🦈", "Rare", 3, "Woah woah, don't force it in the door, be careful.");
const lobster = new Fish("🦞", "Rare", 0.8, "Have you ever seen a blue lobster? Wonder if it's a myth..");
const shrimp = new Fish("🦐", "Rare", 0.3, "Catching this one wasn't shrimple, probably..");
const whale = new Fish("🐳", "Rare", 5, "It's kinda cool how these adapted to our current climate.");
const snake = new Fish("🐍", "Rare", 0.6, "A sea snake.. a nice catch, indeed.");
const crocodile = new Fish("🐊", "Rare", 2.5, "Holy.. did you seriously bring this crocodile all the way here?");
const fishList = [
socks, skull, scorpion, shell, frog, turtle, bass, clownfish, octopus,
squid, crab, blowfish, shark, lobster, shrimp, whale, snake, crocodile
];
class CaughtFish {
constructor(caught, type) {
this.caught = caught;
this.type = type;
}
}
class CaughtFormattedFish {
constructor(success, name, length) {
this.success = success;
this.name = name;
this.length = length;
}
}
const catchFish = (modifier) => {
let add_percentage = 0;
let consecutiveNoCatch = customData.get(`TKS_FISH_IN_A_ROW`);
//let consecutiveNoCatch = 0;
if (consecutiveNoCatch >= 50) {
add_percentage += 25;
} else if (consecutiveNoCatch >= 30) {
add_percentage += 10;
}
if (!isNaN(modifier)) {
add_percentage += modifier;
}
const percentage = ~~(Math.random() * 500) - add_percentage;
if (percentage > 30) {
customData.set(`TKS_FISH_IN_A_ROW`, customData.get(`TKS_FISH_IN_A_ROW`) + 1)
return new CaughtFish(false, null)
}
if (percentage <= 10) {
customData.set(`TKS_FISH_IN_A_ROW`, 0);
return new CaughtFish(true, "Rare")
}
if (percentage <= 20) {
customData.set(`TKS_FISH_IN_A_ROW`, 0);
return new CaughtFish(true, "Normal")
}
if (percentage <= 30) {
customData.set(`TKS_FISH_IN_A_ROW`, 0);
return new CaughtFish(true, "Trash")
}
}
const selectRandom = (array) => {
const randomIndex = Math.floor(Math.random() * array.length);
return array[randomIndex];
}
// /* Randomize array in-place using Durstenfeld shuffle algorithm */
// const shuffleArray = (array) => {
// return array.map(value => ({ value, sort: Math.random() })).sort((a, b) => a.sort - b.sort).map(({ value }) => value)
// }
const shuffleArray = (array) => {
return utils.shuffleArray(array);
}
const getSadEmote = async () => {
const sad_emotes = [
`PoroSad`,
`peepoSad`,
`Sadeg`,
`Sadge`,
`SadgeCry`,
`SadCat`,
`FeelsBadMan`,
`RAGEY`,
`docnotL`,
`ReallyMad`,
`PunOko`,
`SirMad`,
`SirSad`,
`KannaCry`,
`RemCry`,
`catCry`,
`PepeHands`,
`Madge`,
`reeferSad`,
`sadE`,
`NotLikeThis`,
`NLT`,
`FailFish`,
`SAJ`,
`SAJI`
]
return await utils.getEmote(shuffleArray(sad_emotes));
}
const getHappyEmote = async () => {
const happy_emotes = [
`SUGOI`,
`LETSGO`,
`PagMan`,
`PAGLADA`,
`PAGGING`,
`PagBounce`,
`PagChomp`,
`PogU`,
`Pog`,
`PogChamp`,
`WakuWaku`,
`sheCrazy`,
`heCrazy`,
`WICKED`,
`FeelsStrongMan`,
`MUGA`,
`Wowee`,
`PogBones`,
`peepoPog`,
`peepoPag`,
`Shockisu`
];
return await utils.getEmote(shuffleArray(happy_emotes));
}
const getFishFromQuality = (rarity, selectItemFromArray) => {
return selectItemFromArray(fishList.filter(fish => fish.rarity === rarity));
}
const formatCatch = async (fish, selectRandom) => {
let { caught, type } = fish(0);
if (caught === true) {
let { emoji, lengthmodifier } = getFishFromQuality(type, selectRandom);
return new CaughtFormattedFish(true, emoji, (Math.floor(~~(Math.random() * 50) * lengthmodifier)));
} else {
return new CaughtFormattedFish(false, null, null);
}
}
const formatResponse = async (fish, getHappyEmote, getSadEmote) => {
let { success, name, length } = await formatCatch(fish, selectRandom);
if (success === false) {
// I'm returning the distance with a +1 so it can't be 0
// A little bit kkona but it works, alright?
return `No luck... The fish is ${~~(Math.random() * 75) + 1}cm away. ${await getSadEmote()}`;
} else {
return `${await getHappyEmote()} ! You caught ${name}, and it is ${length}cm long!!`;
}
}
const main = async () => {
return await formatResponse(catchFish, getHappyEmote, getSadEmote);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment