CLAUDE: Remove alignment field from frontend - complete Session 1 cleanup

Removed all references to the defensive alignment field across frontend codebase
after backend removal in Session 1. The alignment field was determined to be unused
and was removed from DefensiveDecision model.

Changes:
- types/websocket.ts: Removed alignment from DefensiveDecisionRequest interface
- composables/useGameActions.ts: Removed alignment from submit handler
- pages/demo-decisions.vue: Updated demo state and summary text (alignment → depths)
- pages/games/[id].vue: Updated decision history text for both defensive and offensive
  * Defensive: Now shows "infield depth, outfield depth" instead of "alignment, infield"
  * Offensive: Updated to use new action field with proper labels (swing_away, hit_and_run, etc.)
- Test files (3): Updated all test cases to remove alignment references
  * tests/unit/composables/useGameActions.spec.ts
  * tests/unit/store/game-decisions.spec.ts
  * tests/unit/components/Decisions/DefensiveSetup.spec.ts

Also updated offensive decision handling to match Session 2 changes (approach/hit_and_run/bunt_attempt → action field).

Total: 7 files modified, all alignment references removed
Verified: Zero remaining alignment references in .ts/.vue/.js files

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2025-11-14 15:34:59 -06:00
parent cf4fef22d8
commit 4e7ea9e514
7 changed files with 37 additions and 68 deletions

View File

