Commit Graph

50 Commits

Author SHA1 Message Date
tiennm99 83cba85f04 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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 08:14:41 +00:00
tiennm99 b00b438b1b docs(phase-3): add planning artifacts and update state for Phase 4
Add Phase 3 plan files (pathfinding, scoring, visual feedback),
update state tracking for Phase 4 context, and clean up gitignore.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 14:04:38 +07:00
tiennm99 a94c0c4ac3 docs(phase-3): complete Core Matching Mechanics phase and prepare Phase 4
Mark Phase 3 as completed in roadmap, add verification documentation,
and create Phase 4 context for Game State Management.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 14:03:31 +07:00
tiennm99 718590d0d3 docs(03-02): complete Match Engine and Scoring System plan
- Created 03-02-SUMMARY.md with comprehensive execution summary
- Updated STATE.md with position, decisions, and metrics
- Updated ROADMAP.md with phase 3 progress (2/3 plans complete)
- Marked requirements CORE-05, CORE-06, CORE-07, BOARD-02 as complete

Artifacts delivered:
- Scoring.calculate: Base score (100) + complexity bonus
- MatchEngine.validateMatch: Multi-stage validation pipeline
- GridManager.clearTiles: Tile clearing with event emission
- Game match handling: tilesSelected → validate → clear/score
- Score HTML overlay: Real-time score display

