Commit Graph
59 Commits
Author SHA1 Message Date
pastilhas 76523e293e 2.3.1 2025-11-02 17:43:10 +00:00
pastilhas 9968c924b9 feat: add version to gameInfo export
- gameInfo now includes version from package.json
- Platform can access game version via gameInfo.version
- Useful for version checking and compatibility validation
2025-11-02 17:42:47 +00:00
pastilhas 6ad2119b62 2.3.0 2025-11-02 17:41:13 +00:00
pastilhas 7b0b8ee0aa feat: add runtime gameInfo enrichment with gameOver condition
- Add gameOverCondition to GameManager for runtime tracking
- Create enrichGameInfo() function to merge runtime condition with static gameInfo
- Add formatGameOverCondition() utility to stringify boolean/function conditions
- Returns enriched info with:
  - condition: formatted string representation
  - type: 'none' | 'static' | 'function'
- Platform can call enrichGameInfo(gameManager) to get complete game configuration
- Handles all condition types: undefined, boolean, function
- Truncates long function strings at 200 chars
2025-11-02 17:20:21 +00:00
pastilhas afce474e0d Revert "feat: add intermediate efficiency calculation for real-time feedback"
This reverts commit 7352eff726.
2025-11-02 17:16:10 +00:00
pastilhas 7352eff726 feat: add intermediate efficiency calculation for real-time feedback
- While keystrokes ≤ optimalSteps: show progress (keystrokes/optimal * 100)
  - Players see efficiency climbing from 0→100% as they play well
  - Provides real-time feedback during navigation
- After keystrokes > optimalSteps: show degradation (optimal/keystrokes * 100)
  - Efficiency smoothly decreases below 100%
- Examples with 100 optimal steps:
  - At 25 keystrokes: 25% (progress)
  - At 50 keystrokes: 50% (halfway)
  - At 100 keystrokes: 100% (optimal reached!)
  - At 120 keystrokes: 83% (slightly over)
  - At 200 keystrokes: 50% (double the optimal)
2025-11-02 17:15:38 +00:00
pastilhas c1f578be42 fix: correct efficiency calculation direction
- Efficiency now starts at 100% (perfect play) and decreases toward 0% (bad play)
- Formula: (optimalSteps / keystrokes) * 100
- Clamped to 0-100 range
- Examples:
  - 100 keystrokes / 100 optimal = 100% (perfect)
  - 120 keystrokes / 100 optimal = 83% (good)
  - 200 keystrokes / 100 optimal = 50% (fair)
  - 500 keystrokes / 100 optimal = 20% (poor)
- Default 100% when no keystrokes yet
2025-11-02 17:13:44 +00:00
pastilhas d4eb926783 chore: remove debug console.log from useTimer 2025-11-02 17:10:19 +00:00
pastilhas b962ebf214 docs: add UNIFIED_API update recommendations
- Provide detailed before/after examples for all sections
- Document new gameOver pattern with flexible function-based conditions
- Explain migration path for games updating to this pattern
- Highlight benefits: pure data collection, separation of concerns, flexibility
- Guide for updating root UNIFIED_API.md to reflect vim-maze v2.3 changes
2025-11-02 17:09:21 +00:00
pastilhas 897cb5de13 docs: update gameInfo.ts to reflect scoring refactor
- Update gameOver section: removed hardcoded time limit, now uses custom gameOver condition
- Add examples of gameOver usage: time-based, efficiency-based, combined
- Update metrics: add optimalSteps and efficiency to tracked metrics
- Add note: ScoreManager provides metrics for flexible game-over/scoring logic
- Update objective: reflect custom game-over condition requirement
2025-11-02 17:08:54 +00:00
pastilhas 0749aba648 refactor: separate score calculation from score management
BREAKING CHANGES:
- Remove timeLimit from GameOptions (use gameOver function instead)
- Remove finalScore from ScoreManager (pure data collection only)
- Remove rows/cols parameters from useScore
- Remove finalScore calculation logic from useScore hook

ADDITIONS:
- Create calculateMazeScore() utility function
- ScoreManager now only returns raw metrics: timeValue, keystrokes, optimalSteps, efficiency, distToKey, distToExit
- Score calculation moved to consumer (calculateMazeScore takes scoreManager + mazeSize)
- Example app now uses calculateMazeScore to compute final score on game-won

