Major Refactor: Outcome-First Architecture - PlayResolver now accepts league_id and auto_mode in constructor - Added core resolve_outcome() method - all resolution logic in one place - Added resolve_manual_play() wrapper for manual submissions (primary) - Added resolve_auto_play() wrapper for PD auto mode (rare) - Removed SimplifiedResultChart (obsolete with new architecture) - Removed play_resolver singleton RunnerAdvancement Integration: - All groundball outcomes (GROUNDBALL_A/B/C) now use RunnerAdvancement - Proper DP probability calculation with positioning modifiers - Hit location tracked for all relevant outcomes - 13 result types fully integrated from advancement charts Game State Updates: - Added auto_mode field to GameState (stored per-game) - Updated state_manager.create_game() to accept auto_mode parameter - GameEngine now uses state.auto_mode to create appropriate resolver League Configuration: - Added supports_auto_mode() to BaseGameConfig - SbaConfig: returns False (no digitized cards) - PdConfig: returns True (has digitized ratings) - PlayResolver validates auto mode support and raises error for SBA Play Results: - Added hit_location field to PlayResult - Groundballs include location from RunnerAdvancement - Flyouts track hit_location for tag-up logic (future) - Other outcomes have hit_location=None Testing: - Completely rewrote test_play_resolver.py for new architecture - 9 new tests covering initialization, strikeouts, walks, groundballs, home runs - All 9 tests passing - All 180 core tests still passing (1 pre-existing failure unrelated) Terminal Client: - No changes needed - defaults to manual mode (auto_mode=False) - Perfect for human testing of manual submissions This completes Week 7 Task 6 - the final task of Week 7! Week 7 is now 100% complete with all 8 tasks done. 🎯 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
116 lines
3.1 KiB
Python
116 lines
3.1 KiB
Python
"""
|
|
League-specific configuration implementations.
|
|
|
|
Provides concrete configs for SBA and PD leagues with their unique rules,
|
|
API endpoints, and feature flags.
|
|
|
|
Author: Claude
|
|
Date: 2025-10-28
|
|
"""
|
|
import logging
|
|
from typing import Dict
|
|
from app.config.base_config import BaseGameConfig
|
|
|
|
logger = logging.getLogger(f'{__name__}.LeagueConfigs')
|
|
|
|
|
|
class SbaConfig(BaseGameConfig):
|
|
"""
|
|
SBA League configuration.
|
|
|
|
Features:
|
|
- Manual result selection after dice roll
|
|
- Simple player data model
|
|
- Standard baseball rules
|
|
"""
|
|
|
|
league_id: str = "sba"
|
|
|
|
# SBA-specific features
|
|
player_selection_mode: str = "manual" # Players manually select from chart
|
|
|
|
def get_result_chart_name(self) -> str:
|
|
"""Use SBA standard result chart."""
|
|
return "sba_standard_v1"
|
|
|
|
def supports_manual_result_selection(self) -> bool:
|
|
"""SBA players manually pick results from chart."""
|
|
return True
|
|
|
|
def supports_auto_mode(self) -> bool:
|
|
"""SBA does not support auto mode - cards are not digitized."""
|
|
return False
|
|
|
|
def get_api_base_url(self) -> str:
|
|
"""SBA API base URL."""
|
|
return "https://api.sba.manticorum.com"
|
|
|
|
|
|
class PdConfig(BaseGameConfig):
|
|
"""
|
|
Paper Dynasty League configuration.
|
|
|
|
Features:
|
|
- Flexible result selection (manual or auto via scouting)
|
|
- Complex scouting data model
|
|
- Cardset validation
|
|
- Advanced analytics
|
|
"""
|
|
|
|
league_id: str = "pd"
|
|
|
|
# PD-specific features
|
|
player_selection_mode: str = "flexible" # Manual or auto via scouting model
|
|
use_scouting_model: bool = True # Use detailed ratings for auto-resolution
|
|
cardset_validation: bool = True # Validate cards against approved cardsets
|
|
|
|
# Advanced features
|
|
detailed_analytics: bool = True # Track advanced stats (WPA, RE24, etc.)
|
|
wpa_calculation: bool = True # Calculate win probability added
|
|
|
|
def get_result_chart_name(self) -> str:
|
|
"""Use PD standard result chart."""
|
|
return "pd_standard_v1"
|
|
|
|
def supports_manual_result_selection(self) -> bool:
|
|
"""PD supports manual selection (though auto is also available)."""
|
|
return True
|
|
|
|
def supports_auto_mode(self) -> bool:
|
|
"""PD supports auto mode via digitized scouting data."""
|
|
return True
|
|
|
|
def get_api_base_url(self) -> str:
|
|
"""PD API base URL."""
|
|
return "https://pd.manticorum.com"
|
|
|
|
|
|
# ==================== Config Registry ====================
|
|
|
|
LEAGUE_CONFIGS: Dict[str, BaseGameConfig] = {
|
|
"sba": SbaConfig(),
|
|
"pd": PdConfig()
|
|
}
|
|
|
|
|
|
def get_league_config(league_id: str) -> BaseGameConfig:
|
|
"""
|
|
Get configuration for specified league.
|
|
|
|
Args:
|
|
league_id: League identifier ('sba' or 'pd')
|
|
|
|
Returns:
|
|
League-specific config instance
|
|
|
|
Raises:
|
|
ValueError: If league_id is not recognized
|
|
"""
|
|
config = LEAGUE_CONFIGS.get(league_id)
|
|
if not config:
|
|
logger.error(f"Unknown league ID: {league_id}")
|
|
raise ValueError(f"Unknown league: {league_id}. Valid leagues: {list(LEAGUE_CONFIGS.keys())}")
|
|
|
|
logger.debug(f"Retrieved config for league: {league_id}")
|
|
return config
|