Duration: 2 minutes
Tasks: 5 completed
Files: 8 created/modified
Test coverage: 13 test cases


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 04:42:00 +00:00
tiennm99 0c74c254c2 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


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 04:41:30 +00:00
tiennm99 5976d539ac feat(03-02): add score display HTML overlay
- Added div with id=\"score-display\" in top-right corner
- Semi-transparent background (rgba(26, 26, 70, 0.9))
- Large bold font (24px) with light text color (#eaeaea)
- Initial text shows \"Score: 0\"
- Positioned above canvas with z-index: 100


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 04:41:00 +00:00
tiennm99 10de5e4b6f feat(03-02): add clearTiles method to GridManager
- Added clearTiles method that marks tiles as cleared
- Emits tile:cleared event for each cleared tile
- Calls deselectAll() after clearing tiles
- Enables CORE-05 (connected tiles disappear) and CORE-07 (cleared tiles become passable)


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 04:40:30 +00:00
tiennm99 fd3b584fff feat(03-02): implement MatchEngine validation pipeline
- Implemented MatchEngine class with validateMatch method
- Multi-stage validation: type check → position check → pathfinding
- Type check happens before expensive pathfinding (fail-fast optimization)
- Returns MatchResult with valid flag, reason, path, turns, and score
- All 8 test cases covering all validation branches
- Score calculated using Scoring.calculate

Test coverage:
- Different tile types → valid=false, reason='different-type'
- Same tile ID → valid=false, reason='same-tile'
- Valid 0-turn path → valid=true, turns=0, score=150
- Valid 1-turn path → valid=true, turns=1, score=125
- Valid 2-turn path → valid=true, turns=2, score=100
- 3+ turn path → valid=false, reason='too-many-turns'
- No path (blocked) → valid=false, reason='no-path'
- Score calculation correct for valid matches


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 04:40:00 +00:00
tiennm99 6829c2f025 test(03-02): add failing test for Scoring system
- Created test suite with 5 test cases for score calculation
- Tests cover base score (100), 0-turn bonus (150), 1-turn bonus (125)
- Tests verify default to base score for invalid turn counts
- Tests verify integer scores (no floating point)


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 04:39:00 +00:00
tiennm99 3db7d69e56 docs(03-01): complete Path-Finding Algorithm plan
- Created SUMMARY.md with implementation details
- Updated STATE.md with progress, decisions, and metrics
- Updated ROADMAP.md with plan progress (1/3 complete)
- Marked CORE-04 requirement as complete
- Duration: 3 minutes
- Tasks: 2 (type definitions, BFS implementation)
- Files: 3 created/modified (PathFinder.ts, PathFinder.test.ts, types/index.ts)
- Test coverage: 15 test cases
- Deviations: Fixed npm cache and rollup dependency issue (Rule 3)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 04:37:00 +00:00
tiennm99 472f1529b9 feat(03-01): implement BFS pathfinding with turn counting
- Created PathFinder class with static findPath method
- Implements BFS algorithm with turn tracking (max 2 turns default)
- Direction encoding: -1=none/start, 0=up, 1=right, 2=down, 3=left
- Visited state tracking using 'row,col,direction' keys to avoid cycles
- Turn counting: only direction changes count, first move doesn't count
- Boundary checking using CONFIG.grid.rows and CONFIG.grid.cols
- Passable tile check: only cleared tiles are traversable
- Returns PathNode with path array and turn count, or null if no path
- Added 10 comprehensive test cases covering:
  * 0-turn paths (direct horizontal/vertical)
  * 1-turn L-shaped paths
  * 2-turn Z-shaped paths
  * 3+ turn rejection
  * Blocked path detection
  * Path inclusion of start/end positions
  * Correct turn counting behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 04:36:00 +00:00
tiennm99 9fc8962dc7 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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 04:35:00 +00:00
tiennm99 acee40b83b chore: update .gitignore and add Phase 2 artifacts
- Add shell configs, IDE files, and local configs to .gitignore
- Add Phase 2 planning artifacts (CONTEXT, RESEARCH, VERIFICATION)
- Add GridManager test suite


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 03:09:45 +00:00
tiennm99 0af1a576ca docs(02-03): complete 02-03 plan summary and state updates
- Create 02-03-SUMMARY.md with implementation details
- Update STATE.md with Phase 2 complete status
- Update ROADMAP.md to mark Phase 2 as complete
- Record all task commits and decisions

Phase 2 (Grid and Input) is now 100% complete with all 4 plans finished.


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 02:58:19 +00:00
tiennm99 80a9e2b95c feat(02-03): add debounced canvas resize handler
- Add resizeTimeout field for debounce timer
- Add handleResize() method with 150ms debounce
- Add window resize event listener
- Recalculate canvas size on resize
- Trigger renderer.render() after resize

Implements Task 3 of plan 02-03


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 02:56:33 +00:00
tiennm99 86f968e5ad feat(02-03): add mouse and touch event listeners with coordinate-to-tile mapping
- Add setupInputListeners() public method
- Add handleClick and handleTouch event handlers
- Add handleInput() method for coordinate translation
- Implement getBoundingClientRect() for accurate hit detection
- Account for device pixel ratio in coordinate calculations
- Map canvas coordinates to tile grid position
- Call gridManager.selectTile() for valid tiles

Implements Task 2 of plan 02-03


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 02:56:11 +00:00
tiennm99 dedc65e2c7 feat(02-03): integrate GridManager and Renderer into Game class
- Add GridManager and Renderer imports
- Add gridManager and renderer fields to Game class
- Initialize GridManager and create grid in constructor
- Initialize Renderer with canvas reference
- Delegate render() to renderer.render()
- Add tilesSelected event listener for logging

Implements Task 1 of plan 02-03


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 02:55:44 +00:00
tiennm99 e8f374da68 docs(02-02): complete Renderer plan summary
- Created comprehensive SUMMARY.md documenting Renderer implementation
- Updated STATE.md with position, decisions, and metrics (86% progress)
- Updated ROADMAP.md with plan 02 completion (3 of 4 plans complete)
- Recorded 3 key decisions about GridManager, animations, and centering

**Key Deviations Documented:**
- GridManager created as blocking dependency (Rule 3)
- Added resetFadeAnimation(), setCanvas(), getSelectionAlpha() methods (Rule 2)
- Sandbox issues prevented test execution (manual verification performed)

**Metrics:**
- Duration: 7 minutes
- Tasks: 1 (TDD with RED phase complete)
- Files: 4 created/modified
- Commit: e93ef9c (implementation)


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 02:52:46 +00:00
tiennm99 4f1a0fdb9d 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.


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 02:51:11 +00:00
tiennm99 8508994c92 fix(02): add Wave 0 test infrastructure and update dependencies
- Create Plan 02-00 (Wave 0) with test file stubs for Nyquist compliance
- Update Plans 02-01, 02-02, 02-03 to depend on 02-00
- Fix wave numbers: 02-01 and 02-02 remain in Wave 1, 02-03 stays in Wave 2
- Update VALIDATION.md: mark nyquist_compliant: true, wave_0_complete: true

Resolves checker issues:
- Nyquist Compliance: Wave 0 test files now exist
- All TDD tasks have test stubs to run against

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-11 02:41:44 +00:00
tiennm99 2a2582a9c2 docs(01): complete phase execution 2026-03-11 00:29:01 +07:00
tiennm99 3ce41bb884 docs(01-03): complete game integration plan
- Phase 1 Core Foundation complete
- Game class orchestrates loop, events, and canvas
- main.ts entry point with DOMContentLoaded initialization
- Configuration validation tests added
- Fixed browser compatibility with custom EventEmitter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 00:25:11 +07:00
tiennm99 d25e6aeafb chore: add standard gitignore entries for Vite/TypeScript project 2026-03-11 00:13:10 +07:00
tiennm99 4adca72e3a fix(01-02): replace Node EventEmitter with browser-compatible implementation
Node's 'events' module doesn't work in browsers. Replaced with custom
Map-based implementation that provides the same API but works in both
Node.js and browser environments.

All 98 tests still pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 00:09:45 +07:00
tiennm99 d0a39fc031 feat(01-03): wire main.ts entry point with Game class
- Update main.ts to import and instantiate Game class
- Wait for DOMContentLoaded before initializing
- Add error event listener on game.events
- Add tick event listener (commented debug logging)
- Log initialization message to console
- Add main.test.ts with entry point tests (4 tests)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 00:00:32 +07:00
tiennm99 6fbe23365a feat(01-03): add Game class orchestrator with TDD
- Create Game class that orchestrates canvas, game loop, and events
- Game constructor initializes canvas, context, loop, and events
- Game.start() starts the loop and emits 'game:start' event
- Game.render() clears canvas with background color
- Handle device pixel ratio for sharp rendering
- Add comprehensive tests (15 tests) for Game class

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:58:18 +07:00
tiennm99 2af6053ccf docs(01-02): complete core infrastructure plan
- SUMMARY.md created with full execution details
- STATE.md updated: plan 2 of 3, 11% progress
- ROADMAP.md updated: 01-02 marked complete
- All 79 tests passing, TypeScript compiles clean

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:54:29 +07:00
tiennm99 fdd1ffd17e refactor(01-02): fix TypeScript type issues in tests
- Changed EventEmitter generic constraint to `object` for interface compatibility
- Fixed GameLoop test closure variable narrowing issue by using array

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:51:35 +07:00
tiennm99 efcac7ad4c feat(01-02): implement Tile model class
- Implements Tile interface from types/index.ts
- Constructor with id, type, position
- emoji getter returns CONFIG.emojis[type]
- isAdjacent() checks orthogonal adjacency
- cleared property defaults to false

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:49:16 +07:00
tiennm99 080b9f22a0 test(01-02): add failing tests for Tile model class
- Tests for constructor with id, type, position
- Tests for emoji getter returning correct emoji
- Tests for isAdjacent() method with various positions
- Tests for readonly properties and cleared default

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:48:48 +07:00
tiennm99 84e92c3178 feat(01-02): implement TypedEventEmitter class
- Generic class wrapping Node's EventEmitter
- Type-safe on(), emit(), off() methods
- Added once() and removeAllListeners() methods
- Returns this for method chaining

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:47:55 +07:00
tiennm99 4609e01410 test(01-02): add failing tests for TypedEventEmitter class
- Tests for on(), emit(), off() methods
- Tests for multiple listeners and chaining
- Tests for type safety with typed payloads
- Tests for error handling and once() method
- Tests for removeAllListeners()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:47:24 +07:00
tiennm99 e46bc1db7a test(01-02): add failing tests for GameLoop class
- Tests for start(), stop(), isRunning(), getRafId()
- Tests for update callback with deltaTime
- Tests for delta time accumulation
- Tests for loop lifecycle (start/stop multiple times)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:46:34 +07:00
tiennm99 1589b341e4 docs(01-01): complete project scaffolding plan
- Add SUMMARY.md with execution details
- Update STATE.md with progress and decisions
- Update ROADMAP.md with plan completion
- Mark CORE-01 as complete in REQUIREMENTS.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:43:56 +07:00
tiennm99 cf62913697 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
tiennm99 2e8dcf2f29 feat(01-01): create game configuration constants
- Add src/config.ts with CONFIG object
- Define grid settings (10 rows, 16 cols, 160 tiles)
- Define tile settings (size, gap, corner radius)
- Define 16 nature-themed emojis
- Define color palette for game elements
- Add comprehensive tests for all config values

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:39:15 +07:00
tiennm99 3e61fa2fd4 feat(01-01): create Vite project with TypeScript and Canvas
- Initialize Vite project with vanilla-ts configuration
- Add TypeScript with strict mode enabled
- Configure Vitest for testing
- Create index.html with Canvas element
- Add main.ts entry point with canvas setup
- Add setup tests for project dependencies

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:38:14 +07:00
tiennm99 b7a5d42a03 docs(01): create Phase 1 Core Foundation plans 2026-03-10 23:31:02 +07:00
tiennm99 d5fc12adfa docs(01): add research and validation strategy 2026-03-10 23:23:07 +07:00
tiennm99 52dddf9cdf docs(01-core-foundation): add phase research document 2026-03-10 23:21:54 +07:00
tiennm99 e32f01203e docs(state): record phase 1 context session 2026-03-10 23:15:01 +07:00
tiennm99 6c1c49d6d9 docs(01): capture phase context 2026-03-10 23:14:46 +07:00
tiennm99 eca7c7934d docs: create roadmap (6 phases) 2026-03-10 23:04:58 +07:00
tiennm99 b751d69817 docs: define v1 requirements 2026-03-10 22:58:47 +07:00
tiennm99 f1d2984ea8 docs: complete project research for Pikachu Match tile-matching game
- STACK.md: Recommended Vite + TypeScript + Canvas minimal approach
- FEATURES.md: Core matching mechanics and table stakes features
- ARCHITECTURE.md: Layered architecture with state machine pattern
- PITFALLS.md: Critical pitfalls (path-finding, board generation, dead-end detection)
- SUMMARY.md: Synthesized findings with 6-phase roadmap suggestions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 22:56:01 +07:00
tiennm99 2d0595ae51 chore: add project config 2026-03-10 22:33:08 +07:00
tiennm99 58e0dc3cea docs: initialize project 2026-03-10 22:28:35 +07:00
tiennm99 bde9431c53 chore: install GSD (get-shit-done) Claude Code integration
Add GSD framework configuration including agents, commands, hooks,
and settings for spec-driven development workflow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 22:16:07 +07:00
tiennm99 bf41a79fab docs(gsd-module): add GSD Module 3 course structure and lesson content
- Expand README with full setup instructions, file structure, and testing notes
- Add lesson modules for 3.1–3.5 covering What is GSD through Verify & Beyond
- Add course-structure.json, PROJECT_BRIEF.md, and .claude/ commands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-08 21:13:56 +07:00
Tien Nguyen Minh 66775c3b0f Initial commit 2026-03-08 21:11:57 +07:00