BENEFITS:
- ScoreManager is now a pure data collector with no side effects
- Scoring algorithm is reusable and testable in isolation
- Game-over conditions fully controlled via gameOver option
- Clear separation of concerns: collection vs calculation
2025-11-02 17:04:21 +00:00
pastilhas 060c8abb24 feat: add custom gameOver condition to GameOptions
- Add optional gameOver field to GameOptions
- Can be a boolean value or a function that receives scoreManager
- Function receives current score metrics to make dynamic decisions
- Enables flexible game-over conditions beyond just time limit
- Example: gameOver: (sm) => sm.efficiency > 150 for efficiency threshold
- Checked every frame during 'started' and 'has-key' states
2025-11-02 17:01:53 +00:00
pastilhas 156c6db9d2 feat: display optimalSteps and efficiency metrics on scoreboard
- Show optimal steps required for the maze
- Display player efficiency percentage (100% = perfect play)
- Metrics appear after maze loads (when optimalSteps > 0)
- Separated from final score with visual divider
- Helps players understand their navigation performance
2025-11-02 16:55:46 +00:00
pastilhas 9db77779b8 feat: resurrect optimalSteps and efficiency metrics
- Calculate optimal path from entrance to key to exit using maze.getDistance()
- Compute efficiency as keystroke ratio to optimal steps (percentage)
- Add optimalSteps and efficiency to ScoreManager return value
- No game-over trigger on efficiency threshold (preserved for future use)
- Metrics available for display and potential future scoring enhancements
2025-11-02 16:54:43 +00:00
pastilhas b6c3225c60 2.2.0 2025-11-02 16:40:35 +00:00
pastilhas 8bbc6aac9b exporting version 2025-11-02 16:40:24 +00:00
pastilhas 87da1f999a fix: allow anchor moves to reach exit with key
Update findAnchorTarget to accept optional hasKey parameter. When player has the key and moving to an anchor (gg, G, ^, or $), if an exit is positioned at the edge, allow movement to reach it. This matches behavior of counted moves like 5k that can reach edge-positioned exits.
2025-10-23 20:45:44 +01:00
pastilhas f79d9d1c65 fix: remove invalid hook call in anchor movement validation
Remove validateAnchorMove function that called useMazeNavigation hook inside a regular function, which violates React's rules of hooks. Use the existing navigator instance directly in anchor movement methods instead.
2025-10-23 20:30:07 +01:00
pastilhas 1b9d963f46 removed src_old 2025-10-23 20:21:58 +01:00
pastilhas fe046544f3 2.1.0 2025-10-22 23:15:16 +01:00
pastilhas b5ce598344 new docs 2025-10-22 23:14:36 +01:00
pastilhas 6d71189e03 feat: add gameInfo export with structured game instructions
- Export gameInfo object with complete game documentation
- Includes controls (navigation, game)
- Includes rules (movement, game flow, maze elements)
- Includes scoring (formula, penalties, size multiplier, examples)
- Includes game-over conditions
- Includes maze generation details
- Includes tracked metrics
- Structured for easy platform rendering
- Fully typed with GameInfo type
2025-10-22 22:52:07 +01:00
pastilhas 40555d17b8 docs: add UNIFIED_API v2.0 to vim-maze 2025-10-22 22:31:31 +01:00
pastilhas 48039886d6 docs: comprehensive README with full API reference and examples 2025-10-22 22:14:19 +01:00
pastilhas 7800acaf56 feat: add timeLimit option and time-based game-over logic
- Add timeLimit to GameOptions (default 600 seconds)
- Game-over triggers when time limit exceeded
- Remove all efficiency-based game-over logic
- Pass timeLimit through to useScore
- Check time limit during started and has-key states
2025-10-22 22:07:59 +01:00
pastilhas 7ccf7cdd55 refactor: simplify scoring to remove efficiency-based complexity
- Remove efficiency calculation and game-over at 150%
- Remove optimal steps tracking and complex logic timing
- Simplify to time + keystrokes only scoring
- New formula: score = min(1000, (1000 - time_penalty - keystroke_penalty) × size_multiplier)
  - time_penalty = seconds / 10
  - keystroke_penalty = keystrokes / 2
  - size_multiplier = max(1.0, (rows × cols) / 500)
