Commit Graph

584 Commits

Author SHA1 Message Date
Z. Cliffe Schreuders
a8c4f6576f Enhance standalone mode with VM IP handling and UI updates
- Updated `GamesController` to parse and store VM IPs from JSON input, improving player state management.
- Modified `Game` model to include VM IPs in the context for better integration with gameplay.
- Enhanced `Mission` model's `vm_object` method to override IPs from the context when available.
- Revamped `new.html.erb` to provide a clearer interface for entering VM IP addresses and flag hints.
- Improved `vm-launcher-minigame.js` to display VM IPs and provide connection instructions in standalone mode.
2025-11-30 00:02:08 +00:00
Z. Cliffe Schreuders
bca619aeac Add Lock Scenario and System Architecture Documentation
- Introduced `LOCK_SCENARIO_GUIDE.md` to provide a comprehensive reference for implementing locks in scenarios, detailing room and object lock configurations, lock types, and quick examples.
- Added `LOCK_SYSTEM_ARCHITECTURE.md` to outline the data flow from scenario definition to server validation, including steps for scenario definition, server bootstrap filtering, client lock checks, and server validation processes.
- Included security notes and references for various lockable object types and items related to the locking system.
2025-11-29 23:46:39 +00:00
Z. Cliffe Schreuders
ef8e2f294a Refactor RFID handling and enhance game logic
- Updated `GamesController` and `Game` model to include RFID lock types in the filtering logic for 'requires' attributes, ensuring proper handling of biometric, bluetooth, and RFID types.
- Improved `RFIDMinigame` to standardize card ID retrieval, supporting both `card_id` and `key_id`.
- Enhanced `unlock-system.js` to prioritize physical keycard checks and streamline the unlocking process with detailed logging.
- Adjusted scenario JSON files to replace `keyId` with `card_id` for consistency and added new lock requirements for various rooms.
2025-11-29 23:43:30 +00:00
Z. Cliffe Schreuders
92330b04dc Enhance flag handling and XML integration for standalone mode
- Updated `GamesController` to support XML flag hints for standalone mode, improving backward compatibility with legacy flag input.
- Introduced `parse_flag_hints_xml` method in `Mission` model to extract flags from XML content.
- Enhanced `Game` model to incorporate `flags_by_vm` from player state for better flag management.
- Modified `new.html.erb` to update UI for flag hints input, replacing the previous comma-separated flags format.
- Improved `FlagStationMinigame` to display accepted VM flags and handle flag submissions more effectively.
- Adjusted scenario JSON to include flag stations with VM-specific flag handling.
2025-11-29 20:57:39 +00:00
Z. Cliffe Schreuders
bb2b0c206e Implement VM object retrieval and enhance game visuals
- Added `vm_object` method in `mission.rb` to fetch VM details from context or return a fallback.
- Introduced new images for VM launchers and flag stations in the assets directory.
- Updated `game.js` to preload new VM launcher and flag station images.
- Refactored `vm-launcher-minigame.js` to streamline VM handling and improve UI messaging.
- Adjusted scenario JSON to utilize the new `vm_object` method for VM data retrieval.
2025-11-29 01:35:20 +00:00
Z. Cliffe Schreuders
ca44cef068 Enhance game setup for VM and standalone modes
- Updated `GamesController` to use `current_player` for VM set retrieval.
- Improved `MissionsController` to handle redirection for both Hacktivity and standalone modes.
- Modified `new.html.erb` to include UI for standalone flag input alongside VM set selection.
- Added new CSS styles for standalone mode instructions and flags input form.
- Introduced new mission configuration for the SecGen VM Lab, integrating VM and flag capture elements.
2025-11-28 17:41:17 +00:00
Z. Cliffe Schreuders
0d250d71f0 Refactor game redirection and VM context handling
- Updated `MissionsController` to use explicit paths for redirection to ensure compatibility in engine context.
- Enhanced `Game` model to build VM context conditionally based on mission requirements and Hacktivity mode.
- Adjusted `show.html.erb` to reflect explicit API base paths and improved handling of player state for JSON responses.
2025-11-28 16:28:25 +00:00
Z. Cliffe Schreuders
ea079b11c9 WiP implementing VM integration 2025-11-28 15:36:10 +00:00
Z. Cliffe Schreuders
3a64ffe8f1 Finalize implementation plan for VM and CTF Flag Integration following Review 4
- Updated last modified date and added new review document reference.
- Added policy methods for `GamePolicy#submit_flag?` and `MissionPolicy#create_game?`.
- Fixed authorization in `games#create` to use `:create_game?` and removed redundant `VmSet` authorization.
- Clarified loading of `hacktivity-cable.js` with CSP nonce.
- Included fallback for non-Hacktivity mode in VM set validation.
- Documented minor amendments and verification checklist for implementation readiness.
2025-11-28 15:00:13 +00:00
Z. Cliffe Schreuders
0c25124967 feat: Update VM console integration to use ActionCable for async file delivery 2025-11-28 14:23:39 +00:00
Z. Cliffe Schreuders
752fb2c4f9 Implement Review 3 updates for VM and CTF Flag Integration
- Added detailed review documentation for Hacktivity compatibility.
- Addressed critical issue: implemented missing `games#create` action in GamesController.
- Updated `MissionsController#show` to handle VM-required missions differently.
- Clarified deployment order for migration to remove unique index.
- Added recommendations for strong parameters in `games#create`.
- Documented necessary changes for flag submission and VM set display.
- Verified compatibility of model structures and updated flag submission logic.
2025-11-28 14:00:27 +00:00
Z. Cliffe Schreuders
dd720130c7 update plans 2025-11-27 23:44:51 +00:00
Z. Cliffe Schreuders
a3690b6a68 Implementation plan for VMs 2025-11-27 23:28:44 +00:00
Z. Cliffe Schreuders
ddbe707182 feat: Update project overview and deployment modes in AI coding agent instructions 2025-11-26 23:02:51 +00:00
Z. Cliffe Schreuders
613ac6d4e7 feat: Update license information to AGPL v3 and clarify in README 2025-11-26 22:47:50 +00:00
Z. Cliffe Schreuders
f412d9ba25 feat: Add comprehensive Objectives and Tasks Guide with examples and best practices 2025-11-26 22:42:19 +00:00
Z. Cliffe Schreuders
f4aef2a561 feat: Improve NPC dialogue and objectives handling with global variable synchronization and task unlocking 2025-11-26 14:49:30 +00:00
Z. Cliffe Schreuders
9aaec1a970 feat: Enhance NPC dialogue and objectives system with event mappings for secret mission completion 2025-11-26 13:02:55 +00:00
Z. Cliffe Schreuders
6b1d73f987 feat: Enhance objectives system with new NPC interactions and Ink dialogue integration 2025-11-26 11:18:25 +00:00
Z. Cliffe Schreuders
412cebb65c feat: Add objectives system with policy methods and test scenarios 2025-11-26 09:43:06 +00:00
Z. Cliffe Schreuders
9d6d7709c3 feat: Implement Objectives System with UI and Server Sync
- Added ObjectivesManager to track mission objectives and tasks.
- Created ObjectivesPanel for displaying objectives in a collapsible HUD.
- Integrated objectives state restoration from the server during game initialization.
- Implemented task completion and unlocking mechanisms via game actions.
- Added CSS styles for the objectives panel with a pixel-art aesthetic.
- Developed a test scenario to validate the objectives system functionality.
- Updated database schema to include fields for tracking completed objectives and tasks.
2025-11-26 00:50:32 +00:00
Z. Cliffe Schreuders
150518b4c4 feat: Include objectives state in server response and implement event emissions for door unlocks and key pickups 2025-11-25 23:19:11 +00:00
Z. Cliffe Schreuders
575dc9aad0 Add updated TODO checklist and corrected code snippets for objectives system
- Created an updated TODO checklist outlining phases and tasks for the objectives system implementation.
- Added corrected code snippets for critical fixes, including door unlock event emission and key pickup event handling.
- Documented necessary changes to ensure proper event emissions for objectives tracking.
- Reviewed and approved the implementation plan with minor corrections regarding door unlock events.
2025-11-25 23:13:58 +00:00
Z. Cliffe Schreuders
26fc297ad8 Refactor tests and improve NPC handling
- Updated NPC ink loading tests to ensure proper handling of missing story files.
- Adjusted lazy loading tests for rooms to enhance clarity and maintainability.
- Enhanced unlock system tests by adding inventory checks for keys.
- Refined filtered scenario tests to ensure accurate preservation of game state.
- Improved game model tests to validate unlock functionality with various inventory scenarios.
2025-11-25 16:28:18 +00:00
Z. Cliffe Schreuders
b317103c83 fix: Update CI test command and adjust RuboCop configuration for string literals 2025-11-25 16:14:46 +00:00
Z. Cliffe Schreuders
6d06a33a07 Add rubocop-rails-omakase to Gemfile for CI linting
The CI workflow was failing because rubocop was not available in the bundle.
Adding rubocop-rails-omakase which provides the omakase Ruby styling rules
that are configured in .rubocop.yml.
2025-11-25 16:07:05 +00:00
Z. Cliffe Schreuders
50e262c15d Fix GitHub CI configuration for Rails engine
- Fix test command syntax: change 'bin/rails db:test:prepare test' to 'bin/rails test:prepare'
- Remove unnecessary dependencies: google-chrome-stable, curl, libjemalloc2, libvips
- Remove unused screenshot upload step (no system tests)
- Remove commented Redis service configuration
- Simplify to only install sqlite3 for testing
2025-11-25 16:07:05 +00:00
Z. Cliffe Schreuders
659644b3da feat: Update CyBOK logo and enhance mission index styles with new CSS files 2025-11-25 16:03:09 +00:00
Z. Cliffe Schreuders
3cc9fafcec feat: Enhance mission management with CyBOK integration and collection filtering
- Added `Cybok` model to manage CyBOK entries associated with missions.
- Implemented `by_collection` scope in `Mission` model for filtering missions by collection.
- Updated `missions_controller` to filter missions based on the selected collection.
- Introduced `CybokSyncService` for syncing CyBOK data from mission metadata to the database.
- Created new views and partials for displaying CyBOK information with tooltips using Tippy.js.
- Added metadata fields to `break_escape_missions` for `secgen_scenario` and `collection`.
- Enhanced mission seeding logic to support new metadata and CyBOK entries.
- Added multiple new mission scenarios with associated metadata.
2025-11-25 15:20:05 +00:00
Z. Cliffe Schreuders
797b075cbe feat: Add mission metadata and CyBOK integration with JSON schema and example files 2025-11-25 14:59:57 +00:00
Z. Cliffe Schreuders
9cad11a853 fix: Correct key pin values for CEO office key to ensure proper unlocking 2025-11-25 14:59:49 +00:00
Z. Cliffe Schreuders
0d7ba1f2fc feat: Enhance key selection process by storing original inventory keys and correct key ID for retries 2025-11-24 13:52:07 +00:00
Z. Cliffe Schreuders
5ecfa5db27 feat: Implement KeyCutCalculator utility for consistent key cut depth calculations across the game
refactor: Update key-lock system and minigame starters to utilize KeyCutCalculator for cut depth generation
chore: Normalize keyPins in scenario data to align with new cut depth calculations
2025-11-24 13:41:35 +00:00
Z. Cliffe Schreuders
96cec569f7 Add tests for door unlock mechanics using keys and lockpicks
- Implemented tests to validate unlocking doors with the correct key in inventory.
- Added tests to ensure doors cannot be unlocked without the required key.
- Included scenarios for using lockpicks to unlock doors, bypassing key requirements.
- Ensured that keys take precedence over lockpick attempts when both are available.
- Added checks for accessing unlocked doors regardless of the unlocking method.
- Created helper tests to verify the presence of keys and lockpicks in the player's inventory.
2025-11-24 11:19:45 +00:00
Z. Cliffe Schreuders
b4b95928da feat: Enhance inventory management with server-side validation and CSRF protection 2025-11-24 11:17:39 +00:00
Z. Cliffe Schreuders
7efb758087 refactor: Simplify NPC dialogue structure and remove unnecessary speaker tags for improved readability 2025-11-24 10:20:05 +00:00
Z. Cliffe Schreuders
2c8757de3e Add character registry and NPC management features
- Implemented a global character registry to manage player and NPC data.
- Added methods for setting the player, registering NPCs, and retrieving character information.
- Integrated character registry updates into the NPC manager for seamless NPC registration.
- Created test scenarios for line prefix speaker format, including narrator modes and background changes.
- Developed comprehensive NPC sprite test scenario with various NPC interactions and items.
2025-11-24 02:21:31 +00:00
Z. Cliffe Schreuders
48e7860e0f Add comprehensive review and implementation plan for line prefix speaker format
- Created COMPREHENSIVE_REVIEW.md detailing architecture, risk assessment, and recommendations for the line prefix speaker format implementation.
- Developed README.md summarizing the implementation plan assessment, key findings, and integration of the Background[] feature.
- Included detailed risk assessment, updated timeline estimates, and success criteria for the implementation.
- Recommended enhancements for security, performance, reliability, and deployment strategies.
- Established a phased approach for implementation with clear priorities and next steps for the team and content creators.
2025-11-24 00:07:38 +00:00
Z. Cliffe Schreuders
843879cd62 feat: Enhance NPC chat system with narrator character support, default speaker behavior, and improved NPC behavior tags
- Implemented narrator syntax to display character portraits during narration.
- Changed default speaker behavior to default to the main NPC for unprefixed lines.
- Enhanced NPC behavior tags to support no parameters, comma-separated lists, wildcard patterns, and an "all" keyword.
- Added comprehensive testing requirements for narrator, default speaker, and NPC behavior tags.
- Updated documentation to reflect new features and usage examples.
- Addressed critical and high-priority issues from REVIEW1, including function naming conflicts, regex security, and empty dialogue validation.
- Improved code organization and backward compatibility.
2025-11-23 22:52:20 +00:00
Z. Cliffe Schreuders
5a997e38f7 Enhance NPC collision detection: add checks for table objects in NPC behavior and log successful collisions for better debugging. 2025-11-23 10:39:44 +00:00
Z. Cliffe Schreuders
59f096fdba Add wall escape functionality for NPCs: implement checks and escape logic for NPCs stuck in walls, enhancing collision handling and movement responsiveness. 2025-11-23 01:46:04 +00:00
Z. Cliffe Schreuders
98104b59a8 Enhance NPC behavior: implement home return functionality for stationary NPCs when pushed away from their starting position 2025-11-23 01:27:20 +00:00
Z. Cliffe Schreuders
279cc0125d Fix avatar URL resolution in contact list: ensure full URL is used for non-relative avatar paths 2025-11-22 13:59:21 +00:00
Z. Cliffe Schreuders
140def5650 Add Spotify play button and styles for improved music integration 2025-11-22 01:54:00 +00:00
Z. Cliffe Schreuders
f8bdb73a06 Improve door and unlock interaction handling: deactivate door sprites immediately upon opening, clean up interaction indicators, and ensure proper checks for inactive or destroyed doors. 2025-11-22 01:37:41 +00:00
Z. Cliffe Schreuders
83055f7589 Cancel click-to-move when keyboard input is detected to improve player control responsiveness 2025-11-22 01:30:44 +00:00
Z. Cliffe Schreuders
ac727f4422 Enhance unlock functionality: refactor door unlocking to async, validate NPC permissions via server, and ensure player state integrity 2025-11-22 01:25:36 +00:00
Z. Cliffe Schreuders
ef27265c8c Simplify NPC unlock to use standard unlock flow
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
2025-11-22 00:46:56 +00:00
Z. Cliffe Schreuders
a36c0da04e Fix test errors and add route name for room endpoint
- Added 'as: room' to room route to fix room_game_url helper
- Fixed TypeError in initialize_player_state by using .dup instead of .deep_dup
- Simplified npcUnlockedTargets initialization test to avoid edge case
- All 38 tests now passing with 129 assertions
2025-11-22 00:46:56 +00:00
Z. Cliffe Schreuders
c5eca9cc60 Fix NPC unlock race condition with persistent server-side tracking
PROBLEM:
NPC unlocks had timing-dependent behavior:
- If NPC unlocked door BEFORE room loaded: client saw it as unlocked
- If NPC unlocked door AFTER room loaded: door sprite stayed locked

SOLUTION:
1. Server-side persistent tracking:
   - Added npcUnlockedTargets array to player_state
   - Track all NPC unlocks separately from unlockedRooms/unlockedObjects
   - Initialize npcUnlockedTargets in new games

2. Server merges NPC unlock state:
   - filtered_room_data checks npcUnlockedTargets
   - Marks doors/containers as unlocked if NPC unlocked them
   - Works regardless of when room is loaded

3. Client updates existing sprites:
   - NPC unlock handler finds ALL door sprites for target room
   - Updates sprite state immediately after server unlock
   - Handles both pre-loaded and late-loaded rooms

Changes:
- app/models/break_escape/game.rb: Add npc_unlock_target!, npc_unlocked?, merge state in filtered_room_data
- app/controllers/break_escape/games_controller.rb: Track NPC unlocks in unlock endpoint
- public/break_escape/js/minigames/person-chat/person-chat-conversation.js: Update all door sprites after NPC unlock
- public/break_escape/js/systems/doors.js: Export unlockDoor globally
- test/integration/unlock_system_test.rb: Add 4 tests for persistent NPC unlock state
2025-11-22 00:46:56 +00:00