Merge separate instances

This commit is contained in:
Hri7566 2024-02-27 10:43:26 -05:00
parent cb39e0e18e
commit 76fc8c01a7
7 changed files with 270 additions and 18 deletions

View File

@ -19,7 +19,13 @@ export const fish = new Command(
1000 / 1000 /
60 60
).toFixed(2)} minutes ago).${ ).toFixed(2)} minutes ago).${
fishing.autofish ? ` (AUTOFISH is enabled)` : `` fishing.autofish
? ` (AUTOFISH has been enabled for ${(
(Date.now() - fishing.autofish_t) /
1000 /
60
).toFixed(2)} minutes)`
: ``
}`; }`;
} }
} }

View File

@ -18,6 +18,7 @@ import { color } from "./general/color";
import { autofish } from "./util/autofish"; import { autofish } from "./util/autofish";
import { pokedex } from "./util/pokedex"; import { pokedex } from "./util/pokedex";
import { myid } from "./general/myid"; import { myid } from "./general/myid";
import { yeet } from "./inventory/yeet";
interface ICommandGroup { interface ICommandGroup {
id: string; id: string;
@ -46,7 +47,7 @@ commandGroups.push(fishingGroup);
const inventoryGroup: ICommandGroup = { const inventoryGroup: ICommandGroup = {
id: "inventory", id: "inventory",
displayName: "Inventory", displayName: "Inventory",
commands: [inventory, take, eat, sack, pokemon] commands: [inventory, take, eat, sack, pokemon, yeet]
}; };
commandGroups.push(inventoryGroup); commandGroups.push(inventoryGroup);

View File

@ -49,7 +49,7 @@ export const take = new Command(
break; break;
case "pokemon": case "pokemon":
// addItem(pokemon as unknown as IObject[], foundObject); // addItem(pokemon as unknown as IObject[], foundObject);
return "Unlike other items, Pokémon have to be caught."; return "Unlike other items, Pokémon have to be caught with a Pokéball.";
break; break;
default: default:
break; break;

View File

@ -0,0 +1,231 @@
import { addBack } from "@server/backs";
import Command from "@server/commands/Command";
import { logger } from "@server/commands/handler";
import { getInventory, updateInventory } from "@server/data/inventory";
import { getUser } from "@server/data/user";
import { getSizeString } from "@server/fish/fish";
import { fishers, getFishing } from "@server/fish/fishers";
import { CosmicColor } from "@util/CosmicColor";
export const yeet = new Command(
"yeet",
["yeet", "yoot"],
"Yeet literally anything you have (except non-fish animals)",
"yeet <something>",
"command.inventory.yeet",
async ({ id, command, args, prefix, part, user }) => {
const yeeting = args[0];
if (!yeeting) return `What do you want to ${prefix}yeet?`;
const inventory = await getInventory(user.inventoryId);
if (!inventory) return;
let foundObject: IObject | undefined;
let tryKekGen = false;
let i = 0;
for (const item of inventory.items as unknown as IItem[]) {
if (!item.name.toLowerCase().includes(yeeting.toLowerCase())) {
i++;
continue;
}
foundObject = item;
let shouldRemove = false;
if (typeof item.count !== "undefined") {
if (item.count > 1) {
shouldRemove = false;
((inventory.items as TInventoryItems)[i].count as number)--;
} else {
shouldRemove = true;
}
} else {
shouldRemove = true;
}
if (shouldRemove) (inventory.items as TInventoryItems).splice(i, 1);
break;
}
i = 0;
// no more yeeting animals
// for (const pokemon of inventory.pokemon as TPokemonSack) {
// if (!pokemon.name.toLowerCase().includes(yeeting.toLowerCase())) {
// i++;
// continue;
// }
// foundObject = pokemon as unknown as IObject;
// let shouldRemove = false;
// if (typeof pokemon.count !== "undefined") {
// if (pokemon.count > 1) {
// shouldRemove = false;
// ((inventory.pokemon as TPokemonSack)[i].count as number)--;
// } else {
// shouldRemove = true;
// }
// } else {
// shouldRemove = true;
// }
// if (shouldRemove) (inventory.pokemon as TPokemonSack).splice(i, 1);
// break;
// }
i = 0;
for (const fish of inventory.fishSack as TFishSack) {
if (!fish.name.toLowerCase().includes(yeeting.toLowerCase())) {
i++;
continue;
}
foundObject = fish;
let shouldRemove = false;
if (typeof fish.count !== "undefined") {
if (fish.count > 1) {
shouldRemove = false;
((inventory.fishSack as TFishSack)[i].count as number)--;
} else {
shouldRemove = true;
}
} else {
shouldRemove = true;
}
if (shouldRemove) (inventory.fishSack as TFishSack).splice(i, 1);
break;
}
if (!foundObject) return `You don't have "${yeeting}" to yeet.`;
if (foundObject.objtype == "fish") {
tryKekGen = true;
}
await updateInventory(inventory);
// TODO Implement kekklefruit generation
if (foundObject.id == "sand") {
return `No, ${part.name}, don't yeet ${foundObject.name}.`;
} else {
if (Math.random() < 0.15) {
const randomFisher =
Object.values(fishers)[
Math.floor(
Math.random() * Object.values(fishers).length
)
];
const person = await getUser(randomFisher.userID);
let target: string;
if (!person) {
target = "Anonymous";
} else {
target = person.name;
}
let handsAdjective = [
" violent ",
" shaking ",
" angery ",
" two (2) ",
" unknown number of ",
" "
];
let pastTense = [
"slung",
"foisted",
"launched",
"yeeted",
"expelled",
"fired"
];
let presentTense = [
"lazily",
"forcefully",
"haphazardly",
"angrily",
"playfully",
"lovingly"
];
let ending = [
`in the direction of ${target}.`,
`at where ${target} happens to be.`,
`at ${target}.`,
`directly at ${target}'s location in this realm.`,
`at the general vicinity of ${target}.`
];
let itemAdjective = [
"gooey",
"powdery",
"residual",
"smelly",
"appropriate",
foundObject.name,
foundObject.name + "y",
"greasy",
"uncomfortable",
"delicious",
"wonderful",
"questionable",
"nice",
"gelatinous",
"shampoo",
"fatty",
"warm",
"hot",
"cold",
"dripping",
"fish",
"unknown"
];
let ps = [
"It missed.",
"It grazed his/her cheek, leaving a small dab of " +
foundObject.name +
".",
foundObject.objtype == "fish"
? "Being that it was so " +
getSizeString((foundObject as IFish).size) +
", I'm sure you can infer how comical the result is!"
: "Being that it was so voluminous, I'm sure you can infer how comical the result is!",
"It smacked right across his/her face.",
"It got hung in his/her shirt and he/she flung it out onto the ground and it was quite a silly scene.",
`It scooted across his/her head before rebounding off onto the ground nearby. The ${
itemAdjective[
Math.floor(Math.random() * itemAdjective.length)
]
} residue was left behind in ${target}'s hair.`
];
return `Friend ${part.name}'s${
handsAdjective[
Math.floor(Math.random() * handsAdjective.length)
]
}hands grabbed his/her ${foundObject.name} and ${
pastTense[Math.floor(Math.random() * pastTense.length)]
} it ${
presentTense[
Math.floor(Math.random() * presentTense.length)
]
} ${ending[Math.floor(Math.random() * ending.length)]}`;
}
return `Friend ${part.name} tossed his/her ${foundObject.name}.`;
}
}
);

View File

@ -22,7 +22,7 @@ export const autofish = new Command(
).toFixed(2)} minutes ago).${ ).toFixed(2)} minutes ago).${
fishing.autofish fishing.autofish
? ` (AUTOFISH is enabled)` ? ` (AUTOFISH is enabled)`
: ` (${props.prefix}${reel.aliases[0]} in first to AUTOFISH)` : ` (${props.prefix}${reel.aliases[0]} in first to start AUTOFISH)`
}`; }`;
} }
} }

