Skip to content

Fix: Respect diagonal mode setting in grid rendering#10

Merged
dhanjit merged 2 commits into
mainfrom
claude/fix-diagonal-rendering-3943
Dec 31, 2025
Merged

Fix: Respect diagonal mode setting in grid rendering#10
dhanjit merged 2 commits into
mainfrom
claude/fix-diagonal-rendering-3943

Conversation

@dhanjit

@dhanjit dhanjit commented Dec 31, 2025

Copy link
Copy Markdown
Owner

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() in web/js/ui.js to conditionally render diagonal lines based on the diagonalMode setting:

  • Mode 'none': No diagonal lines (orthogonal grid only)
  • Mode 'short': Short diagonal lines in each square (default)
  • Mode 'all': Short diagonals + long diagonals across entire grid

Changes

Modified Files:

  • web/js/ui.js - Added diagonal mode conditional rendering

Lines Changed: 1 file, 52 insertions(+), 12 deletions(-)

Testing Checklist

Manual testing needed to verify:

  • Code follows project style guidelines
  • No diagonals mode: Grid shows no diagonal lines
  • Short diagonals mode: Grid shows short diagonals only
  • All diagonals mode: Grid shows all diagonal lines
  • Movement restrictions match visual grid in all modes

Impact

  • Severity: Medium (visual bug, game logic already correct)
  • User Experience: Significantly improved - grid now matches rules
  • Breaking Changes: None
  • Performance: No impact

Screenshots

Before: Grid showed diagonals in all modes
After: Grid respects selected diagonal mode


Branch: claude/fix-diagonal-rendering-3943
Commit: Signed ✅

dhanjit and others added 2 commits December 31, 2025 18:05
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>
@dhanjit dhanjit merged commit 1bb0870 into main Dec 31, 2025
4 checks passed
@dhanjit dhanjit deleted the claude/fix-diagonal-rendering-3943 branch December 31, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant