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.
5.3 KiB
Summary of Review Feedback Integration
Critical Updates Made
1. Grid System Clarification (GRID_SYSTEM.md)
- ✅ Clarified that valid room heights are: 6, 10, 14, 18, 22, 26... (formula: 2 + 4N)
- ✅ Updated room size table with formula verification
- ✅ Added invalid room size examples
- ✅ Specified minimum height for multiple E/W doors (8 tiles)
2. Door Alignment for Asymmetric Connections
CRITICAL FIX documented in DOOR_PLACEMENT.md:
When a room with a single connection links to a room with multiple connections in the opposite direction, the door position must be calculated to align with the correct door in the multi-door room.
Example:
[R2][R3] <- R1 has 2 south connections
[--R1--]
[--R0--] <- R0 has 1 north connection to R1
R0's north door must align with whichever of R1's south doors connects to R0.
Solution: Check if connected room has multiple connections in opposite direction, find this room's index in that array, calculate door position to match.
This fix must be applied to all single door placement functions:
placeNorthDoorSingle()placeSouthDoorSingle()placeEastDoorSingle()placeWestDoorSingle()
3. Shared Door Positioning Module
NEW FILE REQUIRED: js/systems/door-positioning.js
This module will be the single source of truth for door position calculations, used by:
createDoorSpritesForRoom()in doors.jsremoveTilesUnderDoor()in collision.js- Validation in validation.js
Benefits:
- Eliminates code duplication
- Guarantees door alignment
- Easier to maintain and test
4. Validation Enhancements
Additional validation checks needed:
- ✅ Connectivity validation (detect disconnected rooms)
- ✅ E/W door space validation (minimum height check)
- ✅ Structured validation report (ValidationReport class)
5. Implementation Strategy
NEW APPROACH: Incremental implementation with feature flag
Instead of "big bang" implementation, use phased approach:
Phase 0: Add feature flag (USE_NEW_ROOM_LAYOUT)
- Allows easy rollback if critical bug found
- Enables A/B testing
- Supports gradual migration
Phases 1-2: Implement north/south support only first
- Test with all existing scenarios (which only use N/S)
- Get early feedback
- Easier debugging
Phases 3-4: Add east/west support
- Test with new scenarios
- Build on stable N/S foundation
Phases 5-6: Validation and polish
- Add comprehensive validation
- Create debug tools
- Update documentation
Documents That Need Updates
High Priority (Before Implementation)
-
DOOR_PLACEMENT.md ⚠️ CRITICAL
- Add asymmetric connection handling to ALL single door functions
- Add examples showing the problem and solution
- Update function signatures to include
gameScenarioparameter
-
IMPLEMENTATION_STEPS.md ⚠️ CRITICAL
- Add Phase 0 for feature flag
- Split Phase 2 into 2a (N/S) and 2b (E/W)
- Add Phase 2.5 for shared door positioning module
- Update task sequence
-
TODO_LIST.md ⚠️ CRITICAL
- Add feature flag tasks
- Add shared door positioning module tasks
- Update door placement tasks with asymmetric handling
- Reorganize for incremental implementation
-
VALIDATION.md
- Add connectivity validation function
- Add E/W door space validation function
- Replace simple error logging with ValidationReport class
- Add examples of structured error reporting
Medium Priority (Can Update During Implementation)
-
POSITIONING_ALGORITHM.md
- No critical changes needed
- Works correctly with integer grid units
- May add performance optimization notes
-
WALL_SYSTEM.md
- No critical changes needed
- Current implementation compatible
New Documents to Create
-
MIGRATION_GUIDE.md (NEW)
- How to update room JSON files to valid heights
- How to test updated scenarios
- Common migration issues and fixes
- Checklist for scenario authors
-
TROUBLESHOOTING.md (NEW)
- Common validation errors and how to fix
- How to use debug tools
- Door misalignment troubleshooting
- Overlap detection help
Review Findings Summary
Critical Issues Found
- ❌ Grid height calculation created fractional grid units
- ❌ Door alignment broken for asymmetric connections
- ❌ Code duplication in door positioning
- ❌ Disconnected rooms not validated
All Issues Addressed
- ✅ Grid heights clarified (6, 10, 14, 18...)
- ✅ Door alignment solution documented
- ✅ Shared module approach specified
- ✅ Connectivity validation added
- ✅ Feature flag strategy added
- ✅ Incremental implementation planned
Next Steps
-
Update remaining documents with review feedback:
- DOOR_PLACEMENT.md (add asymmetric handling code)
- IMPLEMENTATION_STEPS.md (add feature flag and incremental approach)
- TODO_LIST.md (reorganize tasks)
- VALIDATION.md (add new validation functions)
-
Create new documents:
- MIGRATION_GUIDE.md
- TROUBLESHOOTING.md
- door-positioning.js module specification
-
Final review of updated plan
-
Begin implementation following updated plan
Confidence Level
Before Review: 7/10 (significant edge cases not addressed) After Review: 9/10 (critical issues identified and solutions specified)
The plan is now solid and ready for implementation with significantly reduced risk.