View File

@ -105,3 +105,24 @@ export function hasFishTime(
return false; return false;
} }
export function getSizeString(cm: number) {
const size =
cm < 30
? "small"
: cm < 60
? "medium-sized"
: cm < 75
? "large"
: cm < 100
? "huge"
: cm < 200
? "massive"
: cm < 300
? "gigantic"
: cm < 600
? "humongous"
: "supermassive";
return size;
}

View File

@ -1,7 +1,7 @@
import { kvGet, kvSet } from "@server/data/keyValueStore"; import { kvGet, kvSet } from "@server/data/keyValueStore";
import { getObjectStorage } from "@server/data/location"; import { getObjectStorage } from "@server/data/location";
import { addTickEvent, removeTickEvent } from "@util/tick"; import { addTickEvent, removeTickEvent } from "@util/tick";
import { randomFish } from "./fish"; import { getSizeString, randomFish } from "./fish";
import { getUser } from "@server/data/user"; import { getUser } from "@server/data/user";
import { getInventory, updateInventory } from "@server/data/inventory"; import { getInventory, updateInventory } from "@server/data/inventory";
import { addItem } from "@server/items"; import { addItem } from "@server/items";
@ -52,18 +52,7 @@ export async function tick() {
const animal = randomFish(inventory.location); const animal = randomFish(inventory.location);
addItem(inventory.fishSack as TFishSack, animal); addItem(inventory.fishSack as TFishSack, animal);
await updateInventory(inventory); await updateInventory(inventory);
const size = const size = getSizeString(animal.size);
animal.size < 30
? "small"
: animal.size < 60
? "medium-sized"
: animal.size < 75
? "large"
: animal.size < 100
? "huge"
: animal.size < 200
? "massive"
: "gigantic";
addBack(winner.id, { addBack(winner.id, {
m: "sendchat", m: "sendchat",
message: `Our good friend @${user.id} caught a ${size} ${ message: `Our good friend @${user.id} caught a ${size} ${
@ -123,7 +112,11 @@ export function stopFishing(
if (t > autofish_t + 5 * 60000) { if (t > autofish_t + 5 * 60000) {
addBack(fisher.id, { addBack(fisher.id, {
m: "sendchat", m: "sendchat",
message: `Friend @${fisher.userID}'s AUTOFISH has subsided after 5.0 minutes.`, message: `Friend @${fisher.userID}'s AUTOFISH has sibsided after ${(
(Date.now() - fisher.autofish_t) /
1000 /
60
).toFixed(2)} minutes.`,
isDM: fisher.isDM, isDM: fisher.isDM,
id: fisher.userID id: fisher.userID
}); });