fix: validate player positions in lineup before game start #9

Merged
cal merged 2 commits from fix/position-validation-lineup into main 2026-02-08 03:17:24 +00:00
Owner

Summary- Adds early position validation in get_lineups_from_sheets that checks a player's pos_1-pos_8 fields against the assigned lineup position before the game starts- Wraps get_position calls in read_lineup with proper PositionNotFoundException handling for a safety net- Catches PositionNotFoundException at all 3 read_lineup call sites in cogs/gameplay.py, deactivates the game on failure, and sends a clear error message to the user## ContextA user reported: PositionNotFoundException: C ratings not found for 2024 Aaron Judge — their Google Sheet had an outfielder (Aaron Judge) listed at Catcher. Previously this crashed the command and left the game stuck in an active state with no plays.## Changes- command_logic/logic_gameplay.py: Position validation in get_lineups_from_sheets + error handling in read_lineup- cogs/gameplay.py: PositionNotFoundException handling at mlb-campaign, gauntlet, and set-lineup call sites## Test plan- [ ] Start an mlb-campaign with a player at an invalid position → should get a clear error and game should be deactivated- [ ] Start an mlb-campaign with valid positions → should work as before- [ ] DH position should not be validated (any player can DH)

## Summary- Adds early position validation in `get_lineups_from_sheets` that checks a player's pos_1-pos_8 fields against the assigned lineup position before the game starts- Wraps `get_position` calls in `read_lineup` with proper `PositionNotFoundException` handling for a safety net- Catches `PositionNotFoundException` at all 3 `read_lineup` call sites in `cogs/gameplay.py`, deactivates the game on failure, and sends a clear error message to the user## ContextA user reported: `PositionNotFoundException: C ratings not found for 2024 Aaron Judge` — their Google Sheet had an outfielder (Aaron Judge) listed at Catcher. Previously this crashed the command and left the game stuck in an active state with no plays.## Changes- `command_logic/logic_gameplay.py`: Position validation in `get_lineups_from_sheets` + error handling in `read_lineup`- `cogs/gameplay.py`: `PositionNotFoundException` handling at mlb-campaign, gauntlet, and set-lineup call sites## Test plan- [ ] Start an mlb-campaign with a player at an invalid position → should get a clear error and game should be deactivated- [ ] Start an mlb-campaign with valid positions → should work as before- [ ] DH position should not be validated (any player can DH)
cal added 1 commit 2026-02-08 01:32:44 +00:00
fix: validate player positions in lineup before game start
Some checks failed
Build Docker Image / build (pull_request) Failing after 16s
c4577ed46f
Prevents PositionNotFoundException from crashing mlb-campaign when a
player is placed at a position they cannot play (e.g. an outfielder
listed at Catcher in the Google Sheet). Adds early validation in
get_lineups_from_sheets and proper error handling at all read_lineup
call sites so the user gets a clear message and the game is cleaned up.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cal added 1 commit 2026-02-08 03:03:54 +00:00
Update VERSION
All checks were successful
Build Docker Image / build (pull_request) Successful in 5m27s
a79bfbe6eb
cal merged commit a0b5feebf7 into main 2026-02-08 03:17:24 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/paper-dynasty-discord#9
No description provided.