Change whole gui system

This commit is contained in:
2026-10-01 16:22:02 -03:00
parent 013a4fbb97
commit deba36260e
48 changed files with 1925 additions and 1302 deletions
+10 -9
View File
@@ -1,7 +1,7 @@
// artifacts: items worn in curios slots that change the wearer's attributes, see mods/artifacts
import { assertEquals } from "@std/assert";
import { ATTRIBUTES } from "$/server/game/entity/attributes.ts";
import { test_game } from "./helpers.ts";
import { menu_items, opened_menu, test_game } from "./helpers.ts";
// deno-lint-ignore no-explicit-any
type Msg = any;
@@ -18,16 +18,17 @@ async function setup() {
Deno.test("the power glove and feral claws go in the hands slot, and only work while worn", async () => {
const t = await setup();
t.send(1, { type: "mod", channel: "curios:open", data: {} });
const screen = t.take(1).find((m: Msg) => m.type === "open_screen");
assertEquals(screen.layout.slots.map((s: Msg) => s.icon), ["curios:empty_hands_slot"]);
const menu = opened_menu(t.take(1));
// the hands slot, then the inventory's
assertEquals(menu.slots.map((s: Msg) => s.icon).filter(Boolean), ["curios:empty_hands_slot"]);
t.send(1, { type: "click", container: "inventory", index: 0, button: 0, shift: true });
t.send(1, { type: "click", menu: menu.id, slot: 1, button: 0, shift: true });
t.game.tick();
assertEquals(t.alice.attribute(ATTRIBUTES.attack_damage), 1 + 4);
// swapped for the claws by hand: the glove's damage goes, the claws' speed comes
t.send(1, { type: "click", container: "inventory", index: 1, button: 0 });
t.send(1, { type: "click", container: "screen", index: 6, button: 0 });
t.send(1, { type: "click", menu: menu.id, slot: 2, button: 0 });
t.send(1, { type: "click", menu: menu.id, slot: 0, button: 0 });
t.game.tick();
assertEquals(t.alice.attribute(ATTRIBUTES.attack_damage), 1);
assertEquals(t.alice.attribute(ATTRIBUTES.attack_speed), 4 * 1.3);
@@ -36,9 +37,9 @@ Deno.test("the power glove and feral claws go in the hands slot, and only work w
Deno.test("worn artifacts work again after rejoining, and say what they do", async () => {
const t = await setup();
t.send(1, { type: "mod", channel: "curios:open", data: {} });
t.send(1, { type: "click", container: "inventory", index: 0, button: 0, shift: true });
const curios = t.take(1).filter((m: Msg) => m.type === "container" && m.container === "screen").at(-1).items;
assertEquals(curios[6].lore, "When worn:\n+4 Attack Damage");
const { id } = opened_menu(t.take(1));
t.send(1, { type: "click", menu: id, slot: 1, button: 0, shift: true });
assertEquals(menu_items(t.take(1))[0].lore, "When worn:\n+4 Attack Damage");
t.game.on_disconnect(1);
t.join(1, "alice");