- Maze size-based multiplier rewards larger mazes
- Remove optimalSteps and efficiency from ScoreManager type
- Pass rows and cols to useScore for size calculation
- Align with vim-sudoku's simplified scoring approach
2025-10-22 22:03:44 +01:00
pastilhas 75ff8bc76e 2.0.0 2025-10-19 16:16:31 +01:00
pastilhas f1d59692be 1.3.0 2025-10-19 16:16:23 +01:00
pastilhas f5150b8324 updated README 2025-10-19 16:13:50 +01:00
pastilhas a69b7bbb5f organized types 2025-10-19 16:11:38 +01:00
pastilhas 252027dab2 no more ReturnType<typeof> 2025-10-19 15:55:52 +01:00
pastilhas a6f066d738 scoreManager implemented flawlessly 2025-10-19 15:29:01 +01:00
pastilhas 07f218f4dd 0 works both ways now 2025-10-19 15:09:41 +01:00
pastilhas 47aea08d49 proper anchor invalidation 2025-10-19 14:43:18 +01:00
pastilhas aa42066f57 anchor moves all work except zero. <dot> also working 2025-10-19 13:51:57 +01:00
pastilhas b6f5d7ae9f player moving, hjkl and counts... anchors not working yet 2025-10-19 13:32:01 +01:00
pastilhas 70a8167fb0 refactor: implement clean architecture with separation of concerns
- Add useMazeNavigation for pure maze geometry and path validation
- Add useVimMotions for pure Vim-style input parsing
- Add useAnimation for pure movement animation system
- Refactor useCursor to use specialized hooks with cleaner interface
- Refactor useHero to pure game logic without DOM manipulation
- Refactor useHeroRender to pure visual presentation layer
- Fix dual position system - hero position now authoritative
- Replace global events with callback props and return values
- Implement state-driven rendering instead of direct DOM queries
- Update GameManager interface with new HeroManager and HeroRenderer
- Maintain backward compatibility with legacy Cursor type
- Update UNIFIED_API.md with new architecture and interfaces
2025-10-19 13:27:35 +01:00
pastilhas 2c7816306c fix: rename GameStatus 'hasKey' to 'has-key'
- Update GameStatus type to use kebab-case convention
- Change all occurrences in useHero.ts
- Update UNIFIED_API.md documentation
- Maintains consistency with other status values
2025-10-19 13:05:35 +01:00
pastilhas 7c36f9dc14 refactor: integrate key management into cursor module
- Move useKeyBindings functionality into useCursor as useGameKeys
- Flatten GameManager interface using intersection types
- Rename clearLog/getLog to clearKeyLog/getKeyLog for clarity
- Remove separate useKeyBindings module and exports
- Update all documentation to reflect new architecture
- Maintain backward compatibility for platform hooks
2025-10-19 12:56:35 +01:00
pastilhas 81489557c3 player stopped moving 2025-10-19 03:39:37 +01:00
pastilhas ec954ccbb4 simplification 2025-10-19 03:34:43 +01:00
pastilhas 970bf22a6a no useCallbacks or useMemos 2025-10-19 03:28:27 +01:00
pastilhas 544581401b player moving 2025-10-19 03:07:52 +01:00
pastilhas 6108640267 useGame=>useCursor=>useHero=>useHeroRender 2025-10-19 03:01:22 +01:00
pastilhas 7e9058b2c9 proper hero death / respawn 2025-10-19 02:43:32 +01:00
pastilhas ef635f6112 proper hero renderer and positioning 2025-10-19 02:39:18 +01:00
pastilhas 310355104a useHeroRender 2025-10-19 02:30:50 +01:00
pastilhas f302c67778 e to ev 2025-10-19 02:06:59 +01:00
pastilhas e253a6b51d start and quit game working 2025-10-19 02:00:22 +01:00
pastilhas 4db86e1cfe working on unified API and major refactoring 2025-10-19 01:48:20 +01:00
pastilhas 8f62c6c2b5 working on unified API and major refactoring 2025-10-19 01:14:59 +01:00
pastilhas ee58ab25fb working on refactor 2025-10-17 03:07:07 +01:00
pastilhas acd4ec2053 1.2.1 2025-10-16 15:46:43 +01:00
pastilhas ea1a0c7343 importing styles from here 2025-10-16 15:46:35 +01:00
pastilhas f109b05f3e 1.1.0 2025-10-15 19:36:22 +01:00
pastilhas bdbe7b6914 css now theme aware 2025-10-15 19:35:43 +01:00
pastilhas 498e0adfb9 1.0.1 2025-10-14 13:46:07 +01:00
pastilhas 8f9bb1b51a github info 2025-10-14 13:46:02 +01:00
pastilhas c8eb84ce7e first 2025-10-14 13:33:51 +01:00