fix next player rotation
This commit is contained in:
parent
f297317b71
commit
fcb46ff387
|
|
@ -275,12 +275,7 @@ public class GameEffects
|
|||
_logger.LogWarning(ex, "Could not resolve game logic service for {GameType}", gameTypeName);
|
||||
}
|
||||
|
||||
// Create AfterThrowState for game logic
|
||||
var beforeSnapshot = CreateThrowPanelSnapshot(action.BeforeThrowState);
|
||||
var afterSnapshot = CreateThrowPanelSnapshot(action.AfterThrowState);
|
||||
var afterThrowState = afterSnapshot.CreateAfterThrowState(beforeSnapshot, currentPlayerId.Value);
|
||||
|
||||
// Calculate new throw panel state with standard lane behavior
|
||||
// Calculate new throw panel state with incremented counters
|
||||
var newThrowPanel = action.AfterThrowState with
|
||||
{
|
||||
ThrowCounterPerRound = action.AfterThrowState.ThrowCounterPerRound + 1,
|
||||
|
|
@ -288,6 +283,14 @@ public class GameEffects
|
|||
BellValue = false // Reset bell after throw
|
||||
};
|
||||
|
||||
// Check if round is complete BEFORE applying pin reset
|
||||
bool isRoundComplete = newThrowPanel.ThrowCounterPerRound >= newThrowPanel.ThrowsPerRound;
|
||||
|
||||
// Create AfterThrowState for game logic with updated counters
|
||||
var beforeSnapshot = CreateThrowPanelSnapshot(action.BeforeThrowState);
|
||||
var afterSnapshot = CreateThrowPanelSnapshot(newThrowPanel);
|
||||
var afterThrowState = afterSnapshot.CreateAfterThrowState(beforeSnapshot, currentPlayerId.Value);
|
||||
|
||||
// Default values
|
||||
bool shouldRotatePlayer = false;
|
||||
Guid? nextPlayerId = null;
|
||||
|
|
@ -339,19 +342,14 @@ public class GameEffects
|
|||
_logger.LogError(ex, "Error in ProcessThrow for game type {GameType}", gameTypeName);
|
||||
// Continue with standard behavior on error
|
||||
newThrowPanel = ApplyStandardPinReset(newThrowPanel);
|
||||
shouldRotatePlayer = isRoundComplete;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No game logic service - use standard behavior
|
||||
newThrowPanel = ApplyStandardPinReset(newThrowPanel);
|
||||
|
||||
// Standard rotation: rotate after round is complete
|
||||
shouldRotatePlayer = newThrowPanel.ThrowCounterPerRound >= newThrowPanel.ThrowsPerRound;
|
||||
if (shouldRotatePlayer)
|
||||
{
|
||||
newThrowPanel = newThrowPanel with { ThrowCounterPerRound = 0 };
|
||||
}
|
||||
shouldRotatePlayer = isRoundComplete;
|
||||
}
|
||||
|
||||
// Dispatch result action
|
||||
|
|
|
|||
Loading…
Reference in New Issue