Fix: Respect diagonal mode setting in grid rendering#10
Merged
Conversation
The grid was always rendering all diagonal lines regardless of the selected diagonal mode. This fix ensures the visual grid matches the configured game rules. ## Changes **Fixed diagonal line rendering in ui.js:** - Mode 'none': No diagonal lines drawn (4-way movement only) - Mode 'short': Short diagonals in each square (8-way movement) - Mode 'all': Short + long diagonals across entire grid **Implementation:** - Added diagonalMode check before drawing diagonal lines - Wrapped short diagonal rendering in conditional block - Added long diagonal rendering for 'all' mode - Maintains existing behavior for 'short' mode (default) ## Bug Impact **Before:** Grid visually showed all diagonals even in 'none' mode, confusing players about valid moves. **After:** Grid visual accurately reflects allowed movement directions based on selected diagonal mode. ## Testing Manual testing required: - [ ] Start game with 'No Diagonals' - verify no diagonal lines shown - [ ] Start game with 'Short Diagonals' - verify short diagonals shown - [ ] Start game with 'All Diagonals' - verify all diagonal lines shown - [ ] Verify movement restrictions match visual grid 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed diagonal mode options from three modes (none, short, all) to: - No Diagonals (4-way movement) - Main Diagonals Only (diagonal movement restricted to main diagonals) - 8-way Movement (full diagonal connections everywhere) Game Logic Changes: - Added isOnMainDiagonal() and isOnAntiDiagonal() helper methods - Updated getAdjacentPositions() to handle 'main' mode - Removed 'all' diagonal mode from game.js AI Changes: - Updated AI's getAdjacentPositions() to support 'main' mode - Removed 'all' diagonal mode from ai.js UI Changes: - Updated grid rendering to draw only two main diagonal lines for 'main' mode - Simplified diagonal rendering logic Tests: - Replaced 'all' mode tests with comprehensive 'main' mode tests - Added tests for main diagonal movement restrictions - All 130 tests passing Documentation: - Updated RULES.md with Main Diagonals Only description and diagram - Updated README.md with new mode descriptions - Updated tests/README.md with correct mode documentation Files changed: 9 files Tests: 130 passing 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug Fix
Fixes a visual bug where the grid always displayed all diagonal lines regardless of the selected diagonal mode setting.
Problem
When users selected "No Diagonals" mode, the grid still showed diagonal lines, creating confusion about which moves were valid. The diagonal mode setting affected game logic correctly, but the UI rendering didn't respect it.
Solution
Updated
drawGridLines()inweb/js/ui.jsto conditionally render diagonal lines based on thediagonalModesetting:Changes
Modified Files:
web/js/ui.js- Added diagonal mode conditional renderingLines Changed: 1 file, 52 insertions(+), 12 deletions(-)
Testing Checklist
Manual testing needed to verify:
Impact
Screenshots
Before: Grid showed diagonals in all modes
After: Grid respects selected diagonal mode
Branch:
claude/fix-diagonal-rendering-3943Commit: Signed ✅