Commit Graph

5 Commits

Author SHA1 Message Date
GSD Executor 65e45ba32f feat(04-01): add GameState enum and StateChangeEvent type
- Add GameState enum with 4 string values (IDLE, SELECTING, MATCHING, GAME_OVER)
- Add StateChangeEvent interface with from/to properties
- Add game:stateChange event to GameEvents interface
- Add tests for GameState enum values and types
2026-03-11 08:14:41 +00:00
Claude Sonnet fcf3101490 feat(03-02): extend Game.ts with match handling and score display
- Added MatchEngine instantiation in Game constructor
- Implemented tilesSelected event handler with match validation
- Valid matches: emit tilesMatched event, clear tiles, update score display
- Failed matches: emit matchFailed event, deselect after 200ms delay
- Added private score property tracking current score
- Added updateScoreDisplay method to update HTML overlay
- Extended GameEvents interface with tilesMatched and matchFailed events

Event flow:
1. Player selects two tiles → tilesSelected event
2. MatchEngine validates match (type → position → path)
3. Success: clear tiles, add score, update display, emit tilesMatched
4. Failure: emit matchFailed, deselect tiles after 200ms

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-11 04:41:30 +00:00
Claude Sonnet 8bf2ccf78a test(03-01): add PathNode and MatchResult type definitions
- Added PathNode interface for BFS state tracking (row, col, direction, turns, path)
- Added MatchResult interface for match validation results (valid, reason, path, turns)
- Created test file with type import tests
- Direction encoding: -1=none/start, 0=up, 1=right, 2=down, 3=left
2026-03-11 04:35:00 +00:00
Claude Code e93ef9cb80 feat(02-02): implement Renderer class with tile and selection rendering
- Created Renderer class with tile rendering, selection highlighting, and fade-in animations
- Created GridManager class with tile array and selection state management (blocking dependency)
- Added tilesSelected event to GameEvents interface
- Created comprehensive test suite for Renderer with 9 test cases

**Renderer Features:**
- Renders all non-cleared tiles from GridManager at correct positions
- Centers grid horizontally and vertically within canvas
- Displays emoji characters centered within tile bounds
- Selection highlights with border (3px) and background tint (30% opacity)
- Fade-in animation over ~100ms using performance.now()
- Uses CONFIG.tile.size, gap, cornerRadius for positioning
- Respects CONFIG.colors for styling

**GridManager Features:**
- Manages 2D tile array (10x16 grid = 160 tiles)
- Selection state tracking with toggle behavior (0-2 tiles)
- selectTile() with toggle deselect and cleared tile filtering
- Emits tilesSelected event when 2 tiles selected
- getTileAt() for coordinate-based tile access

**Note:** Tests created but not runnable due to sandbox file system restrictions
preventing npm install. Implementation verified manually against plan requirements.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-11 02:51:11 +00:00
tiennm99 89a09fc047 feat(01-01): create shared type definitions
- Add src/types/index.ts with type definitions
- Define TilePosition interface (row, col)
- Define Tile interface (id, type, position, cleared)
- Define GameEvents interface for type-safe event handling
- Add comprehensive tests for all type definitions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:40:44 +07:00