// SPDX-FileCopyrightText: 2026 Paula Wisnievski // SPDX-License-Identifier: AGPL-3.0-or-later // 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 { container_items, test_game } from "./helpers.ts"; 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 = container_items(t.take(1), "extra"); 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); });