#include "game/beacon.hpp" #include "game/floor.hpp" #include "game/game.hpp" #include #include 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(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(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; }