strat-gameplay-webapp/backend/app/services/__init__.py
Cal Corum b15f80310b CLAUDE: Add LineupService and SBA API client for player data integration
Created centralized services for SBA player data fetching at lineup creation:

Backend - New Services:
- app/services/sba_api_client.py: REST client for SBA API (api.sba.manticorum.com)
  with batch player fetching and caching support
- app/services/lineup_service.py: High-level service combining DB operations
  with API calls for complete lineup entries with player data

Backend - Refactored Components:
- app/core/game_engine.py: Replaced raw API calls with LineupService,
  reduced _prepare_next_play() from ~50 lines to ~15 lines
- app/core/substitution_manager.py: Updated pinch_hit(), defensive_replace(),
  change_pitcher() to use lineup_service.get_sba_player_data()
- app/models/game_models.py: Added player_name/player_image to LineupPlayerState
- app/services/__init__.py: Exported new LineupService components
- app/websocket/handlers.py: Enhanced lineup state handling

Frontend - SBA League:
- components/Game/CurrentSituation.vue: Restored player images with fallback
  badges (P/B letters) for both mobile and desktop layouts
- components/Game/GameBoard.vue: Enhanced game board visualization
- composables/useGameActions.ts: Updated game action handling
- composables/useWebSocket.ts: Improved WebSocket state management
- pages/games/[id].vue: Enhanced game page with better state handling
- types/game.ts: Updated type definitions
- types/websocket.ts: Added WebSocket type support

Architecture Improvement:
All SBA player data fetching now goes through LineupService:
- Lineup creation: add_sba_player_to_lineup()
- Lineup loading: load_team_lineup_with_player_data()
- Substitutions: get_sba_player_data()

All 739 unit tests pass.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-19 11:55:18 -06:00

37 lines
1.2 KiB
Python

"""
Services - External API clients and caching services.
Provides access to external APIs and caching layers for the game engine.
Author: Claude
Date: 2025-11-03
"""
from app.services.pd_api_client import PdApiClient, pd_api_client
from app.services.sba_api_client import SbaApiClient, sba_api_client
from app.services.position_rating_service import PositionRatingService, position_rating_service
from app.services.redis_client import RedisClient, redis_client
from app.services.play_stat_calculator import PlayStatCalculator
from app.services.box_score_service import BoxScoreService, box_score_service
from app.services.stat_view_refresher import StatViewRefresher, stat_view_refresher
from app.services.lineup_service import LineupService, LineupEntryWithPlayer, lineup_service
__all__ = [
"PdApiClient",
"pd_api_client",
"SbaApiClient",
"sba_api_client",
"PositionRatingService",
"position_rating_service",
"RedisClient",
"redis_client",
"PlayStatCalculator",
"BoxScoreService",
"box_score_service",
"StatViewRefresher",
"stat_view_refresher",
"LineupService",
"LineupEntryWithPlayer",
"lineup_service",
]