Curios and artifacts !

This commit is contained in:
2026-09-30 15:22:32 -03:00
parent 342b45d593
commit 3af5f6e54b
45 changed files with 729 additions and 43 deletions
+26 -2
View File
@@ -149,7 +149,8 @@ Deno.test("players hit entities they can reach, pushing them away", async () =>
const mob = spawn(0.5, 100, 2.5);
const far = spawn(0.5, 100, 20.5);
far.tags.add("stays");
ticks(2);
// long enough for a full strength attack
ticks(5);
send(1, { type: "attack_entity", id: mob.id });
assertEquals(mob.health, 9);
@@ -161,12 +162,35 @@ Deno.test("players hit entities they can reach, pushing them away", async () =>
send(1, { type: "attack_entity", id: "nothing" });
});
Deno.test("attacking again before the attack speed allows hits weaker, like minecraft", async () => {
const { game, spawn, ticks, send } = await floor_game();
const [alice] = game.players();
alice.attributes.get(ATTRIBUTES.attack_damage)!.base = 5;
const mob = spawn(0.5, 100, 2.5);
ticks(5);
send(1, { type: "attack_entity", id: mob.id });
assertEquals(mob.health, 5, "4 attacks a second, so 5 ticks is full strength");
// right away is a fifth, a tick later a bit more. past the hurt cooldown, so it isn't just the difference
ticks(20);
alice.attack_strength_ticker = 0;
send(1, { type: "attack_entity", id: mob.id });
assertEquals(mob.health, 5 - 5 * (0.2 + 0.1 * 0.1 * 0.8));
// faster attack speed fills up sooner
ticks(10);
alice.attributes.get(ATTRIBUTES.attack_speed)!.base = 20;
alice.attack_strength_ticker = 1;
assertEquals(alice.attack_strength(), 1);
});
Deno.test("players hit each other, knocking them back and flashing red for everyone else", async () => {
const { game, ticks, send, join, take } = await floor_game();
join(2, "bob");
send(2, { type: "move", x: 0.5, y: 100, z: 2.5, yaw: 0, pitch: 0 });
const [alice, bob] = game.players();
ticks(1);
// long enough for a full strength attack
ticks(5);
take(1);
take(2);