// 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 { PLAYER_MENU_EXTRA } from "$/common/protocol.ts"; import { test_game } from "./helpers.ts"; // deno-lint-ignore no-explicit-any type Msg = any; async function setup() { const t = await test_game("mods"); t.join(1, "alice"); t.send(1, { type: "chat", text: "/give artifacts:power_glove" }); t.send(1, { type: "chat", text: "/give artifacts:feral_claws" }); t.take(1); const alice = t.game.players()[0]; // the curios slot artifacts go in, after the player's own menu's. which others there are depends on every mod const hands = PLAYER_MENU_EXTRA + alice.inventory_menu.extra.findIndex((s) => s.icon === "bworld:empty_hands_slot"); return { ...t, alice, hands }; } 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: "click", menu: 0, slot: 0, 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", menu: 0, slot: 1, button: 0 }); t.send(1, { type: "click", menu: 0, slot: t.hands, button: 0 }); t.game.tick(); assertEquals(t.alice.attribute(ATTRIBUTES.attack_damage), 1); assertEquals(t.alice.attribute(ATTRIBUTES.attack_speed), 4 * 1.3); }); Deno.test("worn artifacts work again after rejoining, and say what they do", async () => { const t = await setup(); t.send(1, { type: "click", menu: 0, slot: 0, button: 0, shift: true }); const worn = t.take(1).findLast((m: Msg) => m.type === "container" && m.container === "extra").items; assertEquals(worn[t.hands - PLAYER_MENU_EXTRA].lore, "When worn:\n+4 Attack Damage"); t.game.on_disconnect(1); t.join(1, "alice"); assertEquals(t.game.players()[0].attribute(ATTRIBUTES.attack_damage), 1 + 4); });