diff --git a/src/Koogle.Web/Components/Game/GameInputPanel.razor b/src/Koogle.Web/Components/Game/GameInputPanel.razor index 3db5d3d..3609731 100644 --- a/src/Koogle.Web/Components/Game/GameInputPanel.razor +++ b/src/Koogle.Web/Components/Game/GameInputPanel.razor @@ -208,8 +208,8 @@ var newStatus = currentStatus == PinStatus.Standing ? PinStatus.Fallen : PinStatus.Standing; - Dispatcher.Dispatch(new SetPinStatusAction(pinNumber, newStatus)); _hasModifiedPins = true; + Dispatcher.Dispatch(new SetPinStatusAction(pinNumber, newStatus)); _selectedNumber = null; } @@ -224,15 +224,16 @@ newState = newState.SetPin(i, status); } + // Set flag BEFORE dispatching to prevent CaptureBeforeThrowState in StateChanged + _hasModifiedPins = true; + _selectedNumber = number; + // Dispatch individual pin updates to match the new state for (int i = 1; i <= 9; i++) { var targetStatus = i <= number ? PinStatus.Fallen : PinStatus.Standing; Dispatcher.Dispatch(new SetPinStatusAction(i, targetStatus)); } - - _selectedNumber = number; - _hasModifiedPins = true; } private void HandleBellClick() @@ -276,9 +277,11 @@ // Dispatch record throw action - game logic will handle pin reset and player rotation Dispatcher.Dispatch(new RecordThrowAction(beforeState, currentThrowPanel, isGutter, isLeftGutter)); - // Reset local state + // Reset local state and capture new before-state for next throw + // (Dispatch is synchronous, so state is already updated with pin reset) _selectedNumber = null; _hasModifiedPins = false; + CaptureBeforeThrowState(); // Notify parent (for timer/tab switching) await OnThrowCompleted.InvokeAsync(result);