cntrl/tests/beacon_test.cpp
dandovlatov 6bad822113 Added the Hissed Floppy Disk: beacon-gated Security Booth reward with an Evade damage trail
The third Beacon now unseals the Security Booth, and entering it grants the
Hissed Floppy Disk — a permanent run item: dash cooldown x0.85 (15% faster
Evade) and a data trail dealing 8 base damage to enemies within 1.15 m of
the dash path, once per enemy per Evade. The briefing stamp now opens only
the Janitor and Locker rooms; the Booth stays sealed until all three
monuments burn, so the disk is earned, not found.

- Added floppy_disk.glb with its Blender generator (tools/blender/
  build_floppy_disk.py) and a bobbing render path for Decor props carrying
  a model name; one disk authored in floor01.json
- Rebuilt clearance-door visuals: fixed jamb/header frame, two leaves with
  a hot seam, red/green status bar and lit sill; open doors park their leaves
- HUD objective switches to ENTER THE SECURITY BOOTH once the Beacons burn;
  disk buff stamp listed while held
- Added --disk-test (beacons lit, start inside the Booth) and --door-test
  (start at the sealed door) QA flags
- Tests: beacon_test extended with booth gating, disk claim, buff and
  one-hit-per-dash cases (17/17 pass)
2026-11-25 06:41:42 +04:00

106 lines
3.9 KiB
C++

#include "game/beacon.hpp"
#include "game/floor.hpp"
#include "game/game.hpp"
#include <cmath>
#include <cstdio>
namespace {
int failures = 0;
void check(bool ok, const char* what) {
if (!ok) {
std::printf("FAIL: %s\n", what);
++failures;
}
}
int count_events(const EventQueue& events, EventType type) {
int n = 0;
for (int i = 0; i < events.count; ++i) {
if (events.items[i].type == type) ++n;
}
return n;
}
} // namespace
int main() {
Floor floor;
BeaconSystem beacons;
beacons.init(floor);
check(beacons.count() == 3, "three beacons authored in the level");
check(floor.beacon_colliders().size() == 3, "three beacon collision boxes");
const Vec2 first = beacons.beacons().front().pos;
check(floor.blocked(first, 0.45f), "beacon plinth blocks the player");
check(distance(floor.resolve(first, 0.45f), first) > 1.0f,
"resolve pushes the player out of the beacon");
check(!floor.blocked(first + Vec2{4.0f, 0.0f}, 0.45f),
"floor beside the beacon stays walkable");
EventQueue events;
for (const auto& b : beacons.beacons()) beacons.update(b.pos, events);
check(beacons.active_count() == 3, "walking over each beacon activates it");
check(beacons.complete(), "third beacon completes the set");
check(count_events(events, EventType::BeaconActivated) == 3,
"one activation event per beacon");
check(count_events(events, EventType::BeaconsComplete) == 1,
"one completion event when all beacons are active");
beacons.update(beacons.beacons().front().pos, events);
check(count_events(events, EventType::BeaconsComplete) == 1,
"completion event does not repeat");
beacons.reset();
check(beacons.active_count() == 0 && !beacons.complete(),
"reset clears beacon progress");
// Beacons gate the Security Booth, which holds the Hissed Floppy Disk.
Game game(1234);
check(!game.floor.door_open(static_cast<int>(DoorId::Booth)),
"Security Booth starts sealed");
InputState in{};
for (const auto& b : game.beacons.beacons()) {
game.player.pos = b.pos + Vec2{2.2f, 0.0f};
game.update(in, 1.0f / 60.0f);
}
check(game.beacons.complete(), "the game lights all three beacons");
check(game.floor.door_open(static_cast<int>(DoorId::Booth)),
"the third beacon unseals the Security Booth");
check(!game.player.hissed_disk, "the disk still needs a booth visit");
const FloorRoom* booth = nullptr;
for (const FloorRoom& r : game.floor.rooms()) {
if (r.side_index == 3) booth = &r;
}
check(booth != nullptr, "Security Booth room exists");
if (booth != nullptr) {
game.player.pos = {(booth->rect.x0 + booth->rect.x1) * 0.5f,
(booth->rect.z0 + booth->rect.z1) * 0.5f};
game.update(in, 1.0f / 60.0f);
}
check(game.player.hissed_disk, "entering the booth claims the disk");
check(std::fabs(game.player.stats.dash_cooldown_mult - 0.85f) < 1e-5f,
"the disk grants a 15% Evade cooldown buff");
// One Evade through an enemy deals the trail damage exactly once.
game.enemy_system.clear();
game.enemy_system.spawn(EnemyType::HissStaff,
game.player.pos + Vec2{1.0f, 0.0f}, game.corruption);
const float hp_before = game.enemy_system.enemies[0].hp;
in.dash = true;
in.move_x = 1.0f;
in.move_y = 0.0f;
game.update(in, 1.0f / 60.0f);
check(game.enemy_system.enemies[0].hp < hp_before,
"Evade damages an enemy passed through");
const float hp_after_one = game.enemy_system.enemies[0].hp;
for (int i = 0; i < 6; ++i) game.update(in, 1.0f / 60.0f);
check(game.enemy_system.enemies[0].hp == hp_after_one,
"one Evade hits an enemy only once");
if (failures == 0) std::printf("beacon tests passed\n");
else std::printf("%d failures\n", failures);
return failures == 0 ? 0 : 1;
}