diff --git a/config/bots.yml b/config/bots.yml index 0cb2c6b..36be29f 100644 --- a/config/bots.yml +++ b/config/bots.yml @@ -2,7 +2,12 @@ # channel: # id: "βœ§π““π“”π“₯ π“‘π“Έπ“Έπ“Άβœ§" # allowColorChanging: true +# - uri: wss://mppclone.com:8443 +# channel: +# id: "test/fishing" +# allowColorChanging: true + - uri: wss://mppclone.com:8443 channel: - id: "test/fishing" + id: "keller room" allowColorChanging: true diff --git a/src/api/commands/groups/general/info.ts b/src/api/commands/groups/general/info.ts new file mode 100644 index 0000000..22d2ea4 --- /dev/null +++ b/src/api/commands/groups/general/info.ts @@ -0,0 +1,13 @@ +import Command from "@server/commands/Command"; + +export const info = new Command( + "info", + ["info"], + "Get your own user ID", + "info", + "command.general.info", + async ({ id, command, args, prefix, part, user }) => { + return `🌊 Made by Hri7566 | Original created by Brandon Lockaby`; + }, + false +); diff --git a/src/api/commands/groups/index.ts b/src/api/commands/groups/index.ts index bb3d15b..ea23a46 100644 --- a/src/api/commands/groups/index.ts +++ b/src/api/commands/groups/index.ts @@ -23,6 +23,8 @@ import { tree } from "./fishing/tree"; import { pick } from "./fishing/pick"; import { fid } from "./util/fid"; import { chance } from "./util/chance"; +import { info } from "./general/info"; +import { burger } from "./util/burger"; // import { give } from "./inventory/give"; interface ICommandGroup { @@ -36,7 +38,7 @@ export const commandGroups: ICommandGroup[] = []; const generalGroup: ICommandGroup = { id: "general", displayName: "General", - commands: [help, color, myid] + commands: [help, color, myid, info] }; commandGroups.push(generalGroup); @@ -52,7 +54,7 @@ commandGroups.push(fishingGroup); const inventoryGroup: ICommandGroup = { id: "inventory", displayName: "Inventory", - commands: [inventory, take, eat, sack, pokemon, yeet /* give */] + commands: [inventory, take, eat, sack, pokemon, yeet, burger /* give */] }; commandGroups.push(inventoryGroup); diff --git a/src/api/commands/groups/util/burger.ts b/src/api/commands/groups/util/burger.ts new file mode 100644 index 0000000..e9bbd3e --- /dev/null +++ b/src/api/commands/groups/util/burger.ts @@ -0,0 +1,29 @@ +import { addBack } from "@server/backs"; +import Command from "@server/commands/Command"; +import { getInventory, updateInventory } from "@server/data/inventory"; +import { addItem } from "@server/items"; + +export const burger = new Command( + "burger", + ["burger"], + "Get a burger", + "burger", + "command.util.burger", + async ({ id, command, args, prefix, part, user }) => { + const burger = { + id: "burger", + name: "Burger", + objtype: "item", + emoji: "πŸ”" + }; + + const inv = await getInventory(user.inventoryId); + if (!inv) return "something has gone *terribly* wrong"; + + addItem(inv.items as unknown as IObject[], burger); + await updateInventory(inv); + + return "you now have burger"; + }, + false +); diff --git a/src/api/fish/fishers.ts b/src/api/fish/fishers.ts index 1de5e5a..9b78bfc 100644 --- a/src/api/fish/fishers.ts +++ b/src/api/fish/fishers.ts @@ -20,7 +20,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; @@ -44,7 +44,8 @@ export async function tick() { if (r < data.chance / 10) { // After 60 minutes, reset chance - if (data.t > 60 * 60000) await resetFishingChance(user.id); + if (data.t > Date.now() + 60 * 60000) + await resetFishingChance(user.id); stopFishing( winner.id, @@ -66,7 +67,13 @@ export async function tick() { addBack(winner.id, { m: "sendchat", channel: winner.channel, - 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)" : ""}`, + 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 }); @@ -157,7 +164,7 @@ export async function getFishingChance(userID: string) { export async function resetFishingChance(userID: string) { const key = `fishingChance~${userID}`; - logger.debug("Resetting fishing chance for user " + userID); + // logger.debug("Resetting fishing chance for user " + userID); await kvSet(key, { t: Date.now(), chance: 1 diff --git a/src/api/fish/locations.ts b/src/api/fish/locations.ts index aeaaec7..07744ce 100644 --- a/src/api/fish/locations.ts +++ b/src/api/fish/locations.ts @@ -7,11 +7,12 @@ import { Logger } from "@util/Logger"; import { loadConfig } from "@util/config"; import { addTickEvent, removeTickEvent } from "@util/tick"; -export const locations = loadConfig("config/locations.yml", [ +export const locations = loadConfig("config/locations.yml", [ { id: "pond", name: "Pond", nearby: ["lake", "river", "sea"], + canFish: true, hasSand: true, objects: [] }, @@ -19,6 +20,7 @@ export const locations = loadConfig("config/locations.yml", [ id: "lake", name: "Lake", nearby: ["pond", "river", "sea"], + canFish: true, hasSand: false, objects: [] }, @@ -26,6 +28,7 @@ export const locations = loadConfig("config/locations.yml", [ id: "river", name: "River", nearby: ["pond", "lake", "sea"], + canFish: true, hasSand: false, objects: [] }, @@ -33,8 +36,16 @@ export const locations = loadConfig("config/locations.yml", [ id: "sea", name: "Sea", nearby: ["pond", "lake", "river"], + canFish: true, hasSand: true, objects: [] + }, + { + id: "shop", + name: "Shop", + nearby: ["pond", "lake", "river"], + isShop: true, + objects: [] } ]); @@ -49,9 +60,10 @@ const logger = new Logger("Places"); export function populateSand() { for (const loc of locations) { + if (!("hasSand" in loc)) continue; if (!loc.hasSand) continue; - let existing = loc.objects.find(obj => obj.id == "sand"); + let existing = loc.objects.find((obj: ILocation) => obj.id == "sand"); if (typeof existing !== "undefined") continue; loc.objects.push(sand); diff --git a/src/api/items/behavior/items/fish.ts b/src/api/items/behavior/items/fish.ts index f22f049..0ef7f17 100644 --- a/src/api/items/behavior/items/fish.ts +++ b/src/api/items/behavior/items/fish.ts @@ -9,9 +9,6 @@ export const fish: IBehaviorDefinition = { const fish = obj as IFish; - console.log(fish) - console.log(fish.rarity); - // 50% if (r < 0.5) { const color = new CosmicColor( @@ -37,7 +34,7 @@ export const fish: IBehaviorDefinition = { return { success: true, shouldRemove: true - } + }; } } } diff --git a/src/util/types.d.ts b/src/util/types.d.ts index 5006ed6..2dd06a0 100644 --- a/src/util/types.d.ts +++ b/src/util/types.d.ts @@ -101,9 +101,26 @@ interface ILocation { name: string; nearby: string[]; objects: IObject[]; - hasSand: boolean; } +interface IFishingLocation extends ILocation { + canFish: true; +} + +interface ISandyLocation extends ILocation { + hasSand: true; +} + +interface IShopLocation extends ILocation { + isShop: true; +} + +type TAnyLocation = + | ILocation + | IFishingLocation + | ISandyFishingLocation + | IShopLocation; + interface TFisher { id: string; userID: string;