Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global leaderboard #76

Draft
wants to merge 78 commits into
base: master
Choose a base branch
from

Conversation

noneofyourbusiness1415252
Copy link

@noneofyourbusiness1415252 noneofyourbusiness1415252 commented Feb 17, 2025

This PR adds a global leaderboard feature that tracks player progress across both games while maintaining the project's commitment to pure Rust/WASM implementation and accessibility standards.

Key Changes:

  • New leaderboard page with game-specific sorting:
    • Perception: Sorted by (level, lowest moves in last level)
    • Numeracy: Sorted by level reached
  • Player name persistence using local storage
  • Cloudflare D1 integration for global stats
  • Additional player statistics tracking
  • New WASI-based Cloudflare Worker for database operations

Implementation Details:

  • Uses Rust compiled to WASM/WASI for all functionality
  • Maintains existing dark/light theme support
  • Follows project's contrast ratio standards (3:1 minimum)
  • Zero JavaScript implementation

Migration:

  1. Deploy Cloudflare D1 database
  2. Deploy WASI-compatible worker
  3. Add leaderboard routes to Pages configuration

Testing:

  • Local D1 testing with miniflare
  • End-to-end testing with wasm-bindgen-test
  • Accessibility validation for WCAG AA compliance

- Add localStorage save/load for game state
- Fix timer display updates during gameplay
- Preserve level between sessions
- Block door access until key is collected
- Ensure game resets after 5 minute timeout
- Remove unnecessary alerts
- Ensure key and door positions are always different
- Maintain waypoint system for path complexity
- Keep separate logic for 2x2 and larger grids
- Fix potential inaccessible positions issue
- Start with all walls instead of random walls
- Create guaranteed paths first before adding random walls
- Ensure paths between start -> waypoints -> key -> waypoints -> door
- Different waypoint logic for 2x2 vs larger grids
- Fix overlapping key/door positions
- Make sure all positions are accessible
- Remove individual pointer HTML elements
- Add CSS pseudo-elements for all 4 directions using ::before, ::after on cell and span
- Fix z-index and positioning to show pointers above cells
- Align pointer bases exactly with cell borders
- Add clip-path to grid to hide out-of-bounds pointers
- Optimize cell creation by only regenerating grid when size changes
- Fix type conversion for HTML collection indices (usize to u32)
- Improve cell state management with proper span element handling
- Implement efficient event delegation for cell clicks
- Reduce unnecessary DOM updates by checking content before modification
- Use text nodes for content updates to improve performance
* refactor: initial modularization of the codebase

Split monolithic lib.rs into a more maintainable structure:
- Create games/ directory for game implementations
- Move Perception (Seek) game into games/perception.rs
- Create utils.rs for shared functionality
- Update lib.rs to re-export necessary items

This refactoring sets up the foundation for:
1. Adding remaining cognitive test modules
2. Better separation of concerns
3. Easier maintenance and testing
4. More idiomatic Rust module structure

* break down the Perception module further
Game state management (saving/loading/creation)
Rendering logic
Movement and maze interaction
Core game mechanics (walls, positions, etc.)

* fix compilation

* extracting the timer-related functionality into a new module

* Create a new input.rs module for handling user interactions

* Removed redundant game.render()? call since it's already done in new()
todo: simple decimals at later levels
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