Inventory things
This commit is contained in:
parent
6db28fd2bc
commit
99ccca2412
|
@ -1,5 +1,5 @@
|
||||||
prefixes:
|
prefixes:
|
||||||
- id: "*"
|
- id: "**"
|
||||||
spaced: false
|
spaced: false
|
||||||
- id: cosmic
|
- id: cdebug
|
||||||
spaced: true
|
spaced: true
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
debug: false
|
debug: true
|
||||||
enableConsole: false
|
enableConsole: true
|
||||||
enableMPP: true
|
enableMPP: true
|
||||||
enableDiscord: true
|
enableDiscord: false
|
||||||
enableSwitchChat: false
|
enableSwitchChat: false
|
||||||
|
|
50
package.json
50
package.json
|
@ -1,27 +1,27 @@
|
||||||
{
|
{
|
||||||
"name": "supercosmic",
|
"name": "supercosmic",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"module": "src/index.ts",
|
"module": "src/index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bun-types": "latest"
|
"bun-types": "^1.0.16"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@prisma/client": "^5.5.2",
|
"@prisma/client": "^5.5.2",
|
||||||
"@t3-oss/env-core": "^0.7.1",
|
"@t3-oss/env-core": "^0.7.1",
|
||||||
"discord.js": "^14.14.1",
|
"discord.js": "^14.14.1",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
"hyperimport": "^0.1.0",
|
"hyperimport": "^0.1.0",
|
||||||
"mathjs": "^11.11.2",
|
"mathjs": "^11.11.2",
|
||||||
"mpp-client-net": "^1.1.3",
|
"mpp-client-net": "^1.1.3",
|
||||||
"mpp-client-xt": "^1.3.1",
|
"mpp-client-xt": "^1.3.1",
|
||||||
"prisma": "^5.4.2",
|
"prisma": "^5.4.2",
|
||||||
"switchchat": "^3.2.1",
|
"switchchat": "^3.2.1",
|
||||||
"typescript": "^5.3.2",
|
"typescript": "^5.3.2",
|
||||||
"yaml": "^2.3.3",
|
"yaml": "^2.3.3",
|
||||||
"zod": "^3.22.4"
|
"zod": "^3.22.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ export async function updateInventory(data: Omit<Inventory, "id">) {
|
||||||
where: { userId: data.userId },
|
where: { userId: data.userId },
|
||||||
data: {
|
data: {
|
||||||
balance: data.balance,
|
balance: data.balance,
|
||||||
items: data.items as any
|
items: JSON.stringify(data.items)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
});
|
Loading…
Reference in New Issue