16 lines
1.1 KiB
Markdown
16 lines
1.1 KiB
Markdown
# 2024-12-18 - Implement Manual Card Draw
|
|
|
|
## Problem
|
|
The user reported that clicking on the library or using the "Draw Card" context menu option had no effect. The frontend was correctly emitting the `DRAW_CARD` action (via `game_action` channel/event), but the `GameManager` (which handles manual/legacy actions) had no case handler for it, causing the action to be ignored.
|
|
|
|
## Root Cause
|
|
1. **Missing Handler**: The `GameManager.handleAction` switch statement lacked a `case 'DRAW_CARD'`.
|
|
2. **Access Control**: The `RulesEngine.drawCard` method was `private`, preventing external invocation even if the handler existed.
|
|
|
|
## Solution
|
|
1. **Made `drawCard` Public**: Updated `RulesEngine.ts` to change `drawCard` visibility from `private` to `public`.
|
|
2. **Added Handler**: Updated `GameManager.ts` to include a `case 'DRAW_CARD'` in `handleAction`. This handler instantiates a `RulesEngine` for the current game and calls `engine.drawCard(actorId)`.
|
|
|
|
## Outcome
|
|
Users can now manually draw cards from their library interactions (click or context menu) during gameplay.
|