feat: Implement game restart, battlefield styling with art crops and tapped stacks, and initial draw fixes.
Some checks failed
Build and Deploy / build (push) Failing after 1m10s
Some checks failed
Build and Deploy / build (push) Failing after 1m10s
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
# 2024-12-18 - Fix Strict Action Payload Construction
|
||||
|
||||
## Problem
|
||||
The user reported a server crash/error: `Rule Violation [UNKNOWN]: Cannot read properties of undefined (reading 'type')`.
|
||||
This occurred when resolving lands or casting spells. The error log "UNKNOWN" indicated the server received a null/undefined `action` object within the `game_strict_action` event payload.
|
||||
The server expects `socket.emit('game_strict_action', { action: { type: '...' } })`.
|
||||
The client was emitting `socket.emit('game_strict_action', { type: '...' })` (missing the `action` wrapper).
|
||||
|
||||
## Root Cause
|
||||
When refactoring for the Strict Actions, the frontend calls for `handleZoneDrop` (Battlefield), `handleCardDrop`, and `handlePlayerDrop` were updated to emit the new event name `game_strict_action`, but the payload structure was not updated to wrap the data in an `{ action: ... }` object as expected by `server/index.ts`.
|
||||
|
||||
## Solution
|
||||
Updated `GameView.tsx` in three locations (`handleZoneDrop`, `handleCardDrop`, `handlePlayerDrop`) to correctly wrap the payload:
|
||||
```typescript
|
||||
socketService.socket.emit('game_strict_action', {
|
||||
action: {
|
||||
type: '...',
|
||||
...
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Outcome
|
||||
Client strict actions now match the server's expected payload structure. Actions like playing lands or casting spells should now execute defined logic instead of crashing or being treated as unknown.
|
||||
Reference in New Issue
Block a user