add burger

This commit is contained in:
Hri7566 2024-06-13 04:39:12 -04:00
parent ac43825c27
commit d4a6c599ac
8 changed files with 96 additions and 14 deletions

View File

@ -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

View File

@ -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
);

View File

@ -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);

View File

@ -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
);

View File

@ -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

View File

@ -7,11 +7,12 @@ import { Logger } from "@util/Logger";
import { loadConfig } from "@util/config";
import { addTickEvent, removeTickEvent } from "@util/tick";
export const locations = loadConfig<ILocation[]>("config/locations.yml", [
export const locations = loadConfig<TAnyLocation[]>("config/locations.yml", [
{
id: "pond",
name: "Pond",
nearby: ["lake", "river", "sea"],
canFish: true,
hasSand: true,
objects: []
},
@ -19,6 +20,7 @@ export const locations = loadConfig<ILocation[]>("config/locations.yml", [
id: "lake",
name: "Lake",
nearby: ["pond", "river", "sea"],
canFish: true,
hasSand: false,
objects: []
},
@ -26,6 +28,7 @@ export const locations = loadConfig<ILocation[]>("config/locations.yml", [
id: "river",
name: "River",
nearby: ["pond", "lake", "sea"],
canFish: true,
hasSand: false,
objects: []
},
@ -33,8 +36,16 @@ export const locations = loadConfig<ILocation[]>("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);

View File

@ -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
}
};
}
}
}

19
src/util/types.d.ts vendored
View File

@ -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;