Backend fixes: - state_manager: Properly recover current_pitcher and current_catcher from fielding team during game state recovery (fixes pitcher badge not showing) - handlers: Add headshot field to lineup data, use lineup_service for proper player data loading on cache miss - lineup_service: Minor adjustments for headshot support Frontend fixes: - player.ts: Update Lineup type to match WebSocket event format - lineup_id (was 'id'), card_id fields - player.headshot for UI circles - Optional fields for event variations - CurrentSituation.vue: Adapt to updated type structure - Substitution selectors: Use updated Lineup type fields This fixes the issue where pitcher badge wouldn't show after game recovery because current_pitcher was being set from batting team instead of fielding team. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
146 lines
3.0 KiB
TypeScript
146 lines
3.0 KiB
TypeScript
/**
|
|
* Player and Lineup Types
|
|
*
|
|
* TypeScript definitions for SBA player models.
|
|
* Matches backend SbaPlayer and Lineup structures.
|
|
*
|
|
* Backend Reference: app/models/player_models.py
|
|
*/
|
|
|
|
/**
|
|
* SBA Player - Simple player model
|
|
* Backend: SbaPlayer
|
|
*/
|
|
export interface SbaPlayer {
|
|
// Identity
|
|
id: number
|
|
name: string
|
|
|
|
// Images
|
|
image: string
|
|
image2?: string | null
|
|
headshot?: string | null
|
|
vanity_card?: string | null
|
|
|
|
// Positions (up to 8)
|
|
pos_1?: string | null
|
|
pos_2?: string | null
|
|
pos_3?: string | null
|
|
pos_4?: string | null
|
|
pos_5?: string | null
|
|
pos_6?: string | null
|
|
pos_7?: string | null
|
|
pos_8?: string | null
|
|
|
|
// Stats
|
|
wara?: number | null
|
|
|
|
// Team info
|
|
team_id?: number | null
|
|
team_name?: string | null
|
|
season?: string | null
|
|
|
|
// References
|
|
strat_code?: string | null
|
|
bbref_id?: string | null
|
|
injury_rating?: string | null
|
|
}
|
|
|
|
/**
|
|
* Lineup entry - player assignment in a game
|
|
* Backend: Lineup (db model) via WebSocket lineup_data event
|
|
*/
|
|
export interface Lineup {
|
|
lineup_id: number // Unique lineup entry ID (was 'id')
|
|
card_id: number // Player/card ID
|
|
game_id?: string // Optional - not always sent in events
|
|
team_id?: number // Optional - not always sent in events
|
|
position: string
|
|
batting_order: number | null
|
|
is_starter: boolean
|
|
is_active: boolean
|
|
entered_inning?: number // Optional - not always sent in events
|
|
|
|
// Substitution tracking (optional - not always sent in events)
|
|
replacing_id?: number | null
|
|
after_play?: number | null
|
|
is_fatigued?: boolean
|
|
|
|
// Player data (embedded from SBA API)
|
|
player: {
|
|
id: number
|
|
name: string
|
|
image: string // Card image
|
|
headshot: string // Headshot for UI circles
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Team lineup - collection of players for a team
|
|
*/
|
|
export interface TeamLineup {
|
|
team_id: number
|
|
players: Lineup[]
|
|
}
|
|
|
|
/**
|
|
* Lineup data response from server
|
|
*/
|
|
export interface LineupDataResponse {
|
|
game_id: string
|
|
team_id: number
|
|
players: Lineup[]
|
|
}
|
|
|
|
/**
|
|
* Substitution types
|
|
*/
|
|
export type SubstitutionType = 'pinch_hitter' | 'defensive_replacement' | 'pitching_change'
|
|
|
|
/**
|
|
* Substitution request
|
|
*/
|
|
export interface SubstitutionRequest {
|
|
game_id: string
|
|
type: SubstitutionType
|
|
player_out_lineup_id: number
|
|
player_in_card_id: number
|
|
team_id: number
|
|
new_position?: string // Required for defensive replacement
|
|
}
|
|
|
|
/**
|
|
* Substitution result from server
|
|
*/
|
|
export interface SubstitutionResult {
|
|
type: SubstitutionType
|
|
player_out_lineup_id: number
|
|
player_in_card_id: number
|
|
new_lineup_id: number
|
|
position: string
|
|
batting_order: number | null
|
|
team_id: number
|
|
message: string
|
|
}
|
|
|
|
/**
|
|
* Substitution error codes
|
|
*/
|
|
export type SubstitutionErrorCode =
|
|
| 'MISSING_FIELD'
|
|
| 'INVALID_FORMAT'
|
|
| 'NOT_CURRENT_BATTER'
|
|
| 'PLAYER_ALREADY_OUT'
|
|
| 'NOT_IN_ROSTER'
|
|
| 'ALREADY_ACTIVE'
|
|
| 'INVALID_POSITION'
|
|
|
|
/**
|
|
* Substitution error response
|
|
*/
|
|
export interface SubstitutionError {
|
|
code: SubstitutionErrorCode
|
|
message: string
|
|
field?: string
|
|
}
|