Compare commits

...

2 Commits

Author SHA1 Message Date
Hri7566 2074915830 tidy 2024-06-13 04:39:22 -04:00
Hri7566 d4a6c599ac add burger 2024-06-13 04:39:12 -04:00
8 changed files with 89 additions and 14 deletions

View File

@ -2,7 +2,12 @@
# channel: # channel:
# id: "✧𝓓𝓔𝓥 𝓡𝓸𝓸𝓶✧" # id: "✧𝓓𝓔𝓥 𝓡𝓸𝓸𝓶✧"
# allowColorChanging: true # allowColorChanging: true
# - uri: wss://mppclone.com:8443
# channel:
# id: "test/fishing"
# allowColorChanging: true
- uri: wss://mppclone.com:8443 - uri: wss://mppclone.com:8443
channel: channel:
id: "test/fishing" id: "keller room"
allowColorChanging: true 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 { pick } from "./fishing/pick";
import { fid } from "./util/fid"; import { fid } from "./util/fid";
import { chance } from "./util/chance"; import { chance } from "./util/chance";
import { info } from "./general/info";
import { burger } from "./util/burger";
// import { give } from "./inventory/give"; // import { give } from "./inventory/give";
interface ICommandGroup { interface ICommandGroup {
@ -36,7 +38,7 @@ export const commandGroups: ICommandGroup[] = [];
const generalGroup: ICommandGroup = { const generalGroup: ICommandGroup = {
id: "general", id: "general",
displayName: "General", displayName: "General",
commands: [help, color, myid] commands: [help, color, myid, info]
}; };
commandGroups.push(generalGroup); commandGroups.push(generalGroup);
@ -52,7 +54,7 @@ commandGroups.push(fishingGroup);
const inventoryGroup: ICommandGroup = { const inventoryGroup: ICommandGroup = {
id: "inventory", id: "inventory",
displayName: "Inventory", displayName: "Inventory",
commands: [inventory, take, eat, sack, pokemon, yeet /* give */] commands: [inventory, take, eat, sack, pokemon, yeet, burger /* give */]
}; };
commandGroups.push(inventoryGroup); 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 = let winner =
Object.values(fishers)[ Object.values(fishers)[
Math.floor(Math.random() * Object.values(fishers).length) Math.floor(Math.random() * Object.values(fishers).length)
]; ];
if (!winner) return; if (!winner) return;
@ -44,7 +44,8 @@ export async function tick() {
if (r < data.chance / 10) { if (r < data.chance / 10) {
// After 60 minutes, reset chance // 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( stopFishing(
winner.id, winner.id,
@ -66,7 +67,13 @@ export async function tick() {
addBack(winner.id, { addBack(winner.id, {
m: "sendchat", m: "sendchat",
channel: winner.channel, 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, isDM: winner.isDM,
id: winner.userID id: winner.userID
}); });
@ -157,7 +164,7 @@ export async function getFishingChance(userID: string) {
export async function resetFishingChance(userID: string) { export async function resetFishingChance(userID: string) {
const key = `fishingChance~${userID}`; const key = `fishingChance~${userID}`;
logger.debug("Resetting fishing chance for user " + userID); // logger.debug("Resetting fishing chance for user " + userID);
await kvSet(key, { await kvSet(key, {
t: Date.now(), t: Date.now(),
chance: 1 chance: 1

View File

@ -7,11 +7,12 @@ import { Logger } from "@util/Logger";
import { loadConfig } from "@util/config"; import { loadConfig } from "@util/config";
import { addTickEvent, removeTickEvent } from "@util/tick"; import { addTickEvent, removeTickEvent } from "@util/tick";
export const locations = loadConfig<ILocation[]>("config/locations.yml", [ export const locations = loadConfig<TAnyLocation[]>("config/locations.yml", [
{ {
id: "pond", id: "pond",
name: "Pond", name: "Pond",
nearby: ["lake", "river", "sea"], nearby: ["lake", "river", "sea"],
canFish: true,
hasSand: true, hasSand: true,
objects: [] objects: []
}, },
@ -19,6 +20,7 @@ export const locations = loadConfig<ILocation[]>("config/locations.yml", [
id: "lake", id: "lake",
name: "Lake", name: "Lake",
nearby: ["pond", "river", "sea"], nearby: ["pond", "river", "sea"],
canFish: true,
hasSand: false, hasSand: false,
objects: [] objects: []
}, },
@ -26,6 +28,7 @@ export const locations = loadConfig<ILocation[]>("config/locations.yml", [
id: "river", id: "river",
name: "River", name: "River",
nearby: ["pond", "lake", "sea"], nearby: ["pond", "lake", "sea"],
canFish: true,
hasSand: false, hasSand: false,
objects: [] objects: []
}, },
@ -33,6 +36,7 @@ export const locations = loadConfig<ILocation[]>("config/locations.yml", [
id: "sea", id: "sea",
name: "Sea", name: "Sea",
nearby: ["pond", "lake", "river"], nearby: ["pond", "lake", "river"],
canFish: true,
hasSand: true, hasSand: true,
objects: [] objects: []
} }
@ -49,9 +53,10 @@ const logger = new Logger("Places");
export function populateSand() { export function populateSand() {
for (const loc of locations) { for (const loc of locations) {
if (!("hasSand" in loc)) continue;
if (!loc.hasSand) 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; if (typeof existing !== "undefined") continue;
loc.objects.push(sand); loc.objects.push(sand);

View File

@ -9,9 +9,6 @@ export const fish: IBehaviorDefinition = {
const fish = obj as IFish; const fish = obj as IFish;
console.log(fish)
console.log(fish.rarity);
// 50% // 50%
if (r < 0.5) { if (r < 0.5) {
const color = new CosmicColor( const color = new CosmicColor(
@ -37,7 +34,7 @@ export const fish: IBehaviorDefinition = {
return { return {
success: true, success: true,
shouldRemove: true shouldRemove: true
} };
} }
} }
} }

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

@ -101,9 +101,26 @@ interface ILocation {
name: string; name: string;
nearby: string[]; nearby: string[];
objects: IObject[]; 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 { interface TFisher {
id: string; id: string;
userID: string; userID: string;