fix gutter
This commit is contained in:
parent
dc1fad14c8
commit
48b96cec0c
|
|
@ -147,10 +147,15 @@ public static class GameProgressExtensions
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates after-throw state from before and after snapshots.
|
/// Creates after-throw state from before and after snapshots.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="afterThrow">Snapshot after the throw.</param>
|
||||||
|
/// <param name="beforeThrow">Snapshot before the throw.</param>
|
||||||
|
/// <param name="playerId">Current player ID.</param>
|
||||||
|
/// <param name="isGutter">Whether the throw went into the gutter (from user input).</param>
|
||||||
public static AfterThrowState CreateAfterThrowState(
|
public static AfterThrowState CreateAfterThrowState(
|
||||||
this ThrowPanelSnapshot afterThrow,
|
this ThrowPanelSnapshot afterThrow,
|
||||||
ThrowPanelSnapshot beforeThrow,
|
ThrowPanelSnapshot beforeThrow,
|
||||||
Guid playerId)
|
Guid playerId,
|
||||||
|
bool isGutter = false)
|
||||||
{
|
{
|
||||||
var pinsKnockedBefore = beforeThrow.PinCount();
|
var pinsKnockedBefore = beforeThrow.PinCount();
|
||||||
var pinsKnockedAfter = afterThrow.PinCount();
|
var pinsKnockedAfter = afterThrow.PinCount();
|
||||||
|
|
@ -162,7 +167,7 @@ public static class GameProgressExtensions
|
||||||
PinsKnocked: pinsKnocked,
|
PinsKnocked: pinsKnocked,
|
||||||
IsCircle: afterThrow.IsCircle(),
|
IsCircle: afterThrow.IsCircle(),
|
||||||
IsStrike: afterThrow.IsStrike(),
|
IsStrike: afterThrow.IsStrike(),
|
||||||
IsGutter: pinsKnocked == 0
|
IsGutter: isGutter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,7 @@
|
||||||
var beforeState = _beforeThrowState ?? currentThrowPanel;
|
var beforeState = _beforeThrowState ?? currentThrowPanel;
|
||||||
|
|
||||||
// Dispatch record throw action - game logic will handle pin reset and player rotation
|
// Dispatch record throw action - game logic will handle pin reset and player rotation
|
||||||
Dispatcher.Dispatch(new RecordThrowAction(beforeState, currentThrowPanel));
|
Dispatcher.Dispatch(new RecordThrowAction(beforeState, currentThrowPanel, isGutter, isLeftGutter));
|
||||||
|
|
||||||
// Reset local state
|
// Reset local state
|
||||||
_selectedNumber = null;
|
_selectedNumber = null;
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,9 @@ public record LoadCompletedGamesFailureAction(string Error);
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="BeforeThrowState">State before the throw was made.</param>
|
/// <param name="BeforeThrowState">State before the throw was made.</param>
|
||||||
/// <param name="AfterThrowState">State after the throw was made.</param>
|
/// <param name="AfterThrowState">State after the throw was made.</param>
|
||||||
public record RecordThrowAction(ThrowPanelState BeforeThrowState, ThrowPanelState AfterThrowState);
|
/// <param name="IsGutter">Whether the throw went into the gutter.</param>
|
||||||
|
/// <param name="IsLeftGutter">Whether it was the left gutter.</param>
|
||||||
|
public record RecordThrowAction(ThrowPanelState BeforeThrowState, ThrowPanelState AfterThrowState, bool IsGutter = false, bool IsLeftGutter = false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Action dispatched after ProcessThrow completes with game logic result.
|
/// Action dispatched after ProcessThrow completes with game logic result.
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,7 @@ public class GameEffects
|
||||||
// Create AfterThrowState for game logic with updated counters
|
// Create AfterThrowState for game logic with updated counters
|
||||||
var beforeSnapshot = CreateThrowPanelSnapshot(action.BeforeThrowState);
|
var beforeSnapshot = CreateThrowPanelSnapshot(action.BeforeThrowState);
|
||||||
var afterSnapshot = CreateThrowPanelSnapshot(newThrowPanel);
|
var afterSnapshot = CreateThrowPanelSnapshot(newThrowPanel);
|
||||||
var afterThrowState = afterSnapshot.CreateAfterThrowState(beforeSnapshot, currentPlayerId.Value);
|
var afterThrowState = afterSnapshot.CreateAfterThrowState(beforeSnapshot, currentPlayerId.Value, action.IsGutter);
|
||||||
|
|
||||||
// Default values
|
// Default values
|
||||||
bool shouldRotatePlayer = false;
|
bool shouldRotatePlayer = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue