48 lines
2.0 KiB
TypeScript
48 lines
2.0 KiB
TypeScript
// 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 { menu_items, opened_menu, 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);
|
|
return { ...t, alice: t.game.players()[0] };
|
|
}
|
|
|
|
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 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", 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", 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);
|
|
});
|
|
|
|
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: {} });
|
|
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");
|
|
assertEquals(t.game.players()[0].attribute(ATTRIBUTES.attack_damage), 1 + 4);
|
|
});
|