From ebbdb15f804502ecade21df0193ffd646a2379dd Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Wed, 12 Jun 2024 05:19:30 -0400 Subject: [PATCH] Check linear - FIS-48 FIS-49 --- src/api/commands/groups/fishing/go.ts | 5 +- src/api/commands/groups/index.ts | 3 +- src/api/commands/groups/inventory/eat.ts | 10 +++- .../commands/groups/inventory/inventory.ts | 18 +++---- src/api/commands/groups/util/autofish.ts | 7 ++- src/api/commands/groups/util/chance.ts | 16 ++++++ src/api/fish/fishers.ts | 14 +++--- src/api/items/behavior/items/fish.ts | 49 ++++++++++++------- 8 files changed, 79 insertions(+), 43 deletions(-) create mode 100644 src/api/commands/groups/util/chance.ts diff --git a/src/api/commands/groups/fishing/go.ts b/src/api/commands/groups/fishing/go.ts index 29459d9..d24180c 100644 --- a/src/api/commands/groups/fishing/go.ts +++ b/src/api/commands/groups/fishing/go.ts @@ -37,8 +37,9 @@ export const go = new Command( inventory.location = nextLoc.id; await updateInventory(inventory); - if (getFishing(id, user.id)) { - stopFishing(id, user.id, false); + let fisher; + if (fisher = getFishing(id, user.id)) { + stopFishing(id, user.id, fisher.channel, false); return `You ${prefix}${reel.aliases[0]}ed your LURE in and went to ${nextLoc.name}.`; } diff --git a/src/api/commands/groups/index.ts b/src/api/commands/groups/index.ts index 0a67b7e..bb3d15b 100644 --- a/src/api/commands/groups/index.ts +++ b/src/api/commands/groups/index.ts @@ -22,6 +22,7 @@ import { yeet } from "./inventory/yeet"; import { tree } from "./fishing/tree"; import { pick } from "./fishing/pick"; import { fid } from "./util/fid"; +import { chance } from "./util/chance"; // import { give } from "./inventory/give"; interface ICommandGroup { @@ -59,7 +60,7 @@ commandGroups.push(inventoryGroup); const utilGroup: ICommandGroup = { id: "util", displayName: "Utility", - commands: [data, setcolor, memory, autofish, pokedex, fid] + commands: [data, setcolor, memory, autofish, pokedex, fid, chance] }; commandGroups.push(utilGroup); diff --git a/src/api/commands/groups/inventory/eat.ts b/src/api/commands/groups/inventory/eat.ts index f5d5da2..b6c2559 100644 --- a/src/api/commands/groups/inventory/eat.ts +++ b/src/api/commands/groups/inventory/eat.ts @@ -108,15 +108,21 @@ export const eat = new Command( if (foundObject.id == "sand") { if (res) { - if (res.and) + if (res.and) { return `Our friend ${part.name} ate of his/her ${foundObject.name} ${res.and}`; + } else { + return `Our friend ${part.name} ate of his/her ${foundObject.name}.`; + } } else { return `Our friend ${part.name} ate of his/her ${foundObject.name}.`; } } else { if (res) { - if (res.and) + if (res.and) { return `Our friend ${part.name} ate his/her ${foundObject.name} ${res.and}`; + } else { + return `Our friend ${part.name} ate his/her ${foundObject.name}.`; + } } else { return `Our friend ${part.name} ate his/her ${foundObject.name}.`; } diff --git a/src/api/commands/groups/inventory/inventory.ts b/src/api/commands/groups/inventory/inventory.ts index 25f142e..82e2950 100644 --- a/src/api/commands/groups/inventory/inventory.ts +++ b/src/api/commands/groups/inventory/inventory.ts @@ -5,7 +5,7 @@ import prisma from "@server/data/prisma"; export const inventory = new Command( "inventory", - ["inventory", "inv", "i"], + ["inventory", "inv", "items", "i"], "Look at your inventory", "inventory", "command.inventory.inventory", @@ -37,32 +37,28 @@ export const inventory = new Command( const items = inv.items as TInventoryItems; - return `Contents of ${decidedUser.name}'s inventory: ${ - items + return `Contents of ${decidedUser.name}'s inventory: ${items .map( (item: IItem) => - `${item.emoji || "📦"}${item.name}${ - item.count ? ` (x${item.count})` : "" + `${item.emoji || "📦"}${item.name}${item.count ? ` (x${item.count})` : "" }` ) .join(", ") || "(none)" - }`; + }`; } else { const inv = await getInventory(user.inventoryId); if (!inv) return `Apparently, you have no inventory. Not sure if that can be fixed, and I don't know how you got this message.`; const items = inv.items as TInventoryItems; - return `Contents of ${part.name}'s inventory: ${ - items + return `Contents of ${part.name}'s inventory: ${items .map( (item: IItem) => - `${item.emoji || "📦"}${item.name}${ - item.count ? ` (x${item.count})` : "" + `${item.emoji || "📦"}${item.name}${item.count ? ` (x${item.count})` : "" }` ) .join(", ") || "(none)" - }`; + }`; } } ); diff --git a/src/api/commands/groups/util/autofish.ts b/src/api/commands/groups/util/autofish.ts index 9f16a08..22fc159 100644 --- a/src/api/commands/groups/util/autofish.ts +++ b/src/api/commands/groups/util/autofish.ts @@ -12,18 +12,17 @@ export const autofish = new Command( const fishing = getFishing(props.id, props.part.id); if (!fishing) { - startFishing(props.id, props.part.id, true, true); + startFishing(props.id, props.part.id, props.channel, true, true); return `Our friend ${props.user.name} casts LURE into a water with AUTOFISH enabled. (${props.prefix}${reel.aliases[0]} to disable)`; } else { return `Your lure is already in the water (since ${( (Date.now() - fishing.t) / 1000 / 60 - ).toFixed(2)} minutes ago).${ - fishing.autofish + ).toFixed(2)} minutes ago).${fishing.autofish ? ` (AUTOFISH is enabled)` : ` (${props.prefix}${reel.aliases[0]} in first to start AUTOFISH)` - }`; + }`; } } ); diff --git a/src/api/commands/groups/util/chance.ts b/src/api/commands/groups/util/chance.ts new file mode 100644 index 0000000..debd53a --- /dev/null +++ b/src/api/commands/groups/util/chance.ts @@ -0,0 +1,16 @@ +import { addBack } from "@server/backs"; +import Command from "@server/commands/Command"; +import { getFishingChance } from "@server/fish/fishers"; + +export const chance = new Command( + "chance", + ["chance"], + "Set own user color", + "chance", + "command.util.chance", + async ({ id, command, args, prefix, part, user }) => { + const chance = await getFishingChance(user.id); + return `Fishing chance: ${chance.chance} | Timestamp: ${chance.t}`; + }, + false +); diff --git a/src/api/fish/fishers.ts b/src/api/fish/fishers.ts index 0475ad5..022a6a6 100644 --- a/src/api/fish/fishers.ts +++ b/src/api/fish/fishers.ts @@ -21,7 +21,7 @@ export async function tick() { let winner = Object.values(fishers)[ - Math.floor(Math.random() * Object.values(fishers).length) + Math.floor(Math.random() * Object.values(fishers).length) ]; if (!winner) return; @@ -53,18 +53,20 @@ export async function tick() { winner.autofish, winner.autofish_t ); + + // Save to sack const animal = randomFish(inventory.location); addItem(inventory.fishSack as TFishSack, animal); await updateInventory(inventory); + const size = getSizeString(animal.size); + const p = prefixes[0]; + const emoji = animal.emoji || "🐟"; + addBack(winner.id, { m: "sendchat", channel: winner.channel, - message: `Our good friend @${user.id} caught a ${size} ${ - animal.emoji || "🐟" - }${animal.name}! ready to ${prefixes[0]}eat or ${ - prefixes[0] - }fish again${winner.autofish ? " (AUTOFISH is enabled)" : ""}`, + message: `Our good friend @${user.id} caught a ${size} ${emoji}${animal.name}! ready to ${p}eat or ${p}fish again${winner.autofish ? " (AUTOFISH is enabled)" : ""}`, isDM: winner.isDM, id: winner.userID }); diff --git a/src/api/items/behavior/items/fish.ts b/src/api/items/behavior/items/fish.ts index b5fbd80..f22f049 100644 --- a/src/api/items/behavior/items/fish.ts +++ b/src/api/items/behavior/items/fish.ts @@ -5,25 +5,40 @@ export const fish: IBehaviorDefinition = { id: "fish", bhv: { async eat(obj, props) { - const color = new CosmicColor( - Math.floor(Math.random() * 255), - Math.floor(Math.random() * 255), - Math.floor(Math.random() * 255) - ); + const r = Math.random(); - addBack(props.id, { - m: "color", - id: props.part.id, - color: color.toHexa() - }); + const fish = obj as IFish; - return { - success: true, - shouldRemove: true, - and: `and it made him/her turn ${color - .getName() - .toLowerCase()}.` - }; + console.log(fish) + console.log(fish.rarity); + + // 50% + if (r < 0.5) { + const color = new CosmicColor( + Math.floor(Math.random() * 255), + Math.floor(Math.random() * 255), + Math.floor(Math.random() * 255) + ); + + addBack(props.id, { + m: "color", + id: props.part.id, + color: color.toHexa() + }); + + return { + success: true, + shouldRemove: true, + and: `and it made him/her turn ${color + .getName() + .toLowerCase()}.` + }; + } else { + return { + success: true, + shouldRemove: true + } + } } } };