Commit Graph

403 Commits

Author SHA1 Message Date
Claude
ae78cdac47 feat: Add educational tool help files for security tools
Create comprehensive Ink dialogue files for five security tools:
- Kali Linux: Overview and getting started guide
- nmap: Port scanning and network discovery
- Metasploit: Finding and running exploits
- chmod: File permissions and usage
- nikto: Web vulnerability scanning

Each file provides interactive educational content with:
- Multiple topic branches for different aspects
- Practical examples and use cases
- Step-by-step instructions
- Security and ethical usage reminders
- Navigation between related topics

These files can be included in game scenarios to provide
contextual help to players learning security tools.
2025-11-18 10:50:00 +00:00
Z. Cliffe Schreuders
04a85f36cf refactor: Add three-tier variable persistence system to NPC conversation files
Updated all three ongoing conversation files (Netherton, Chen, Haxolottle) with
clear PERSISTENT/GLOBAL/LOCAL variable annotations and proper scoping:

PERSISTENT variables:
- Save/load between game sessions
- Use scoped naming (npc_netherton_*, npc_chen_*, npc_haxolottle_*)
- Include all relationship stats, discussed topics, and special moments

GLOBAL variables:
- Session-only, span across NPCs
- total_missions_completed (replaces sequential mission tracking)
- professional_reputation

LOCAL variables:
- Conversation-specific EXTERNAL variables
- player_name, current_mission_id

This enables order-independent mission completion while maintaining
persistent conversation state across game sessions.
2025-11-18 10:36:09 +00:00
Z. Cliffe Schreuders
88b4722a81 feat: Add ongoing conversation systems for Netherton and Dr. Chen
Implement comprehensive drip-fed dialogue systems for building long-term
relationships with Director Netherton and Dr. Chen (Tech Support).

Netherton system (1625 lines):
- Formal, by-the-book personality that gradually reveals care
- 4 phases spanning missions 1-16+
- Phase 1: Establishing standards (handbook, leadership, history)
- Phase 2: Growing respect (difficult decisions, politics, field vs command)
- Phase 3: Earned respect (weight of command, agent losses, ethics)
- Phase 4: Deep trust (legacy, trust discussion, beyond protocol)
- Tracks netherton_respect variable (0-100)
- 16 conversation topics exploring leadership burden and moral complexity

Dr. Chen system (1786 lines):
- Enthusiastic, rapid-fire technical personality
- Collaborative research partnership approach
- 4 phases spanning missions 1-16+
- Phase 1: Professional support (tech philosophy, ENTROPY analysis)
- Phase 2: Growing collaboration (experimental tech, ethics, field shadowing)
- Phase 3: Deep collaboration (dream projects, tech risks, mentorship)
- Phase 4: True partnership (shared vision, friendship, collaborative legacy)
- Tracks chen_rapport and tech_collaboration variables
- 16 conversation topics exploring innovation and partnership

Both systems use:
- Inline speaker format ("Netherton:", "Dr. Chen:", "You:")
- Mission-gated progression with dual requirements (missions + relationship level)
- Boolean topic flags to prevent repetition
- Multiple choice branches for player agency
- Gradual relationship development from professional to personal
- EXTERNAL variables for game integration
- #exit_conversation tags for dialogue closure

These complement the existing Haxolottle friendship system to create
a rich NPC relationship network with distinct personalities.
2025-11-18 10:36:09 +00:00
Z. Cliffe Schreuders
582b7be2e1 refactor: Convert ink dialogue to inline speaker prefix format
Convert all ink files from #speaker: tag format to inline speaker prefixes:
- "Narrator: " for narration/descriptions
- "Netherton: " for Director Netherton dialogue
- "Haxolottle: " for Agent 0x99 dialogue
- "Dr. Chen: " for Dr. Chen dialogue

Changes:
- agent_0x00_cyber_division_intro.ink: Multi-character scene with Netherton and Haxolottle
- haxolottle_ongoing_conversations.ink: Single-NPC conversations (Phases 1-2)
- haxolottle_ongoing_conversations_advanced.ink: Single-NPC conversations (Phases 3-4)
- lore_exploration_hub.ink: Conversations with multiple possible NPCs

