- Added OUTFIELD_ONLY_OUTCOMES constant for flyout_a, flyout_b, flyout_c - Added showInfieldLocations computed to hide infield for flyballs - Updated selectOutcome to clear infield location when switching to flyball - Mirrors existing groundball logic that hides outfield positions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
113 lines
2.4 KiB
TypeScript
113 lines
2.4 KiB
TypeScript
/**
|
|
* Outcome Constants
|
|
*
|
|
* Centralized definitions for play outcomes used across the UI.
|
|
* These match the backend PlayOutcome enum values.
|
|
*/
|
|
|
|
import type { PlayOutcome } from '~/types/game'
|
|
|
|
/**
|
|
* Outcome categories for UI display and selection
|
|
* Grouped by common baseball categories for user-friendly selection
|
|
*/
|
|
export const OUTCOME_CATEGORIES = [
|
|
{
|
|
name: 'Outs',
|
|
outcomes: [
|
|
'strikeout',
|
|
'groundball_a',
|
|
'groundball_b',
|
|
'groundball_c',
|
|
'flyout_a',
|
|
'flyout_b',
|
|
'flyout_c',
|
|
'lineout',
|
|
'popout',
|
|
] as const satisfies readonly PlayOutcome[],
|
|
},
|
|
{
|
|
name: 'Hits',
|
|
outcomes: [
|
|
'single_1',
|
|
'single_2',
|
|
'single_uncapped',
|
|
'double_2',
|
|
'double_3',
|
|
'double_uncapped',
|
|
'triple',
|
|
'homerun',
|
|
] as const satisfies readonly PlayOutcome[],
|
|
},
|
|
{
|
|
name: 'Walks / HBP',
|
|
outcomes: [
|
|
'walk',
|
|
'intentional_walk',
|
|
'hbp',
|
|
] as const satisfies readonly PlayOutcome[],
|
|
},
|
|
{
|
|
name: 'Special',
|
|
outcomes: [
|
|
'error',
|
|
'x_check',
|
|
] as const satisfies readonly PlayOutcome[],
|
|
},
|
|
{
|
|
name: 'Interrupts',
|
|
outcomes: [
|
|
'stolen_base',
|
|
'caught_stealing',
|
|
'wild_pitch',
|
|
'passed_ball',
|
|
'balk',
|
|
'pick_off',
|
|
] as const satisfies readonly PlayOutcome[],
|
|
},
|
|
] as const
|
|
|
|
/**
|
|
* Outcomes that require a hit location to be specified
|
|
* These outcomes involve defensive plays where location matters
|
|
*/
|
|
export const OUTCOMES_REQUIRING_HIT_LOCATION = [
|
|
'groundball_a',
|
|
'groundball_b',
|
|
'groundball_c',
|
|
'flyout_a',
|
|
'flyout_b',
|
|
'flyout_c',
|
|
'lineout',
|
|
'single_uncapped',
|
|
'double_uncapped',
|
|
'error',
|
|
] as const satisfies readonly PlayOutcome[]
|
|
|
|
/**
|
|
* Outcomes that only allow infield hit locations (no outfield)
|
|
* Groundballs by definition stay in the infield
|
|
*/
|
|
export const INFIELD_ONLY_OUTCOMES = [
|
|
'groundball_a',
|
|
'groundball_b',
|
|
'groundball_c',
|
|
] as const satisfies readonly PlayOutcome[]
|
|
|
|
/**
|
|
* Outcomes that only allow outfield hit locations (no infield)
|
|
* Flyballs by definition go to the outfield
|
|
*/
|
|
export const OUTFIELD_ONLY_OUTCOMES = [
|
|
'flyout_a',
|
|
'flyout_b',
|
|
'flyout_c',
|
|
] as const satisfies readonly PlayOutcome[]
|
|
|
|
/**
|
|
* Hit location options
|
|
*/
|
|
export const HIT_LOCATIONS = {
|
|
infield: ['P', 'C', '1B', '2B', '3B', 'SS'] as const,
|
|
outfield: ['LF', 'CF', 'RF'] as const,
|
|
} as const |