Week 6 Progress: 75% Complete ## Components Implemented ### 1. League Configuration System ✅ - Created BaseGameConfig abstract class for league-agnostic rules - Implemented SbaConfig and PdConfig with league-specific settings - Immutable configs (frozen=True) with singleton registry - 28 unit tests, all passing Files: - backend/app/config/base_config.py - backend/app/config/league_configs.py - backend/tests/unit/config/test_league_configs.py ### 2. PlayOutcome Enum ✅ - Universal enum for all play outcomes (both SBA and PD) - Helper methods: is_hit(), is_out(), is_uncapped(), is_interrupt() - Supports standard hits, uncapped hits, interrupt plays, ballpark power - 30 unit tests, all passing Files: - backend/app/config/result_charts.py - backend/tests/unit/config/test_play_outcome.py ### 3. Player Model Refinements ✅ - Fixed PdPlayer.id field mapping (player_id → id) - Improved field docstrings for image types - Fixed position checking logic in SBA helper methods - Added safety checks for missing image data Files: - backend/app/models/player_models.py (updated) ### 4. Documentation ✅ - Updated backend/CLAUDE.md with Week 6 section - Documented card-based resolution mechanics - Detailed config system and PlayOutcome usage ## Architecture Decisions 1. **Card-Based Resolution**: Both SBA and PD use same mechanics - 1d6 (column) + 2d6 (row) + 1d20 (split resolution) - PD: Digitized cards with auto-resolution - SBA: Manual entry from physical cards 2. **Immutable Configs**: Prevent accidental modification using Pydantic frozen 3. **Universal PlayOutcome**: Single enum for both leagues reduces duplication ## Testing - Total: 58 tests, all passing - Config tests: 28 - PlayOutcome tests: 30 ## Remaining Work (25%) - Update dice system (check_d20 → chaos_d20) - Integrate PlayOutcome into PlayResolver - Add Play.metadata support for uncapped hits 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
63 lines
2.0 KiB
Python
63 lines
2.0 KiB
Python
"""
|
|
Base configuration class for league-specific game rules.
|
|
|
|
Provides abstract interface that all league configs must implement.
|
|
|
|
Author: Claude
|
|
Date: 2025-10-28
|
|
"""
|
|
from abc import ABC, abstractmethod
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class BaseGameConfig(BaseModel, ABC):
|
|
"""
|
|
Abstract base configuration for all leagues.
|
|
|
|
Defines common game rules and requires league-specific implementations
|
|
to provide result chart names, API endpoints, and feature flags.
|
|
"""
|
|
|
|
league_id: str = Field(..., description="League identifier ('sba' or 'pd')")
|
|
version: str = Field(default="1.0.0", description="Config version for compatibility")
|
|
|
|
# Basic baseball rules (same across leagues)
|
|
innings: int = Field(default=9, description="Standard innings per game")
|
|
outs_per_inning: int = Field(default=3, description="Outs required per half-inning")
|
|
strikes_for_out: int = Field(default=3, description="Strikes for strikeout") # TODO: remove - unneeded
|
|
balls_for_walk: int = Field(default=4, description="Balls for walk") # TODO: remove - unneeded
|
|
|
|
@abstractmethod
|
|
def get_result_chart_name(self) -> str:
|
|
"""
|
|
Get name of result chart to use for this league.
|
|
|
|
Returns:
|
|
Chart name identifier (e.g., 'sba_standard_v1')
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def supports_manual_result_selection(self) -> bool: # TODO: consider refactor: manually selecting results is default behavior with PD allowing auto-results as an option
|
|
"""
|
|
Whether players manually select results after dice roll.
|
|
|
|
Returns:
|
|
True if players pick from chart, False if auto-resolved
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_api_base_url(self) -> str:
|
|
"""
|
|
Get base URL for league's external API.
|
|
|
|
Returns:
|
|
Base URL for roster/player data API
|
|
"""
|
|
pass
|
|
|
|
class Config:
|
|
"""Pydantic configuration."""
|
|
frozen = True # Immutable config - prevents accidental modification
|