mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-21 19:28:03 +00:00
PROBLEM: Previous implementation had unnecessary complexity with npcUnlockedTargets tracking. NPC unlocks should just work like any other unlock method. SOLUTION: 1. Removed npcUnlockedTargets tracking (not needed) 2. NPC unlocks now use standard unlockedRooms/unlockedObjects arrays 3. Updated validate_unlock to check if already unlocked FIRST: - If in player_state unlocked list → grant access - If method='unlocked' → verify against scenario data locked field - Otherwise → validate normally This fixes the race condition issue: - NPC calls unlock API with method='npc' - Server validates NPC has permission - Server adds to unlockedRooms (normal unlock) - Later when player opens door, client sends method='unlocked' - Server sees it's already in unlockedRooms OR unlocked in scenario → grants access Changes: - app/models/break_escape/game.rb: Remove npc_unlock_target!/npc_unlocked?, check unlocked state first - app/controllers/break_escape/games_controller.rb: Remove npc_unlock_target! calls - test/integration/unlock_system_test.rb: Update tests for simplified approach All 37 tests passing, 122 assertions