Inventory things

This commit is contained in:
Hri7566 2023-12-11 02:53:49 -05:00
parent 6db28fd2bc
commit 99ccca2412
6 changed files with 54 additions and 31 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -1,5 +1,5 @@
prefixes:
- id: "*"
- id: "**"
spaced: false
- id: cosmic
- id: cdebug
spaced: true

View File

@ -1,5 +1,5 @@
debug: false
enableConsole: false
debug: true
enableConsole: true
enableMPP: true
enableDiscord: true
enableDiscord: false
enableSwitchChat: false

View File

@ -4,7 +4,7 @@
"module": "src/index.ts",
"type": "module",
"devDependencies": {
"bun-types": "latest"
"bun-types": "^1.0.16"
},
"peerDependencies": {
"typescript": "^5.0.0"

View File

@ -42,7 +42,7 @@ export async function updateInventory(data: Omit<Inventory, "id">) {
where: { userId: data.userId },
data: {
balance: data.balance,
items: data.items as any
items: JSON.stringify(data.items)
}
});
}

View File

@ -0,0 +1,23 @@
import { expect, test } from "bun:test";
import { collapseInventory } from "../../src/data/inventory";
import { StackableItem } from "../../src/economy/Item";
test("Collapse inventory", () => {
let sampleData: StackableItem[] = [
{
id: "test_item",
name: "Test Item",
count: 10
},
{
id: "test_item",
name: "Test Item",
count: 15
}
];
collapseInventory(sampleData);
expect(sampleData[0].count).toBe(25);
expect(sampleData[1]).toBe(undefined);
console.log(sampleData);
});