@ -96,7 +96,6 @@ export function useGameActions(gameId?: string) {
socket.value!.emit('submit_defensive_decision', { socket.value!.emit('submit_defensive_decision', {
game_id: currentGameId.value!, game_id: currentGameId.value!,
alignment: decision.alignment,
infield_depth: decision.infield_depth, infield_depth: decision.infield_depth,
outfield_depth: decision.outfield_depth, outfield_depth: decision.outfield_depth,
hold_runners: decision.hold_runners, hold_runners: decision.hold_runners,

View File

@ -346,7 +346,6 @@ const demoState = ref({
toggle3: false, toggle3: false,
toggle4: true, toggle4: true,
defensiveSetup: { defensiveSetup: {
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [], hold_runners: [],
@ -358,7 +357,7 @@ const demoState = ref({
decisionHistory: [ decisionHistory: [
{ {
type: 'Defensive' as const, type: 'Defensive' as const,
summary: 'normal alignment, normal infield', summary: 'normal infield, normal outfield',
timestamp: '10:45:23', timestamp: '10:45:23',
}, },
{ {
@ -393,7 +392,7 @@ const showToast = (message: string) => {
// Event handlers // Event handlers
const handleDefensiveSubmit = (decision: DefensiveDecision) => { const handleDefensiveSubmit = (decision: DefensiveDecision) => {
demoState.value.defensiveSetup = decision demoState.value.defensiveSetup = decision
const summary = `${decision.alignment} alignment, ${decision.infield_depth} infield` const summary = `${decision.infield_depth} infield, ${decision.outfield_depth} outfield`
demoState.value.decisionHistory.unshift({ demoState.value.decisionHistory.unshift({
type: 'Defensive', type: 'Defensive',
summary, summary,

View File

@ -268,7 +268,7 @@ const handleDefensiveSubmit = async (decision: DefensiveDecision) => {
try { try {
await actions.submitDefensiveDecision(decision) await actions.submitDefensiveDecision(decision)
gameStore.setPendingDefensiveSetup(decision) gameStore.setPendingDefensiveSetup(decision)
gameStore.addDecisionToHistory('Defensive', `${decision.alignment} alignment, ${decision.infield_depth} infield`) gameStore.addDecisionToHistory('Defensive', `${decision.infield_depth} infield, ${decision.outfield_depth} outfield`)
} catch (error) { } catch (error) {
console.error('[Game Page] Failed to submit defensive decision:', error) console.error('[Game Page] Failed to submit defensive decision:', error)
} }
@ -284,7 +284,15 @@ const handleOffensiveSubmit = async (decision: Omit<OffensiveDecision, 'steal_at
} }
await actions.submitOffensiveDecision(fullDecision) await actions.submitOffensiveDecision(fullDecision)
gameStore.setPendingOffensiveDecision(decision) gameStore.setPendingOffensiveDecision(decision)
gameStore.addDecisionToHistory('Offensive', `${decision.approach} approach${decision.hit_and_run ? ', Hit & Run' : ''}${decision.bunt_attempt ? ', Bunt' : ''}`) const actionLabels: Record<string, string> = {
swing_away: 'Swing Away',
steal: 'Steal',
check_jump: 'Check Jump',
hit_and_run: 'Hit & Run',
sac_bunt: 'Sac Bunt',
squeeze_bunt: 'Squeeze Bunt',
}
gameStore.addDecisionToHistory('Offensive', actionLabels[decision.action] || decision.action)
} catch (error) { } catch (error) {
console.error('[Game Page] Failed to submit offensive decision:', error) console.error('[Game Page] Failed to submit offensive decision:', error)
} }

View File

@ -34,7 +34,6 @@ describe('DefensiveSetup', () => {
props: defaultProps, props: defaultProps,
}) })
expect(wrapper.text()).toContain('Defensive Alignment')
expect(wrapper.text()).toContain('Infield Depth') expect(wrapper.text()).toContain('Infield Depth')
expect(wrapper.text()).toContain('Outfield Depth') expect(wrapper.text()).toContain('Outfield Depth')
expect(wrapper.text()).toContain('Hold Runners') expect(wrapper.text()).toContain('Hold Runners')
@ -53,9 +52,8 @@ describe('DefensiveSetup', () => {
it('uses provided currentSetup values', () => { it('uses provided currentSetup values', () => {
const currentSetup: DefensiveDecision = { const currentSetup: DefensiveDecision = {
alignment: 'shifted_left',
infield_depth: 'back', infield_depth: 'back',
outfield_depth: 'deep', outfield_depth: 'normal',
hold_runners: [1, 3], hold_runners: [1, 3],
} }
@ -66,9 +64,8 @@ describe('DefensiveSetup', () => {
}, },
}) })
expect(wrapper.vm.localSetup.alignment).toBe('shifted_left')
expect(wrapper.vm.localSetup.infield_depth).toBe('back') expect(wrapper.vm.localSetup.infield_depth).toBe('back')
expect(wrapper.vm.localSetup.outfield_depth).toBe('deep') expect(wrapper.vm.localSetup.outfield_depth).toBe('normal')
expect(wrapper.vm.localSetup.hold_runners).toEqual([1, 3]) expect(wrapper.vm.localSetup.hold_runners).toEqual([1, 3])
}) })
}) })
@ -79,7 +76,6 @@ describe('DefensiveSetup', () => {
props: { props: {
...defaultProps, ...defaultProps,
currentSetup: { currentSetup: {
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [1, 2], hold_runners: [1, 2],
@ -108,20 +104,19 @@ describe('DefensiveSetup', () => {
}) })
describe('Preview Display', () => { describe('Preview Display', () => {
it('displays current alignment in preview', () => { it('displays current infield depth in preview', () => {
const wrapper = mount(DefensiveSetup, { const wrapper = mount(DefensiveSetup, {
props: { props: {
...defaultProps, ...defaultProps,
currentSetup: { currentSetup: {
alignment: 'extreme_shift', infield_depth: 'back',
infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [], hold_runners: [],
}, },
}, },
}) })
expect(wrapper.text()).toContain('Extreme') expect(wrapper.text()).toContain('Back')
}) })
it('displays holding status for multiple runners', () => { it('displays holding status for multiple runners', () => {
@ -129,7 +124,6 @@ describe('DefensiveSetup', () => {
props: { props: {
...defaultProps, ...defaultProps,
currentSetup: { currentSetup: {
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [1, 2, 3], hold_runners: [1, 2, 3],
@ -159,9 +153,8 @@ describe('DefensiveSetup', () => {
}) })
wrapper.vm.localSetup = { wrapper.vm.localSetup = {
alignment: 'shifted_right',
infield_depth: 'in', infield_depth: 'in',
outfield_depth: 'back', outfield_depth: 'normal',
hold_runners: [2], hold_runners: [2],
} }
@ -169,9 +162,8 @@ describe('DefensiveSetup', () => {
expect(wrapper.emitted('submit')).toBeTruthy() expect(wrapper.emitted('submit')).toBeTruthy()
const emitted = wrapper.emitted('submit')![0][0] as DefensiveDecision const emitted = wrapper.emitted('submit')![0][0] as DefensiveDecision
expect(emitted.alignment).toBe('shifted_right')
expect(emitted.infield_depth).toBe('in') expect(emitted.infield_depth).toBe('in')
expect(emitted.outfield_depth).toBe('back') expect(emitted.outfield_depth).toBe('normal')
expect(emitted.hold_runners).toEqual([2]) expect(emitted.hold_runners).toEqual([2])
}) })
@ -189,7 +181,6 @@ describe('DefensiveSetup', () => {
it('does not submit when no changes', async () => { it('does not submit when no changes', async () => {
const currentSetup: DefensiveDecision = { const currentSetup: DefensiveDecision = {
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [], hold_runners: [],
@ -234,7 +225,6 @@ describe('DefensiveSetup', () => {
it('shows "No Changes" when setup unchanged', () => { it('shows "No Changes" when setup unchanged', () => {
const currentSetup: DefensiveDecision = { const currentSetup: DefensiveDecision = {
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [], hold_runners: [],
@ -255,18 +245,17 @@ describe('DefensiveSetup', () => {
props: defaultProps, props: defaultProps,
}) })
wrapper.vm.localSetup.alignment = 'shifted_left' wrapper.vm.localSetup.infield_depth = 'back'
expect(wrapper.vm.submitButtonText).toBe('Submit Defensive Setup') expect(wrapper.vm.submitButtonText).toBe('Submit Defensive Setup')
}) })
}) })
describe('Change Detection', () => { describe('Change Detection', () => {
it('detects alignment changes', () => { it('detects infield depth changes', () => {
const wrapper = mount(DefensiveSetup, { const wrapper = mount(DefensiveSetup, {
props: { props: {
...defaultProps, ...defaultProps,
currentSetup: { currentSetup: {
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [], hold_runners: [],
@ -275,7 +264,7 @@ describe('DefensiveSetup', () => {
}) })
expect(wrapper.vm.hasChanges).toBe(false) expect(wrapper.vm.hasChanges).toBe(false)
wrapper.vm.localSetup.alignment = 'shifted_left' wrapper.vm.localSetup.infield_depth = 'back'
expect(wrapper.vm.hasChanges).toBe(true) expect(wrapper.vm.hasChanges).toBe(true)
}) })
@ -284,7 +273,6 @@ describe('DefensiveSetup', () => {
props: { props: {
...defaultProps, ...defaultProps,
currentSetup: { currentSetup: {
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [], hold_runners: [],
@ -305,17 +293,15 @@ describe('DefensiveSetup', () => {
}) })
const newSetup: DefensiveDecision = { const newSetup: DefensiveDecision = {
alignment: 'extreme_shift',
infield_depth: 'double_play', infield_depth: 'double_play',
outfield_depth: 'back', outfield_depth: 'normal',
hold_runners: [1, 2, 3], hold_runners: [1, 2, 3],
} }
await wrapper.setProps({ currentSetup: newSetup }) await wrapper.setProps({ currentSetup: newSetup })
expect(wrapper.vm.localSetup.alignment).toBe('extreme_shift')
expect(wrapper.vm.localSetup.infield_depth).toBe('double_play') expect(wrapper.vm.localSetup.infield_depth).toBe('double_play')
expect(wrapper.vm.localSetup.outfield_depth).toBe('back') expect(wrapper.vm.localSetup.outfield_depth).toBe('normal')
expect(wrapper.vm.localSetup.hold_runners).toEqual([1, 2, 3]) expect(wrapper.vm.localSetup.hold_runners).toEqual([1, 2, 3])
}) })
}) })

View File

@ -205,7 +205,6 @@ describe('useGameActions', () => {
describe('strategic decision actions', () => { describe('strategic decision actions', () => {
it('emits defensive decision with correct parameters', () => { it('emits defensive decision with correct parameters', () => {
const decision: DefensiveDecision = { const decision: DefensiveDecision = {
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [], hold_runners: [],
@ -216,7 +215,6 @@ describe('useGameActions', () => {
expect(mockSocket.value.emit).toHaveBeenCalledWith('submit_defensive_decision', { expect(mockSocket.value.emit).toHaveBeenCalledWith('submit_defensive_decision', {
game_id: 'game-123', game_id: 'game-123',
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [], hold_runners: [],
@ -225,10 +223,8 @@ describe('useGameActions', () => {
it('emits offensive decision with correct parameters', () => { it('emits offensive decision with correct parameters', () => {
const decision: OffensiveDecision = { const decision: OffensiveDecision = {
approach: 'normal', action: 'steal',
steal_attempts: [2], steal_attempts: [2],
hit_and_run: false,
bunt_attempt: false,
} }
const actions = useGameActions() const actions = useGameActions()
@ -236,10 +232,8 @@ describe('useGameActions', () => {
expect(mockSocket.value.emit).toHaveBeenCalledWith('submit_offensive_decision', { expect(mockSocket.value.emit).toHaveBeenCalledWith('submit_offensive_decision', {
game_id: 'game-123', game_id: 'game-123',
approach: 'normal', action: 'steal',
steal_attempts: [2], steal_attempts: [2],
hit_and_run: false,
bunt_attempt: false,
}) })
}) })
}) })
@ -380,7 +374,6 @@ describe('useGameActions', () => {
const actions = useGameActions() const actions = useGameActions()
actions.rollDice() actions.rollDice()
actions.submitDefensiveDecision({ actions.submitDefensiveDecision({
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [], hold_runners: [],

View File

@ -12,7 +12,6 @@ describe('Game Store - Decision Methods', () => {
it('sets defensive setup', () => { it('sets defensive setup', () => {
const store = useGameStore() const store = useGameStore()
const setup: DefensiveDecision = { const setup: DefensiveDecision = {
alignment: 'shifted_left',
infield_depth: 'back', infield_depth: 'back',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [1, 3], hold_runners: [1, 3],
@ -25,7 +24,6 @@ describe('Game Store - Decision Methods', () => {
it('clears defensive setup with null', () => { it('clears defensive setup with null', () => {
const store = useGameStore() const store = useGameStore()
const setup: DefensiveDecision = { const setup: DefensiveDecision = {
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [], hold_runners: [],
@ -41,9 +39,7 @@ describe('Game Store - Decision Methods', () => {
it('sets offensive decision', () => { it('sets offensive decision', () => {
const store = useGameStore() const store = useGameStore()
const decision: Omit<OffensiveDecision, 'steal_attempts'> = { const decision: Omit<OffensiveDecision, 'steal_attempts'> = {
approach: 'power', action: 'hit_and_run',
hit_and_run: true,
bunt_attempt: false,
} }
store.setPendingOffensiveDecision(decision) store.setPendingOffensiveDecision(decision)
@ -53,9 +49,7 @@ describe('Game Store - Decision Methods', () => {
it('clears offensive decision with null', () => { it('clears offensive decision with null', () => {
const store = useGameStore() const store = useGameStore()
const decision: Omit<OffensiveDecision, 'steal_attempts'> = { const decision: Omit<OffensiveDecision, 'steal_attempts'> = {
approach: 'normal', action: 'swing_away',
hit_and_run: false,
bunt_attempt: false,
} }
store.setPendingOffensiveDecision(decision) store.setPendingOffensiveDecision(decision)
@ -89,21 +83,21 @@ describe('Game Store - Decision Methods', () => {
describe('addDecisionToHistory', () => { describe('addDecisionToHistory', () => {
it('adds defensive decision to history', () => { it('adds defensive decision to history', () => {
const store = useGameStore() const store = useGameStore()
store.addDecisionToHistory('Defensive', 'normal alignment, normal infield') store.addDecisionToHistory('Defensive', 'normal infield, normal outfield')
expect(store.decisionHistory).toHaveLength(1) expect(store.decisionHistory).toHaveLength(1)
expect(store.decisionHistory[0].type).toBe('Defensive') expect(store.decisionHistory[0].type).toBe('Defensive')
expect(store.decisionHistory[0].summary).toBe('normal alignment, normal infield') expect(store.decisionHistory[0].summary).toBe('normal infield, normal outfield')
expect(store.decisionHistory[0].timestamp).toBeDefined() expect(store.decisionHistory[0].timestamp).toBeDefined()
}) })
it('adds offensive decision to history', () => { it('adds offensive decision to history', () => {
const store = useGameStore() const store = useGameStore()
store.addDecisionToHistory('Offensive', 'power approach, Hit & Run') store.addDecisionToHistory('Offensive', 'Hit & Run')
expect(store.decisionHistory).toHaveLength(1) expect(store.decisionHistory).toHaveLength(1)
expect(store.decisionHistory[0].type).toBe('Offensive') expect(store.decisionHistory[0].type).toBe('Offensive')
expect(store.decisionHistory[0].summary).toBe('power approach, Hit & Run') expect(store.decisionHistory[0].summary).toBe('Hit & Run')
}) })
it('adds new decisions to the front of history', () => { it('adds new decisions to the front of history', () => {
@ -135,15 +129,12 @@ describe('Game Store - Decision Methods', () => {
// Set all pending decisions // Set all pending decisions
store.setPendingDefensiveSetup({ store.setPendingDefensiveSetup({
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [], hold_runners: [],
}) })
store.setPendingOffensiveDecision({ store.setPendingOffensiveDecision({
approach: 'normal', action: 'swing_away',
hit_and_run: false,
bunt_attempt: false,
}) })
store.setPendingStealAttempts([2, 3]) store.setPendingStealAttempts([2, 3])
@ -172,15 +163,12 @@ describe('Game Store - Decision Methods', () => {
// Set decisions and history // Set decisions and history
store.setPendingDefensiveSetup({ store.setPendingDefensiveSetup({
alignment: 'normal',
infield_depth: 'normal', infield_depth: 'normal',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [], hold_runners: [],
}) })
store.setPendingOffensiveDecision({ store.setPendingOffensiveDecision({
approach: 'power', action: 'hit_and_run',
hit_and_run: true,
bunt_attempt: false,
}) })
store.setPendingStealAttempts([2]) store.setPendingStealAttempts([2])
store.addDecisionToHistory('Defensive', 'test') store.addDecisionToHistory('Defensive', 'test')
@ -202,23 +190,20 @@ describe('Game Store - Decision Methods', () => {
// Set defensive decision // Set defensive decision
const defensiveSetup: DefensiveDecision = { const defensiveSetup: DefensiveDecision = {
alignment: 'shifted_left',
infield_depth: 'double_play', infield_depth: 'double_play',
outfield_depth: 'normal', outfield_depth: 'normal',
hold_runners: [1], hold_runners: [1],
} }
store.setPendingDefensiveSetup(defensiveSetup) store.setPendingDefensiveSetup(defensiveSetup)
store.addDecisionToHistory('Defensive', 'shifted_left alignment, double_play infield') store.addDecisionToHistory('Defensive', 'double_play infield, normal outfield')
// Set offensive decision // Set offensive decision
const offensiveDecision: Omit<OffensiveDecision, 'steal_attempts'> = { const offensiveDecision: Omit<OffensiveDecision, 'steal_attempts'> = {
approach: 'contact', action: 'sac_bunt',
hit_and_run: false,
bunt_attempt: true,
} }
store.setPendingOffensiveDecision(offensiveDecision) store.setPendingOffensiveDecision(offensiveDecision)
store.setPendingStealAttempts([]) store.setPendingStealAttempts([])
store.addDecisionToHistory('Offensive', 'contact approach, Bunt') store.addDecisionToHistory('Offensive', 'Sac Bunt')
// Verify all state // Verify all state
expect(store.pendingDefensiveSetup).toEqual(defensiveSetup) expect(store.pendingDefensiveSetup).toEqual(defensiveSetup)

View File

@ -117,7 +117,6 @@ export interface LeaveGameRequest {
export interface DefensiveDecisionRequest { export interface DefensiveDecisionRequest {
game_id: string game_id: string
alignment: DefensiveDecision['alignment']
infield_depth: DefensiveDecision['infield_depth'] infield_depth: DefensiveDecision['infield_depth']
outfield_depth: DefensiveDecision['outfield_depth'] outfield_depth: DefensiveDecision['outfield_depth']
hold_runners: number[] hold_runners: number[]