47 lines
2.0 KiB
TypeScript
47 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 { 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 screen = t.take(1).find((m: Msg) => m.type === "open_screen");
|
|
assertEquals(screen.layout.slots.map((s: Msg) => s.icon), ["curios:empty_hands_slot"]);
|
|
|
|
t.send(1, { type: "click", container: "inventory", index: 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", container: "inventory", index: 1, button: 0 });
|
|
t.send(1, { type: "click", container: "screen", index: 6, 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: {} });
|
|
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");
|
|
|
|
t.game.on_disconnect(1);
|
|
t.join(1, "alice");
|
|
assertEquals(t.game.players()[0].attribute(ATTRIBUTES.attack_damage), 1 + 4);
|
|
});
|