cntrl/tests/blackout_test.cpp
dandovlatov faf048c1f2 FBC: NIGHT SHIFT - polished the blackout flow and made skill keys responsive
- Kept the default tactical camera in the projector blackout; lights go out
  ~2 s after crossing the screen (Pending phase with normal play/grace)
- Removed the blackout task HUD (progress card, dots, instructions); replaced
  with close-range world-anchored FBC inspection placards for the screen,
  phones and the glass case
- Fixed manual J/K/U presses feeling dead: queued a press while the skill is on
  cooldown and flashed the HUD stamp immediately; cleared the queue on autoplay
  toggle and during the pocket. Added a regression test
- Added a --blackout-near-phone QA hook; updated design docs and README
2026-11-25 00:20:49 +04:00

84 lines
3.1 KiB
C++

// Projector-screen blackout: 20 phone chain, glass case claim, skill reward.
#include <cstdio>
#include "game/game.hpp"
namespace {
constexpr float kDt = 1.0f / 60.0f;
bool failed = false;
void check(bool ok, const char* what) {
if (!ok) {
std::printf("FAIL: %s\n", what);
failed = true;
}
}
int count_events(const Game& game, EventType type) {
int n = 0;
for (int i = 0; i < game.events.count; ++i)
if (game.events.items[i].type == type) ++n;
return n;
}
} // namespace
int main() {
Game game(42);
const BlackoutSequence& b = game.blackout;
check(!b.active() && !b.complete(), "blackout starts idle");
check(!game.skill_system.fluorescent_unlocked, "reward starts locked");
// Walking into the non-colliding screen arms the puzzle; the room stays
// lit and the camera stays normal for ~2 s before the lights go out.
game.player.pos = b.screen_pos();
game.update(InputState{}, kDt);
check(b.pending() && !b.active(), "entering the screen only arms the blackout");
check(count_events(game, EventType::BlackoutStart) == 0,
"no lights-out event during the grace period");
game.update(InputState{}, 2.1f);
check(b.active(), "lights go out ~2 s after entering the screen");
check(count_events(game, EventType::BlackoutStart) == 1,
"blackout start event emitted when lights go out");
// Every unanswered phone can be activated by walking over it; order does
// not matter and an already-answered phone is inert.
for (int pass = 0; pass < 2; ++pass) {
for (int i = 0; i < BlackoutSequence::kPhoneCount; ++i) {
game.player.pos = b.phone(i);
game.blackout.update(0.7f, game.player, game.events, false);
}
}
check(b.answered() == BlackoutSequence::kPhoneCount,
"all 20 phones answer exactly once");
check(b.phase() == BlackoutPhase::CaseRevealed,
"case reveals after the last phone");
check(count_events(game, EventType::BlackoutPhone) ==
BlackoutSequence::kPhoneCount,
"one phone event per phone");
check(count_events(game, EventType::BlackoutCase) == 1,
"case reveal event emitted");
// Entering the case completes the ritual and restores the lights.
game.player.pos = b.case_pos();
game.update(InputState{}, kDt);
check(b.complete(), "entering the case completes the ritual");
check(count_events(game, EventType::BlackoutComplete) == 1,
"completion event emitted");
check(game.skill_system.fluorescent_unlocked,
"completion unlocks the FLUORESCENT skill");
// Re-entering the screen after completion does nothing.
game.player.pos = b.screen_pos();
game.update(InputState{}, kDt);
check(!b.active(), "the ritual cannot be restarted after completion");
// Floor jump / reset make it claimable again, but the unlock persists.
game.blackout.reset();
check(!b.complete() && b.answered() == 0, "reset clears puzzle progress");
if (failed) return 1;
std::printf("blackout ritual: all checks passed\n");
return 0;
}