Preserves all functional tags (#exit_conversation, etc.)
Follows Break Escape ink best practices for speaker attribution
2025-11-18 10:36:09 +00:00
Z. Cliffe Schreuders
845cd662ca feat: Add ongoing friendship conversation system with Haxolottle and Protocol 47-Alpha
- Add haxolottle_ongoing_conversations.ink: Phases 1-2 conversations (Missions 1-10)
  * Phase 1 (Missions 1-5): Getting to know you - hobbies, interests, axolotl deep dive
  * Phase 2 (Missions 6-10): Deepening connection - philosophy, handler life, field nostalgia
  * Tracks friendship_level (0-100) and conversation topics
  * Personal conversations within identity protection constraints

- Add haxolottle_ongoing_conversations_advanced.ink: Phases 3-4 conversations (Missions 11+)
  * Phase 3 (Missions 11-15): Genuine friendship - fears, meaning, vulnerability
  * Phase 4 (Missions 16+): Deep bond - identity burden, name temptation, explicit friendship
  * Special high-friendship events: personal loss story, secret hobby reveal
  * Deepest emotional moments respecting Protocol 47-Alpha

- Add ONGOING_CONVERSATIONS_README.md: Comprehensive documentation
  * Progression system: mission-based and friendship-based gating
  * 20+ unique conversation topics across 4 phases
  * Integration guide for adding to missions
  * Protocol 47-Alpha guidelines (what can/can't be shared)
  * Character voice guidelines and writing templates
  * Emotional arcs and narrative impact discussion

- Update rules_of_engagement.md: Add Protocol 47-Alpha identity protection rules
  * Protocol 47-Alpha: Agents cannot reveal real identities to each other
  * Regulation 847: Personal sharing encouraged within identity constraints
  * Protocol 180: Specific guidance on what information can be shared
  * Section 19, Clause 11: Friendships acceptable within security protocols
  * Balances operational security with psychological wellbeing

System Features:
- Drip-fed content across 15+ missions for long-term investment
- Genuine friendship despite never knowing real names
- Explores emotional cost of secrecy and hidden identities
- Progressive unlock system prevents rushing content
- Multiple tracking variables (trust_moments, vulnerable_moments, etc.)
- Hub-based conversation pattern with branching choices
- Player agency over engagement depth
- Constraint (Protocol 47-Alpha) becomes part of emotional depth

Conversations respect identity protection while exploring:
- Personal interests (swimming, reading, music, poetry)
- Philosophies and stress management
- Operational experiences and handler life
- Fears, doubts, and emotional struggles
- Meaning of work and future dreams
- The burden of hidden identity
- Temptation to share real names (but choosing not to)
- Explicit acknowledgment of genuine friendship

Designed for authentic emotional progression within spy fiction constraints.
2025-11-18 10:36:09 +00:00
Z. Cliffe Schreuders
7f7ee5d761 feat: Add Agent 0x00 intro cutscene and lore exploration dialogue system
- Add agent_0x00_cyber_division_intro.ink: Introduction cutscene for Agent 0x00 joining SAFETYNET's CYBER-PHYSICAL division
  * Introduces Director Netherton and Agent 0x99 "Haxolottle"
  * Player makes meaningful choices affecting relationships
  * Tracks influence with netherton_respect and haxolottle_trust variables
  * Establishes player_attitude and specialization_interest
  * Multiple branching paths based on player responses

- Add lore_exploration_hub.ink: Reusable dialogue system for exploring ENTROPY and SAFETYNET lore
  * Hub-based conversation pattern with multiple NPCs
  * Tracks influence with handler, tech support, director, and fellow agents
  * Progressive revelation system (deeper topics unlock with higher influence)
  * Covers ENTROPY origins, philosophy, cells, and tactics
  * Covers SAFETYNET mission, methods, shadow war, and field operations
  * Deep lore unlocks: Berlin Crisis, handler backstory, moral complexity
  * Works with different speakers (Haxolottle, Dr. Chen, Director Netherton)
  * Mission-agnostic design for reusability

- Add comprehensive README.md documenting:
  * File purposes and when to use them
  * Variables reference and influence tracking system
  * Character voice guidelines for each NPC
  * Integration examples and usage guidelines
  * Testing checklist and quality standards
  * Future expansion ideas

All dialogue follows established character voices from universe bible and
implements influence-based relationship progression system.
2025-11-18 10:36:08 +00:00
Z. Cliffe Schreuders
147c4af225 feat: Add comprehensive features reference and enhanced Ink scripting guide
Add two critical enhancements to scenario development prompts:

1. FEATURES_REFERENCE.md - Complete game features documentation
   - All available object types (notes, PC, phone, tablet, etc.)
   - All lock types (key, pin, password, bluetooth, rfid, lockpick)
   - NPC system (physical, phone, patrol, event mappings)
   - RFID security protocols (EM4100, MIFARE variants, DESFire)
   - Ink dialogue system with tags and patterns
   - Event system for reactive dialogue
   - Room system and connections
   - Complete examples and best practices
   - Quick reference tables

2. Enhanced 07_ink_scripting.md - Detailed Ink guide with actual structure
   - THREE-ACT STRUCTURE AS ACTUALLY IMPLEMENTED:
     * Act 1: Interactive cutscene (Ink-heavy, 2-5 min, choices)
     * Act 2: Puzzle chain gameplay (game-heavy, 15-40 min, NPC support)
     * Act 3: Resolution and debrief (Ink-heavy, 2-5 min, consequences)
   - Complete templates for opening cutscene with choices
   - NPC dialogue patterns (hub pattern, guards, phone contacts)
   - Closing cutscene with variable callbacks
   - Event-driven dialogue examples
   - Ink tags reference (#speaker, #display, #hostile, etc.)
   - Testing and validation guidance
   - Common errors and solutions

These documents provide the concrete technical details needed for AI agents
to write scenarios with proper features, constraints, and narrative structure.

Based on analysis of existing scenarios:
- scenarios/ceo_exfil.json
- scenarios/test-npc-patrol.json
- scenarios/test-rfid-multiprotocol.json
- scenarios/ink/security-guard.ink
- scenarios/ink/alice-chat.ink
2025-11-18 01:22:08 +00:00
Z. Cliffe Schreuders
fd434762fe feat: Add complete AI prompt system for scenario development (Stages 0-7)
Add comprehensive prompts for all 9 stages of Break Escape scenario development:

- Stage 0: Scenario Initialization - Technical challenges and narrative themes
- Stage 1: Narrative Structure - Three-act story arc development
- Stage 2: Storytelling Elements - Characters, atmosphere, dialogue
- Stage 3: Moral Choices - Player agency and ethical decisions
- Stage 4: Player Objectives - Goals and win conditions
- Stage 5: Room Layout - Physical design with technical constraints
- Stage 6: LORE Fragments - Collectible universe-building content
- Stage 7: Ink Scripting - Interactive dialogue and cutscenes

These prompts guide AI agents (or human designers) through a structured
process to create complete, validated Break Escape scenarios that combine
cybersecurity education with compelling narrative gameplay.

Each prompt includes:
- Role definition and responsibilities
- Required inputs from previous stages
- Essential reference documentation
- Process guidelines and templates
- Quality checklists
- Common pitfalls to avoid
- Tips for success

This completes the story development prompt system alongside the previously
committed README.md and Stage 8 (Review) prompt.
2025-11-18 01:22:08 +00:00
Z. Cliffe Schreuders
4ffb9e2a07 feat: Add scenario review and README for story development prompts
Add comprehensive scenario review and validation prompt (Stage 8) plus
README overview for the story development prompt system.

Note: Files for stages 0-7 need to be recreated - they appear to have
not persisted despite Write tool calls during the session.
2025-11-18 01:22:08 +00:00
Z. Cliffe Schreuders
bbb99cf935 fix: Add teleportation collision boxes for doors to enable bi-directional teleportation 2025-11-17 20:08:07 +00:00
Z. Cliffe Schreuders
56917474fd fix: Add full tile collision boxes above and below side doors for improved player interaction 2025-11-17 19:47:55 +00:00
Z. Cliffe Schreuders
975e9fa069 fix: Update side door dimensions and add collision boxes for east/west connections 2025-11-17 15:53:24 +00:00
Z. Cliffe Schreuders
09cd416d02 fix: Adjust east/west door positioning for consistent alignment and visual display 2025-11-17 15:48:36 +00:00
Z. Cliffe Schreuders
0cf2f0fae3 fix: Standardize east and west door positioning for consistency with north/south doors 2025-11-17 15:40:16 +00:00
Z. Cliffe Schreuders
1947ff3ad4 fix: Adjust door placement to flush with walls for east and west doors 2025-11-17 14:55:29 +00:00
Z. Cliffe Schreuders
d10db55213 feat: Reorganize and expand Break Escape Universe Bible into modular structure
This commit transforms the single universe bible document into a comprehensive,
organized set of reference materials across 74 files in 10 major sections.

Major Changes:
- Split original universe bible into chapter-based documents
- Expanded all content by 50-100% with additional lore and details
- Created modular directory structure for easy navigation
- Added extensive cross-referencing between documents

New Structure:
01. Universe Overview - Setting, premise, and tone
02. Organisations - SAFETYNET and ENTROPY detailed profiles
03. ENTROPY Cells - All 11 cells with expanded operations
04. Characters - SAFETYNET operatives and ENTROPY antagonists
05. World Building - Rules, technology, society, timeline
06. Locations - Environment types and notable locations
07. Narrative Structures - Mission types, arcs, player agency
08. LORE System - Collectibles, progression, writing guides
09. Scenario Design - Framework, templates, and examples
10. Reference - Quick reference, checklists, glossary, style guide

Content Expansions:
- SAFETYNET: 28 Field Operations Handbook rules (from 3)
- ENTROPY Cells: 8 key members per cell (from 4)
- Characters: 8 additional SAFETYNET agents created
- Locations: 7 environment type guides
- Scenario Templates: 4 complete templates + 3 full examples
- LORE System: 220 fragments mapped across 6 categories
- Reference: Comprehensive glossary, checklists, and CyBOK guide

Benefits:
- Easier to find specific information
- Consistent universe across all scenarios
- Supports continuous discovery as players progress
- Comprehensive reference for scenario designers
- Expanded lore enables richer storytelling

Total Documentation: ~500KB across 74 markdown files
2025-11-17 12:41:36 +00:00
Z. Cliffe Schreuders
c3440986a3 fix: Correct side door (E/W) placement, sprites, and animations
This commit fixes several issues with East/West side doors:

1. **Sprite Flipping**: Changed flip direction - East doors are now flipped
   horizontally instead of West doors (opposite direction as requested)

2. **Door Positioning**: Updated E/W door placement from 2 tiles to 3 tiles
   from the top corner for better alignment with room layout

3. **Wall Passage Cutout**: Increased wall tile removal area for side doors
   from 1 tile to 3 tiles vertically, creating a wider passage (matching the
   inset spacing used for N/S doors)

4. **Side Door Animation**:
   - Added `isSideDoor` property to doorProperties to track door type
   - Created new 'door_side_open' animation using frames 1-4 (frames 2-5
     in 1-indexed notation) of door_side_sheet_32 sprite
   - Updated animated door creation to use side door sprite and animation
     for E/W doors

5. **Sprite Alignment**: Door sprites now properly align with the tile grid
   at 3 tiles from corner position

Changes made in:
- js/systems/doors.js: Door placement, sprite creation, and animations
- js/systems/collision.js: Wall tile removal for wider passages
- js/core/game.js: Side door animation definition

Tested with: scenarios/test_horizontal_layout.json
2025-11-17 12:28:19 +00:00
Z. Cliffe Schreuders
aef6e97df0 fix: Update item spawn positioning to respect room GU boundaries and padding
- Modified createSpriteAtRandomPosition() to accept map parameter
- Items now use actual room dimensions based on tilemap (respects room GU)
- Applied correct padding constraints:
  * 1 tile (32px) from left and right sides
  * 2 tiles (64px) from top and bottom
- Random item placement now works correctly with variable room sizes
- Ensures items stay within playable room bounds

Related to new room layout system (Grid Unit based positioning)
2025-11-17 11:19:43 +00:00
Z. Cliffe Schreuders
150e3a6d43 fix: Ensure each connecting room has minimum 1 GU overlap with parent
Updated room positioning to verify overlap for EACH connected room
after grid alignment, not just the group as a whole. This fixes
layouts like:

  122
  00

Where room 1 was previously positioned with no overlap to room 0.

Changes:
- positionNorthMultiple/positionSouthMultiple: After centering and
  aligning group, check first and last room overlap. If insufficient,
  shift entire group to ensure minimum overlap for each room.
- positionEastMultiple/positionWestMultiple: Same approach for
  vertical stacking along east/west edges.

The algorithm now:
1. Centers the group of connecting rooms over parent
2. Aligns starting position to grid
3. Checks if first room has >= 1 GU overlap, adjusts if not
4. Checks if last room has >= 1 GU overlap, adjusts if not
5. Positions all rooms from the adjusted aligned start

This guarantees each connecting room overlaps with the parent room
by at least one Grid Unit, ensuring proper door placement and room
connectivity.
2025-11-17 11:04:52 +00:00
Z. Cliffe Schreuders
0442139236 fix: Align connecting rooms to grid with minimum 1 GU overlap
Updated room positioning algorithm to ensure all connecting rooms are
properly aligned to the grid and have at least one Grid Unit overlap
with the connecting edge of the parent room.

Changes:
- positionNorthMultiple/positionSouthMultiple: Position rooms as a group,
  align the starting position to grid, then place rooms side-by-side
  without individual alignment to prevent gaps
- positionEastMultiple/positionWestMultiple: Similar approach for vertical
  stacking of rooms along east/west edges

This ensures:
- All rooms maintain proper grid alignment
- Connected rooms have guaranteed minimum overlap
- No gaps between adjacent rooms in multi-room connections
- Room layouts match the examples in planning notes

Addresses alignment issues described in new_room_layout documentation
where rooms need to be positioned against the connecting edge with
at least one GU overlap.
2025-11-17 11:04:52 +00:00
Z. Cliffe Schreuders
5f64e728ba Universe & Scenario Design Guide 2025-11-17 10:27:09 +00:00
Z. Cliffe Schreuders
302449d8e1 fix: Resolve room layout issues for mixed sizes and east/west doors
This commit addresses three critical issues identified during testing:

1. **Fixed mixed room size door alignment (Issue #1)**
   - Updated room positioning logic in positionNorthMultiple, positionSouthMultiple,
     positionEastMultiple, and positionWestMultiple functions
   - Rooms are now positioned centered on their corresponding door positions
   - Ensures doors align properly between different-sized rooms (e.g., 1×1 GU closet
     connecting to 2×1 GU hallway)
   - Uses same door spacing logic as door placement (edgeInset + doorSpacing)

2. **Implemented East/West single-tile doors (Issue #2)**
   - Changed door_side_sheet_32 from image to spritesheet (6 frames, 32×32px each)
   - Updated door sprite creation to use single tile per room for east/west doors
   - West-facing doors (left room) now properly flip horizontally
   - Doors positioned 3 tiles down from top (TILE_SIZE * 2) as specified
   - Updated wall tile removal and animated door creation to use correct dimensions
   - Both sides of east/west connections now use matching door system

3. **Added connection limit validation (Issue #3)**
   - Created validateMultipleConnections function to check if connections fit
   - Validates that multiple connections won't cause rooms to overhang excessively
   - Logs detailed error messages with recommendations when connections don't fit
   - Example: 2GU room can't have 3 north connections (not enough width)
   - Helps developers identify invalid room layouts during scenario design

Files modified:
- js/core/game.js: Load door_side_sheet_32 as spritesheet
- js/core/rooms.js: Fix positioning, add validation
- js/systems/doors.js: Single-tile east/west doors with flipping
- js/systems/collision.js: Update wall tile removal for single-tile doors
2025-11-17 08:49:50 +00:00
Z. Cliffe Schreuders
d92a8a5f18 fix: Correct room type keys in test scenarios and add new room types to preload
Fixed issue where test scenarios couldn't load rooms:

1. Added new room types to game preload:
   - small_room_1x1gu (1×1 GU closet)
   - hall_1x2gu (2×1 GU wide hallway)

2. Corrected room type keys in all test scenarios:
   - room_reception2 → room_reception
   - room_office2 → room_office
   - room_ceo2 → room_ceo
   - room_servers2 → room_servers

The issue was that scenarios referenced room file names (room_reception2)
instead of the Phaser cache keys (room_reception). The game preloads rooms
with specific keys that map to the JSON files:
  this.load.tilemapTiledJSON('room_reception', 'assets/rooms/room_reception2.json')

Scenarios must use the key ('room_reception'), not the filename.

Files updated:
- js/core/game.js: Added preload for new variable-sized rooms
- scenarios/test_vertical_layout.json
- scenarios/test_horizontal_layout.json
- scenarios/test_complex_multidirection.json
- scenarios/test_multiple_connections.json
- scenarios/test_mixed_room_sizes.json

All test scenarios should now load correctly.
2025-11-17 08:49:50 +00:00
Z. Cliffe Schreuders
d21084f6cf feat: Update mixed room sizes test scenario with actual variable-sized rooms
Updated test_mixed_room_sizes.json to use the new room files merged from main:
- Changed hall from placeholder to hall_1x2gu.json (2×1 GU - 10×6 tiles)
- Changed closet from placeholder to small_room_1x1gu.json (1×1 GU - 5×6 tiles)
- Updated all scenario text to reflect actual room dimensions
- Corrected layout diagram (hall is 2×1 GU wide hallway, not 1×2 GU vertical)

Updated TEST_SCENARIOS_README.md:
- Marked small_room_1x1gu.json and hall_1x2gu.json as available (✓)
- Updated scenario #5 description with actual rooms used
- Clarified that this scenario now demonstrates real size variety

This scenario now provides a complete test of the grid system with:
- 1×1 GU closet (smallest valid room)
- 2×1 GU wide hallway (horizontal connector)
- 2×2 GU standard rooms (reception, CEO office)
- Proper door alignment between all different sizes
2025-11-17 08:49:50 +00:00
Z. Cliffe Schreuders
e9eb9d96c8 docs: Update room layout documentation and add comprehensive test scenarios
Updated README_scenario_design.md with new grid-based room layout system:
- Documented Grid Unit (GU) system: 5×4 tiles base unit
- Added valid room size specifications (widths: multiples of 5, heights: 2+4N)
- Replaced old north/south-only constraints with four-direction support
- Updated door placement rules for N/S/E/W connections
- Added room positioning algorithm documentation
- Revised scenario design guidelines for grid system flexibility

Created 5 comprehensive test scenarios:
1. test_vertical_layout.json - Traditional N/S stacking
2. test_horizontal_layout.json - E/W connections
3. test_complex_multidirection.json - All four directions
4. test_multiple_connections.json - Multiple doors per direction
5. test_mixed_room_sizes.json - Different room sizes (1×1, 1×2, 2×2 GU)

Added TEST_SCENARIOS_README.md documenting:
- Grid system overview and room size specifications
- Detailed test scenario descriptions with layout diagrams
- Testing procedures and validation checks
- Expected console output examples
- Troubleshooting guide

Note: Scenarios reference hall_1x2gu.json and small_room_1x1gu.json which
need to be created in assets/rooms/. Currently using 2×2 GU placeholders.

All test scenarios include:
- Visual layout diagrams in scenario_brief
- Progressive difficulty with locks and keys
- Documentation of what each scenario tests
- Notes explaining grid system concepts
2025-11-17 08:49:50 +00:00
Z. Cliffe Schreuders
8ea391eab8 Add hall and small rooms 2025-11-16 10:20:00 +00:00
Z. Cliffe Schreuders
7cec8b2e17 feat(validation): Add comprehensive room layout validation system
- Add validateRoomSize() to check room dimensions match grid units
- Add validateGridAlignment() to verify positions align to grid
- Add validateNoOverlaps() to detect room collisions
- Add validateRoomLayout() as main validation entry point
- Integrate validation into calculateRoomPositions (Phase 5)
- Store roomPositions globally for cross-system access
- Log validation errors/warnings but don't block game load

Validation checks:
✓ Room width is multiple of 5 tiles (grid unit)
✓ Room stacking height is multiple of 4 tiles (grid unit)
✓ Room positions align to 160px × 128px grid
✓ No rooms overlap (AABB collision detection)

Warnings: Room size mismatches (for backwards compatibility)
Errors: Grid misalignment, overlaps (critical issues)
2025-11-16 08:45:06 +00:00
Z. Cliffe Schreuders
0325412342 refactor(collision): Use shared door placement logic in removeTilesUnderDoor
- Export calculateDoorPositionsForRoom from doors.js for reuse
- Import and use shared function in collision.js
- Remove duplicate door positioning logic (130+ lines)
- Ensures perfect alignment between door sprites and wall tile removal
- Both systems now use identical door placement calculations

This eliminates code duplication and guarantees that wall tiles are
removed at exactly the same positions where door sprites are created.
2025-11-16 08:45:06 +00:00
Z. Cliffe Schreuders
2e62a4e62b feat(room-layout): Implement new grid-based room layout system with critical bug fixes
- Add grid unit constants (5x4 tiles) to constants.js
- Create comprehensive grid conversion helper functions
- Implement 4-direction room positioning (N/S/E/W) with breadth-first algorithm
- Add door placement functions with CRITICAL fixes:
  * Negative modulo fix: ((sum % 2) + 2) % 2 for deterministic placement
  * Asymmetric alignment fix: single-door rooms align with multi-door rooms
  * Consistent grid alignment using Math.floor() for negative coordinates
- Rewrite calculateRoomPositions to support variable room sizes
- Update createDoorSpritesForRoom to use new placement system
- Store room dimensions globally for cross-system access

This implements the comprehensive room layout redesign as specified in
planning_notes/new_room_layout with all critical fixes from review2.

Addresses: Variable room sizes, proper door alignment, and grid-based positioning
2025-11-16 08:45:06 +00:00
Z. Cliffe Schreuders
57d9b8f5d8 docs: Remove critical action required for room dimension audit from implementation plan -- these are older rooms replaced by 2.0 rooms 2025-11-16 02:17:39 +00:00
Z. Cliffe Schreuders
128727536e docs: Complete comprehensive review2 of room layout plans with critical bug fixes
Performed detailed validation of room layout implementation plans against
ceo_exfil.json scenario, identifying and fixing 3 critical bugs that would
have caused implementation failure.

## Critical Bugs Fixed

1. **Negative Modulo Bug** (CRITICAL)
   - JavaScript modulo with negatives: -5 % 2 = -1 (not 1)
   - Affected all rooms with negative grid coordinates
   - Fixed: Use ((sum % 2) + 2) % 2 for deterministic placement
   - Applied to all door placement functions (N/S/E/W)

2. **Asymmetric Door Alignment Bug** (CRITICAL)
   - Single-door rooms connecting to multi-door rooms misaligned
   - Example: office1 (2 doors) ↔ office2 (1 door) = 64px misalignment
   - Fixed: Check connected room's connection array and align precisely
   - Applied to all 4 directions with index-based alignment

3. **Grid Rounding Ambiguity** (CRITICAL)
   - Math.round(-0.5) has implementation-dependent behavior
   - Fixed: Use Math.floor() consistently for grid alignment
   - Applied to all positioning functions

## Scenario Validation

- Traced ceo_exfil.json step-by-step through positioning algorithm
- Simulated door placements for all rooms
- Verified office1↔office2/office3 connections (key test case)
- Result: Would fail without fixes, will succeed with fixes

## Documents Updated

- DOOR_PLACEMENT.md: Added asymmetric alignment + negative modulo fix
- POSITIONING_ALGORITHM.md: Changed Math.round() to Math.floor()
- GRID_SYSTEM.md: Added grid alignment rounding clarification
- README.md: Updated critical fixes status, added Phase 0

## Review Documents Created

- review2/COMPREHENSIVE_REVIEW.md: Full analysis (400+ lines)
- review2/SUMMARY.md: Executive summary and status

## Confidence Assessment

- Before fixes: 40% success probability
- After fixes: 90% success probability

## Status

 Plans are self-contained and actionable
 All critical bugs fixed in specifications
 Validated against real scenario
 Ready for implementation (after Phase 0 audit)

Remaining risk: Room dimension validation (must audit before coding)
2025-11-16 02:13:21 +00:00
Z. Cliffe Schreuders
019986ceef docs: Add comprehensive room layout system redesign plan
Created detailed implementation plan for redesigning the room layout system
to support variable room sizes and four-direction connections.

Core Concepts:
- Grid unit system (5×4 tiles base, excluding 2-tile visual top)
- Valid room heights: 6, 10, 14, 18, 22, 26... (formula: 2 + 4N)
- Breadth-first room positioning from starting room
- Deterministic door placement with alignment for asymmetric connections
- Comprehensive scenario validation

Documents Created:
- OVERVIEW.md: High-level goals and changes
- TERMINOLOGY.md: Definitions and concepts
- GRID_SYSTEM.md: Grid unit system specification
- POSITIONING_ALGORITHM.md: Room positioning logic
- DOOR_PLACEMENT.md: Door placement rules and algorithms
- WALL_SYSTEM.md: Wall collision system updates
- VALIDATION.md: Scenario validation system
- IMPLEMENTATION_STEPS.md: Step-by-step implementation guide
- TODO_LIST.md: Detailed task checklist
- README.md: Quick start and overview

Review & Critical Fixes:
- review1/CRITICAL_REVIEW.md: Identified 4 critical issues
- review1/RECOMMENDATIONS.md: Solutions for all issues
- UPDATED_FILES_SUMMARY.md: Integration of review feedback

Critical Issues Identified & Resolved:
1. Grid height calculation (now: 6, 10, 14, 18...)
2. Door alignment for asymmetric connections (solution documented)
3. Code duplication (shared module approach specified)
4. Disconnected rooms (validation added)

Implementation Strategy:
- Incremental approach with feature flag
- Phase 1: Constants and helpers
- Phase 2a: North/South positioning
- Phase 2b: East/West support
- Phase 3: Door placement with critical fixes
- Phase 4: Validation
- Phase 5-6: Testing and documentation

Estimated time: 18-26 hours
Confidence: 9/10 (all critical issues addressed)

Ready for implementation.
2025-11-15 23:58:19 +00:00
Z. Cliffe Schreuders
32d5bbfab5 fix(chat-helpers): Correctly handle NPC hostility event in game action tags 2025-11-15 23:54:25 +00:00
Z. Cliffe Schreuders
c4622f2dee feat(rfid): Enhance hex generation with improved hash-based approach for realistic card data 2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
ab18e2a5b5 refactor(rfid): Update references from Flipper Zero to RFID Flipper for consistency 2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
08ed220618 Enhance RFID system interactions and NPC conversations
- Updated door sprite creation to support lock properties from both doors and connected rooms.
- Added RFID cloner interaction logic to handle minigame initiation from inventory.
- Implemented inventory variable synchronization for NPC conversations, including RFID card details.
- Introduced new scenarios for RFID guards with varying security levels and interactions.
- Revised test scenarios to include comprehensive RFID protocol testing with detailed notes and NPC interactions.
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
bff4a6a31a docs(rfid): Add corrected scenario patterns and multi-protocol test
Created proper RFID scenario examples following project patterns
(hub structure, #exit_conversation tags, card_id format).

## Issues Found in Existing Files:

### test-rfid.json (Not modified - reference only):
 Uses legacy format (rfid_hex, rfid_facility, key_id)
 All EM4100 - no protocol variety
 Door requires not array format
 No protocol testing variety

### rfid-security-guard.ink (Not modified - reference only):
 Uses -> END instead of #exit_conversation
 Doesn't return to hub after exits
 No proper hub pattern
 Clone tag uses hex instead of card_id

## New Corrected Files:

### 1. scenarios/RFID_SCENARIO_PATTERNS.md (NEW)
Comprehensive guide showing:
-  Correct hub pattern with #exit_conversation
-  Proper card_id JSON format
-  Protocol-specific examples
-  Common mistakes to avoid
- Complete working examples

### 2. scenarios/test-rfid-multiprotocol.json (NEW)
Test scenario with ALL 4 protocols:
- EM4100 (instant clone)
- MIFARE_Classic_Weak_Defaults (dictionary)
- MIFARE_Classic_Custom_Keys (Darkside attack)
- MIFARE_DESFire (UID only)

Features:
- 4 NPCs, each with different protocol
- 4 test rooms demonstrating each security level
- Proper card_id format throughout
- Array-based door requirements
- acceptsUIDOnly flag demonstrated

### 3. scenarios/ink/rfid-security-guard-fixed.ink (NEW)
Fixed version showing:
- Proper hub structure
- #exit_conversation on choice lines
- All paths return to hub
- Card protocol variables declared
- Uses {card_card_id} in clone tags

### 4. scenarios/ink/rfid-guard-low.ink (NEW)
Simple EM4100 example:
- Instant clone pattern
- Proper exit handling
- Minimal complexity for learning

### 5. scenarios/ink/rfid-guard-custom.ink (NEW)
MIFARE Custom Keys example:
- Shows attack requirement
- Player feedback for encrypted cards
- Proper state management

## Key Patterns Documented:

### Correct Ink Pattern:
```ink
+ [Leave] #exit_conversation
  # speaker:npc
  Goodbye!
  -> hub  // Return to hub, NOT END
```

### Correct JSON Pattern:
```json
{
  "type": "keycard",
  "card_id": "employee_badge",
  "rfid_protocol": "EM4100",
  "name": "Employee Badge"
}
```

### Door Configuration:
```json
{
  "lockType": "rfid",
  "requires": ["card1", "card2"],
  "acceptsUIDOnly": false
}
```

## Testing Checklist Added:
- [ ] Uses #exit_conversation tag
- [ ] All knots return to hub
- [ ] Card variables declared
- [ ] Uses card_id format
- [ ] Door requires is array
- [ ] No manual hex entry

## Files Added:
- scenarios/RFID_SCENARIO_PATTERNS.md
- scenarios/test-rfid-multiprotocol.json
- scenarios/ink/rfid-security-guard-fixed.ink
- scenarios/ink/rfid-guard-low.ink
- scenarios/ink/rfid-guard-custom.ink

These serve as reference implementations for scenario designers.
Original files (test-rfid.json, rfid-security-guard.ink) left
unmodified as they may be in use.
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
2a4ee59e4f docs(rfid): Add Ink integration and comprehensive variable documentation
Add Ink integration for RFID card protocols, allowing conversation scripts
to detect and respond to different card security levels and protocols.

## Ink Integration (Phase 5):

### 1. Added syncCardProtocolsToInk() Method
- Location: js/minigames/person-chat/person-chat-conversation.js
- Auto-syncs when syncItemsToInk() is called
- Generates rfid_data if card uses card_id pattern
- Syncs variables for each keycard NPC holds

### 2. Per-Card Variables Synced:
- {prefix}_protocol - Protocol name
- {prefix}_name - Card display name
- {prefix}_card_id - Logical identifier
- {prefix}_security - "low", "medium", "high"
- {prefix}_instant_clone - Boolean (EM4100, weak MIFARE)
- {prefix}_needs_attack - Boolean (custom key MIFARE)
- {prefix}_uid_only - Boolean (DESFire)
- {prefix}_uid - Card UID (MIFARE)
- {prefix}_hex - Card hex ID (EM4100)

### 3. Prefix Pattern:
- First card: card_protocol, card_name, card_card_id, etc.
- Second card: card2_protocol, card2_name, card2_card_id, etc.

## Documentation:

### scenarios/ink/README_RFID_VARIABLES.md (NEW)
Comprehensive guide for scenario designers covering:

1. **Variable Declarations** - Required Ink variable setup
2. **Variable Reference** - Complete table of all variables
3. **Protocol Characteristics** - Details for each of 4 protocols
4. **Usage Examples**:
   - Simple EM4100 clone
   - Multi-protocol detection
   - Conditional dialogue based on protocol
5. **Ink Tags** - Suggested tag patterns for RFID actions
6. **Scenario JSON Format** - How to define keycards
7. **Tips for Scenario Designers** - Best practices
8. **Complete Example Scenario** - Full working Ink script
9. **Troubleshooting** - Common issues and solutions

## Example Ink Usage:

```ink
VAR card_protocol = ""
VAR card_security = ""
VAR card_instant_clone = false

{card_security == "low":
  "This is a low-security card. Easy to clone!"
  # clone_keycard:{card_card_id}
  -> cloned
}

{card_needs_attack:
  "Need to run Darkside attack..."
  # save_uid_and_start_attack:{card_card_id}|{card_uid}
  -> wait_for_attack
}
```

## Benefits:

1. **Scenario designers** can write protocol-aware dialogue
2. **NPCs** can react realistically to card security levels
3. **Players** get different experiences based on card type
4. **Automatic** - no manual variable management needed

## Files Modified:
- js/minigames/person-chat/person-chat-conversation.js
- scenarios/ink/README_RFID_VARIABLES.md (NEW)

## Next Steps:
- Create test scenarios for each protocol
- Add Ink tag handlers for suggested patterns
- Test with various card combinations

Phase 5 (Ink Integration) complete!
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
7ecda9d39d feat(rfid): Implement multi-protocol RFID system with 4 protocols
Implement comprehensive multi-protocol RFID system with deterministic
card_id-based generation, MIFARE key attacks, and protocol-specific UI.

## New Protocol System (4 protocols):
- EM4100 (low security) - Instant clone, already implemented
- MIFARE_Classic_Weak_Defaults (low) - Dictionary attack succeeds (95%)
- MIFARE_Classic_Custom_Keys (medium) - Requires Darkside attack (30s)
- MIFARE_DESFire (high) - UID only, forces physical theft

## Key Features:

### 1. Protocol Foundation
- Created rfid-protocols.js with protocol definitions
- Added protocol detection, capabilities, security levels
- Defined attack durations and common MIFARE keys

### 2. Deterministic Card Generation
- Updated rfid-data.js with card_id-based generation
- Same card_id always produces same hex/UID (deterministic)
- Simplified scenario format - no manual hex/UID needed
- getCardDisplayData() supports all protocols

### 3. MIFARE Attack System
- Created rfid-attacks.js with MIFAREAttackManager
- Dictionary Attack: Instant, 95% success on weak defaults
- Darkside Attack: 30 sec (10s on weak), cracks all keys
- Nested Attack: 10 sec, uses known key to crack rest
- Protocol-aware attack behavior

### 4. UI Enhancements
- Updated rfid-ui.js with protocol-specific displays
- showProtocolInfo() with color-coded security badges
- showAttackProgress() and updateAttackProgress()
- Protocol headers with icons and frequency info
- Updated showCardDataScreen() and showEmulationScreen()

### 5. Unlock System Integration
- Updated unlock-system.js for card_id matching
- Support multiple valid cards per door (array)
- Added acceptsUIDOnly flag for DESFire UID emulation
- Backward compatible with legacy key_id format

### 6. Minigame Integration
- Updated rfid-minigame.js with attack methods
- startKeyAttack() triggers dictionary/darkside/nested
- handleCardTap() and handleEmulate() use card_id arrays
- UID-only emulation validation for DESFire
- Attack manager cleanup on minigame exit

### 7. Styling
- Added CSS for protocol headers and security badges
- Color-coded security levels (red=low, teal=medium, green=high)
- Attack progress styling with smooth transitions
- Dimmed menu items for unlikely attack options

## Scenario Format Changes:

Before (manual technical data):
```json
{
  "type": "keycard",
  "rfid_hex": "01AB34CD56",
  "rfid_facility": 1,
  "key_id": "employee_badge"
}
```

After (simplified with card_id):
```json
{
  "type": "keycard",
  "card_id": "employee_badge",
  "rfid_protocol": "MIFARE_Classic_Weak_Defaults",
  "name": "Employee Badge"
}
```

Technical data (hex/UID) generated automatically from card_id.

## Door Configuration:

Multiple valid cards per door:
```json
{
  "lockType": "rfid",
  "requires": ["employee_badge", "contractor_badge", "master_card"],
  "acceptsUIDOnly": false
}
```

## Files Modified:
- js/minigames/rfid/rfid-protocols.js (NEW)
- js/minigames/rfid/rfid-attacks.js (NEW)
- js/minigames/rfid/rfid-data.js
- js/minigames/rfid/rfid-ui.js
- js/minigames/rfid/rfid-minigame.js
- js/systems/unlock-system.js
- css/rfid-minigame.css
- planning_notes/rfid_keycard/protocols_and_interactions/03_UPDATES_SUMMARY.md (NEW)

## Next Steps:
- Phase 5: Ink integration (syncCardProtocolsToInk)
- Test with scenarios for each protocol
- Add Ink variable documentation

Estimated implementation time: ~12 hours (Phases 1-4 complete)
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
d697eef3ca docs(rfid): Add multi-protocol RFID system planning & review
Created comprehensive planning for adding multiple RFID protocols with
different security levels and attack capabilities.

Planning Documents:
- 00_IMPLEMENTATION_SUMMARY.md: Complete implementation guide (14h estimate)
- 01_TECHNICAL_DESIGN.md: Protocol specs, data models, UI design
- 02_IMPLEMENTATION_PLAN.md: Detailed file-by-file implementation plan
- CRITICAL_REVIEW.md: Pre-implementation review with 12 improvements

Protocol System (Simplified from Original):
 EM4100 (low security) - Instant clone, already implemented
 MIFARE Classic (medium) - Requires key attacks (Darkside/Nested/Dictionary)
 MIFARE DESFire (high) - UID only, forces physical theft
 HID Prox - Removed (too similar to EM4100, saves 2h)

Key Features:
- Protocol detection with color-coded security levels
- MIFARE key cracking minigames (30s Darkside, 10s Nested, instant Dictionary)
- Ink integration for conditional interactions based on card protocol
- Dual format support (no migration needed)
- UID-only emulation for DESFire with acceptsUIDOnly door property

Review Improvements Applied:
- Merged "attack mode" into clone mode (simpler state machine)
- Removed firmware upgrade system (can add later)
- Dual format card data support instead of migration (safer)
- Added error handling for unsupported protocols
- Added cleanup for background attacks
- Documented required Ink variables

Time Estimate: 14 hours (down from 19h)
- Phase 1: Protocol Foundation (3h)
- Phase 2: Protocol Detection & UI (3h)
- Phase 3: MIFARE Attack System (5h)
- Phase 4: Ink Integration (2h)
- Phase 5: Door Integration & Testing (1h)

Next Steps: Begin implementation starting with Phase 1
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
0210a12c64 docs(rfid): Add comprehensive post-implementation review
Added three review documents analyzing the completed RFID system:

- POST_IMPLEMENTATION_REVIEW.md: Full technical analysis of implementation
  - Reviewed 4 core files, 6 integration points, CSS, and test scenario
  - Found 0 critical issues, 2 medium priority improvements (optional)
  - Confirmed production-ready status
  - Verified correct conversation return pattern
  - Validated EM4100 protocol implementation

- ISSUES_SUMMARY.md: Quick reference for identified issues
  - 7 total issues (all minor/optional)
  - Action items with code examples
  - Testing checklist

- README.md: Review overview and quick status

Key findings:
 Clean modular architecture following established patterns
 Authentic Flipper Zero UI with smooth animations
 Robust error handling and validation
 Seamless integration with all game systems
 Comprehensive test scenario created

Recommended improvements (optional):
- Use hex ID for key_id to prevent collisions
- Add cardToClone validation in clone mode
- Extract timing constants for maintainability

Overall assessment: Production ready with minor improvements recommended
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
af11d420e0 fix(rfid): Create proper .ink source file and add compilation instructions
Created proper Ink source file for Security Guard NPC:

Ink Story File:
- Created scenarios/ink/rfid-security-guard.ink (proper Ink format)
- Follows equipment-officer.ink pattern
- Uses # speaker:npc and # speaker:player tags
- Implements hub dialogue structure
- Contains clone_keycard tag: # clone_keycard:Master Keycard|FF4A7B9C21
- Multiple dialogue branches and paths

Story Structure:
- start knot → hub knot
- ask_keycard knot with multiple choices
- cloned knot for post-clone conversation
- Proper conversation flow with END points

Removed:
- Deleted placeholder rfid-security-guard.json (incorrect format)
- JSON must be compiled from .ink source using inklecate or Inky

Updated README:
- Added compilation instructions section
- Option 1: Inky editor (recommended, GUI)
- Option 2: inklecate command line
- Warning that .json needs compilation before use
- Links to download tools

The .ink file is the source of truth and must be compiled to .json
before the scenario will work properly.
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
5d010e98d7 fix(rfid): Update test scenario to match proper JSON format
Fixed test scenario to match reference format from npc-sprite-test2.json:

JSON Format Changes:
- Changed holdsItems → itemsHeld (correct property name)
- Changed storyJSON → storyPath (points to Ink file)
- Added position: { x, y } for NPC placement
- Changed map → type for room definition
- Added connections object for room linking
- Added readable: true to notes objects
- Added observations field to all items
- Added scenario_brief field
- Removed description field from doors

New Ink Story File:
- Created scenarios/ink/rfid-security-guard.json
- Security Guard conversation with clone_keycard tag
- Multiple dialogue branches
- Proper Ink JSON format with content array

NPC Configuration:
- Security Guard at position {x: 6, y: 4}
- Uses hacker-red sprite with idle animation
- Holds Master Keycard in itemsHeld
- References rfid-security-guard.json story
- Starts at 'start' knot

Test scenario now fully compatible with game's scenario loading system.
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
9f26ef0e4f test(rfid): Add comprehensive RFID test scenario
Created complete test scenario to demonstrate all RFID functionality:

Test Scenario Features:
- Two rooms: Test Lobby and Secure Room
- RFID-locked door requiring master keycard
- 3 different keycards with different access levels

Items in Test Lobby:
- Employee Badge (physical keycard, wrong access level)
- Flipper Zero (RFID cloner device)
- Security Notice (instructions)

NPC in Test Lobby:
- Security Guard with Master Keycard in holdsItems
- Conversation includes clone_keycard tag
- Can clone their badge during conversation

RFID-Locked Door:
- Requires master_keycard (guard's badge)
- Employee badge won't work (tests wrong card)
- Must clone and emulate guard's badge

Secure Room Contents:
- Success note (congratulations message)
- CEO Keycard (tests inventory click cloning)

Test Coverage:
✓ Pick up physical keycard and cloner
✓ Try wrong keycard (access denied)
✓ Clone card from NPC conversation (with return)
✓ Save cloned card to Flipper Zero
✓ Emulate saved card to unlock door
✓ Clone card by clicking in inventory
✓ Multiple saved cards management

All hex IDs are valid EM4100 format:
- Employee: 01AB34CD56 (facility 1, card 43981)
- Master: FF4A7B9C21 (facility 255, card 18811)
- CEO: FFAA55CC33 (facility 255, card 43597)

Includes detailed README with test procedure and troubleshooting.
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
f8b20c2db0 feat(rfid): Complete system integration
Integrated RFID minigame into all game systems:

Chat System Integration:
- Added clone_keycard tag handler to chat-helpers.js
- Format: # clone_keycard:Card Name|HEX_ID
- Uses proven window.pendingConversationReturn pattern
- Automatically returns to conversation after cloning

Inventory Integration:
- Added keycard click handler in interactions.js
- Click keycard with cloner → starts clone mode
- Shows alert if no cloner available

Interaction Indicator:
- Added RFID icon support to getInteractionSpriteKey()
- RFID-locked doors/items show rfid-icon overlay
- Works for both door and item lock types

HTML Integration:
- Added rfid-minigame.css link to index.html
- Loaded alongside other minigame styles

Phaser Asset Integration:
- Added keycard sprites (base + 3 variants)
- Added rfid_cloner sprite
- Added rfid-icon and nfc-waves icons
- Loaded in js/core/game.js preload

All integration follows existing patterns from other minigames.
Ready for testing and asset creation.
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
c153b44e34 feat(rfid): Implement core RFID minigame system
Implemented complete RFID keycard lock system with Flipper Zero-inspired interface.

Core Components:
- RFIDDataManager: Card generation, validation, save/load, EM4100 formulas
- RFIDUIRenderer: Flipper Zero UI with unlock/clone modes
- RFIDAnimations: Progress animations and visual feedback
- RFIDMinigame: Main controller with unlock/clone modes
- CSS: Complete Flipper Zero styling (orange device, monochrome screen)

Features:
- Unlock mode: Tap physical keycards or emulate saved cards
- Clone mode: Read and save cards to RFID cloner
- EM4100 protocol with DEZ8, facility codes, checksums
- Automatic conversation return after cloning (proven pattern)
- 50-card storage limit with duplicate overwrite
- Validated 10-char hex IDs

Integration:
- Registered in MinigameFramework as 'rfid'
- Added to unlock-system.js switch statement
- Exported window.startRFIDMinigame and returnToConversationAfterRFID

Files Created:
- js/minigames/rfid/rfid-minigame.js (main controller)
- js/minigames/rfid/rfid-data.js (data management)
- js/minigames/rfid/rfid-ui.js (UI rendering)
- js/minigames/rfid/rfid-animations.js (animations)
- css/rfid-minigame.css (Flipper Zero styles)

Next: Add chat-helpers tag, interactions handler, HTML/Phaser integration
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
a52f8da171 docs(rfid): Second review - fix critical conversation pattern error
CRITICAL ISSUE: Planned return-to-conversation pattern was fundamentally incorrect.
Fixed to use proven window.pendingConversationReturn pattern from container minigame.

Key changes:
- NEW: review2/CRITICAL_FINDINGS.md - 8 findings with detailed analysis
- NEW: review2/README.md - Quick action guide
- FIXED: Task 3.4 - Simplified conversation return (2.5h → 1h)
- ADDED: Task 3.9 - returnToConversationAfterRFID function (0.5h)
- FIXED: Section 2c in architecture doc - Correct minimal context pattern
- Updated time estimates: 102h → 101h

npcConversationStateManager handles all conversation state automatically.
No manual Ink story save/restore needed.

Reference: /js/minigames/container/container-minigame.js:720-754

Risk: HIGH → MEDIUM (after fix)
Confidence: 95% → 98%
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
c5d5ebeff3 docs(rfid): Apply all implementation review improvements to planning docs
Applied all 7 critical fixes and 12 high-priority improvements from the
implementation review to create a complete, self-contained implementation plan.

## Critical Fixes Applied:

1. **CSS File Path Corrected**
   - Changed: css/minigames/rfid-minigame.css → css/rfid-minigame.css
   - Updated: All references in both TODO and architecture docs

2. **Interaction Handler Location Fixed**
   - Changed: inventory.js → interactions.js for keycard click handler
   - Reason: handleObjectInteraction() is defined in interactions.js

3. **Interaction Indicator Integration Added**
   - New Task 3.6: Update getInteractionSpriteKey() for RFID locks
   - Ensures RFID-locked doors show correct icon

4. **Complete 4-Step Registration Pattern**
   - Task 3.2: Added full Import → Export → Register → Window pattern
   - Matches pattern used by all other minigames

5. **Event Dispatcher Integration**
   - Added event emission for card_cloned, card_emulated, rfid_lock_accessed
   - Enables NPC reactions and telemetry tracking

6. **Return-to-Conversation Pattern** (Critical user correction)
   - Task 3.4: Completely rewritten to return to conversation after cloning
   - Added conversation context storage and restoration
   - Matches notes minigame behavior as intended

7. **Hex Validation Specifications**
   - Task 1.2: Added validateHex() method with complete rules
   - Validates length, format, and character set

## High-Priority Improvements:

8. **Card Name Generation**
   - Added CARD_NAME_TEMPLATES array with 8 descriptive names
   - Better UX than generic numbered cards

9. **Duplicate Card Handling**
   - Strategy: Overwrite with updated timestamp
   - MAX_SAVED_CARDS limit: 50 cards

10. **DEZ8 Formula Specified**
    - Proper EM4100 format: last 3 bytes (6 hex chars) to decimal
    - Pad to 8 digits with leading zeros

11. **Facility Code Formula**
    - Extract first byte (chars 0-1) as facility code (0-255)
    - Extract next 2 bytes (chars 2-5) as card number (0-65535)

12. **Checksum Calculation**
    - XOR of all bytes for EM4100 compliance
    - Returns checksum byte (0x00-0xFF)

13. **HTML CSS Link Task**
    - New Task 3.7: Add CSS link to index.html
    - Critical integration step that was missing

14. **Phaser Asset Loading Task**
    - New Task 3.8: Load all RFID sprites and icons
    - Critical integration step that was missing

## Files Updated:

### Review Documents:
- review/IMPLEMENTATION_REVIEW.md - Updated Improvement #1 with correct behavior
- review/CRITICAL_FIXES_SUMMARY.md - Added return-to-conversation pattern

### Planning Documents:
- 01_TECHNICAL_ARCHITECTURE.md - All fixes + formulas + patterns
- 02_IMPLEMENTATION_TODO.md - All task updates + 2 new tasks
- README.md - Updated time estimate (91h → 102h)
- PLANNING_COMPLETE.md - Updated time estimate + review notes

## Time Estimate Updates:

- Original: 91 hours (~11 days)
- Updated: 102 hours (~13 days)
- Increase: +11 hours (+12%)
  - Phase 1: +1h (validation/formulas)
  - Phase 3: +2h (new integration tasks)
  - Phase 6: +3h (additional testing)
  - Phase 8: +5h (comprehensive review)

## Impact:

 Planning documents now self-contained and complete
 All critical integration points specified
 All formulas mathematically correct for EM4100
 User-corrected behavior (return to conversation) implemented
 No references to review findings outside review/ directory
 Ready for implementation with high confidence

Confidence level: 95% → 98% (increased after review)
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
ed09fe7c50 docs: Add comprehensive implementation review for RFID keycard system
Review findings:
- 7 critical issues identified (must fix before implementation)
- 12 important improvements recommended
- Complete analysis of integration points
- Code examples for all fixes provided

Critical issues found:
- Incorrect CSS file path (css/minigames/ vs css/)
- Wrong modification target (inventory.js vs interactions.js)
- Missing interaction indicator integration
- Incomplete minigame registration pattern
- Missing event dispatcher integration
- No hex ID validation specified
- Unclear duplicate card handling

Review documents:
- IMPLEMENTATION_REVIEW.md: Full 35-page analysis
- CRITICAL_FIXES_SUMMARY.md: Quick fix checklist
- README.md: Review overview and navigation

Impact:
- Timeline: +2 hours for critical fixes, +6 hours for improvements
- Success probability: Significantly increased with fixes applied
- Overall assessment: 4/5 stars, excellent plan with fixable issues

All fixes are documented with code examples and can be applied in ~2 hours.
Ready for fix application before implementation begins.
2025-11-15 23:48:15 +00:00
Z. Cliffe Schreuders
bd8b9a4f85 docs: Add comprehensive RFID keycard lock system planning documentation
Planning documentation for new RFID keycard lock system feature:

Documentation:
- Complete planning docs in planning_notes/rfid_keycard/
- 7 planning documents (~16,000 words)
- 90+ implementation tasks with estimates
- Technical architecture and code design
- Asset specifications and creation guides

Assets Created:
- 4 keycard sprite variants (CEO, Security, Maintenance, Generic)
- RFID cloner device sprite (Flipper Zero-inspired)
- 2 icon assets (RFID icon, NFC waves)
- Helper scripts for placeholder creation

System Documentation:
- Lock & key system architecture reference
- Lock & key quick start guide

Feature Overview:
- New lock type: "rfid"
- New items: keycard, rfid_cloner
- New minigame: Flipper Zero-style RFID reader/cloner
- Ink tag support: # clone_keycard:name|hex
- Inventory integration: Click cards to clone
- Two modes: Unlock (tap/emulate) and Clone (read/save)

Implementation:
- Estimated time: 91 hours (~11 working days)
- 11 new files, 5 modified files
- Full test plan included
- Ready for immediate implementation

All placeholder assets functional for development.
Documentation provides complete roadmap from planning to deployment.
2025-11-15 23:48:15 +00:00