From 8296e6942fd0f276f62721e6e09e0f92cc1816a5 Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Fri, 27 Oct 2023 22:13:39 -0400 Subject: [PATCH] Start economy stuff --- config/mpp_net_channels.yml | 3 +- src/commands/commands/economy/inventory.ts | 25 +++++ src/commands/commands/utility/cursor.ts | 17 +++ src/commands/index.ts | 8 +- src/economy/Item.ts | 8 ++ src/services/mpp/Cursor.ts | 120 ++++++++++++++++++++- 6 files changed, 176 insertions(+), 5 deletions(-) create mode 100644 src/commands/commands/economy/inventory.ts create mode 100644 src/commands/commands/utility/cursor.ts create mode 100644 src/economy/Item.ts diff --git a/config/mpp_net_channels.yml b/config/mpp_net_channels.yml index f0bd645..0447ac3 100644 --- a/config/mpp_net_channels.yml +++ b/config/mpp_net_channels.yml @@ -3,4 +3,5 @@ desiredUser: color: "#1d0054" agents: wss://mppclone.com: - - id: "βœ§π““π“”π“₯ π“‘π“Έπ“Έπ“Άβœ§" + # - id: "βœ§π““π“”π“₯ π“‘π“Έπ“Έπ“Άβœ§" + - id: "wizardposting" diff --git a/src/commands/commands/economy/inventory.ts b/src/commands/commands/economy/inventory.ts new file mode 100644 index 0000000..10c55ad --- /dev/null +++ b/src/commands/commands/economy/inventory.ts @@ -0,0 +1,25 @@ +import { Item, StackableItem } from "../../../economy/Item"; +import { Command } from "../../Command"; +import { CommandHandler } from "../../CommandHandler"; + +export const inventory = new Command( + "inventory", + ["inventory", "inv"], + "get bozo's inventory", + "inventory", + (msg, agent) => { + const items = msg.inventory.items as unknown as Item[]; + const list = items + .map( + i => + `${i.name}${ + (i as StackableItem).count + ? " " + (i as StackableItem).count + : "" + }` + ) + .join(" | "); + + return `Items: ${list ? list : "(none)"}`; + } +); diff --git a/src/commands/commands/utility/cursor.ts b/src/commands/commands/utility/cursor.ts new file mode 100644 index 0000000..7575071 --- /dev/null +++ b/src/commands/commands/utility/cursor.ts @@ -0,0 +1,17 @@ +import { MPPAgent } from "../../../services/mpp"; +import { Command } from "../../Command"; + +export const cursor = new Command( + "cursor", + ["cursor"], + "set the cursor bozo", + "cursor", + (msg, agent) => { + if (!(agent as MPPAgent).client.isConnected) return; + if (!msg.argv[1]) return "Specify a mode."; + + const cursor = (agent as MPPAgent).cursor; + cursor.props.currentAnimation = msg.argv[1]; + }, + false +); diff --git a/src/commands/index.ts b/src/commands/index.ts index 9c2b671..3b7a8e8 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -6,13 +6,19 @@ import { id } from "./commands/utility/id"; import { msg } from "./commands/utility/msg"; import { math } from "./commands/utility/math"; import { memory } from "./commands/utility/memory"; +import { cursor } from "./commands/utility/cursor"; +import { inventory } from "./commands/economy/inventory"; export function loadCommands() { const general = new CommandGroup("general", "⭐ General"); general.addCommands([help, about]); CommandHandler.addCommandGroup(general); + const economy = new CommandGroup("economy", "πŸ’Έ Economy"); + economy.addCommands([inventory]); + CommandHandler.addCommandGroup(economy); + const utility = new CommandGroup("utility", "πŸ”¨ Utility"); - utility.addCommands([math, memory, id, msg]); + utility.addCommands([math, memory, id, msg, cursor]); CommandHandler.addCommandGroup(utility); } diff --git a/src/economy/Item.ts b/src/economy/Item.ts new file mode 100644 index 0000000..9417e84 --- /dev/null +++ b/src/economy/Item.ts @@ -0,0 +1,8 @@ +export interface Item { + id: string; + name: string; +} + +export interface StackableItem extends Item { + count: number; +} diff --git a/src/services/mpp/Cursor.ts b/src/services/mpp/Cursor.ts index 33a82d9..d8a6061 100644 --- a/src/services/mpp/Cursor.ts +++ b/src/services/mpp/Cursor.ts @@ -25,7 +25,7 @@ export class Cursor { public updateInterval: NodeJS.Timeout; public props: CursorProps = { - currentAnimation: "lemniscate", + currentAnimation: "test2", position: { x: 50, y: 50 @@ -35,8 +35,8 @@ export class Cursor { y: 0 }, velocity: { - x: 0, - y: 0 + x: 2 / 5, + y: 2 / 7 }, acceleration: { x: 0, @@ -112,6 +112,7 @@ export class Cursor { this.props.position.x >= 105 ) { this.props.position.x = 50; + this.props.velocity.x = 0; } if ( @@ -119,6 +120,64 @@ export class Cursor { this.props.position.y >= 105 ) { this.props.position.y = 50; + this.props.velocity.y = 0; + } + + this.props.ot = Date.now(); + break; + case "bounce2": + this.props.oldPosition.x = this.props.position.x; + this.props.oldPosition.y = this.props.position.y; + this.props.t = Date.now(); + this.props.dt = (this.props.t - this.props.ot) / 1000; + + this.props.acceleration.x = Math.random() * 100 - 50; + + if (this.props.position.y < 75) { + this.props.acceleration.y = + Math.random() * 100 - 50 - this.props.gravity; + } else { + this.props.acceleration.y = -(Math.random() * 50); + } + + this.props.velocity.x += + this.props.acceleration.x * this.props.dt; + this.props.velocity.y += + this.props.acceleration.y * this.props.dt; + + this.props.position.x += + this.props.velocity.x * this.props.dt; + this.props.position.y += + this.props.velocity.y * this.props.dt; + + if ( + this.props.position.x >= 100 || + this.props.position.x <= 0 + ) { + this.props.velocity.x = -this.props.velocity.x; + } + + if ( + this.props.position.y >= 100 || + this.props.position.y <= 0 + ) { + this.props.velocity.y = -this.props.velocity.y; + } + + if ( + this.props.position.x <= -5 || + this.props.position.x >= 105 + ) { + this.props.position.x = 50; + this.props.velocity.x = 0; + } + + if ( + this.props.position.y <= -5 || + this.props.position.y >= 105 + ) { + this.props.position.y = 50; + this.props.velocity.y = 0; } this.props.ot = Date.now(); @@ -156,6 +215,7 @@ export class Cursor { this.props.position.x >= 105 ) { this.props.position.x = 50; + this.props.velocity.x = 0; } if ( @@ -163,6 +223,7 @@ export class Cursor { this.props.position.y >= 105 ) { this.props.position.y = 50; + this.props.velocity.y = 0; } this.props.ot = Date.now(); @@ -181,6 +242,59 @@ export class Cursor { 10 + 50; + break; + case "test": + if (!this.props.angles[0]) this.props.angles[0] = 0; + + this.props.angles[0] += 2; + if (this.props.angles[0] > 360) this.props.angles[0] = 0; + + this.props.position.x = + Math.cos(this.props.angles[0] * (Math.PI / 180)) * 10 + + 50; + this.props.position.y = + Math.sin(this.props.angles[0] * (Math.PI / 180) * 2) * + 10 + + 50; + + break; + case "test2": + this.props.oldPosition.x = this.props.position.x; + this.props.oldPosition.y = this.props.position.y; + this.props.t = Date.now(); + this.props.dt = (this.props.t - this.props.ot) / 1000; + + if (this.props.velocity.x > 10) + this.props.velocity.x = 2 / 5; + if (this.props.velocity.x < -10) + this.props.velocity.x = -(2 / 5); + if (this.props.velocity.y > 10) + this.props.velocity.y = 2 / 7; + if (this.props.velocity.y < -10) + this.props.velocity.y = -(2 / 7); + + this.props.position.x += + this.props.velocity.x * this.props.dt * 10; + this.props.position.y += + this.props.velocity.y * this.props.dt * 10; + + if ( + this.props.position.x >= 100 || + this.props.position.x <= 0 + ) { + this.props.velocity.x = -this.props.velocity.x; + } + + if ( + this.props.position.y >= 100 || + this.props.position.y <= 0 + ) { + this.props.velocity.y = -this.props.velocity.y; + console.log(this.props.velocity, "setting!!!"); + } + + this.props.ot = Date.now(); + break; } }, 1000 / 60);