Giant chestplate regeneration passive

This commit is contained in:
2026-10-01 18:16:03 -03:00
parent f2c3cb8135
commit 8396e8e895
9 changed files with 168 additions and 8 deletions
+27 -1
View File
@@ -4,6 +4,7 @@ import { assert, assertEquals } from "@std/assert";
import { PLAYER_MENU_EXTRA, PROTOCOL_VERSION } from "$/common/protocol.ts";
import { copy_dir, test_game } from "./helpers.ts";
import type { WorldSave } from "$/server/game/saves.ts";
import { EFFECTS } from "$/server/game/entity/effects.ts";
// deno-lint-ignore no-explicit-any
type Msg = any;
@@ -131,7 +132,7 @@ Deno.test("the giant chestplate goes in the body slot and gives 20 more health w
assertEquals(curios_items(t.take(1))[body], {
id: "bworld:giant_chestplate",
count: 1,
lore: "When worn:\n+20 Max Health",
lore: "When worn:\n+20 Max Health\nAfter 10s unhurt: Regeneration II",
});
assertEquals(alice.max_health, 40);
@@ -155,6 +156,31 @@ Deno.test("the giant chestplate goes in the body slot and gives 20 more health w
assertEquals(t.game.players()[0].health, 20);
});
Deno.test("the giant chestplate gives regeneration II after 10 seconds without being hurt", async () => {
const t = await setup();
t.send(1, { type: "chat", text: "/give bworld:giant_chestplate" });
const slot = last_container(t.take(1), "inventory").findIndex((i: Msg) => i?.id === "bworld:giant_chestplate");
const alice = t.game.players()[0];
t.send(1, { type: "click", menu: 0, slot, button: 0, shift: true });
t.game.damage_player(alice, 2, "test");
const regeneration = () => alice.get_effect(EFFECTS.regeneration);
for (let i = 0; i < 199; i++) t.game.tick();
assertEquals(regeneration(), undefined);
t.game.tick();
assertEquals(regeneration()?.amplifier, 1);
// it keeps being topped up while they stay unhurt
for (let i = 0; i < 200; i++) t.game.tick();
assertEquals(regeneration()?.amplifier, 1);
// being hurt starts the 10 seconds again, what they were given runs out
t.game.damage_player(alice, 2, "test");
for (let i = 0; i < 199; i++) t.game.tick();
assertEquals(regeneration(), undefined);
t.game.tick();
assertEquals(regeneration()?.amplifier, 1);
});
Deno.test("everyone sees what a player wears that has a worn model, and players joining later too", async () => {
const t = await setup();
const alice = t.game.players()[0].id;