strat-gameplay-webapp/backend/app/core/cache.py
Cal Corum a1f42a93b8 CLAUDE: Implement Phase 3A - X-Check data models and enums
Add foundational data structures for X-Check play resolution system:

Models Added:
- PositionRating: Defensive ratings (range 1-5, error 0-88) for X-Check resolution
- XCheckResult: Dataclass tracking complete X-Check resolution flow with dice rolls,
  conversions (SPD test, G2#/G3#→SI2), error results, and final outcomes
- BasePlayer.active_position_rating: Optional field for current defensive position

Enums Extended:
- PlayOutcome.X_CHECK: New outcome type requiring special resolution
- PlayOutcome.is_x_check(): Helper method for type checking

Documentation Enhanced:
- Play.check_pos: Documented as X-Check position identifier
- Play.hit_type: Documented with examples (single_2_plus_error_1, etc.)

Utilities Added:
- app/core/cache.py: Redis cache key helpers for player positions and game state

Implementation Planning:
- Complete 6-phase implementation plan (3A-3F) documented in .claude/implementation/
- Phase 3A complete with all acceptance criteria met
- Zero breaking changes, all existing tests passing

Next: Phase 3B will add defense tables, error charts, and advancement logic

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 15:32:09 -05:00

41 lines
739 B
Python

"""
Redis cache key patterns and helper functions.
Author: Claude
Date: 2025-11-01
"""
def get_player_positions_cache_key(player_id: int) -> str:
"""
Get Redis cache key for player's position ratings.
Args:
player_id: Player ID
Returns:
Cache key string
Example:
>>> get_player_positions_cache_key(10932)
'player:10932:positions'
"""
return f"player:{player_id}:positions"
def get_game_state_cache_key(game_id: int) -> str:
"""
Get Redis cache key for game state.
Args:
game_id: Game ID
Returns:
Cache key string
Example:
>>> get_game_state_cache_key(123)
'game:123:state'
"""
return f"game:{game_id}:state"