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);
|
_logger.LogWarning(ex, "Could not resolve game logic service for {GameType}", gameTypeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create AfterThrowState for game logic
|
// Calculate new throw panel state with incremented counters
|
||||||
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
|
|
||||||
var newThrowPanel = action.AfterThrowState with
|
var newThrowPanel = action.AfterThrowState with
|
||||||
{
|
{
|
||||||
ThrowCounterPerRound = action.AfterThrowState.ThrowCounterPerRound + 1,
|
ThrowCounterPerRound = action.AfterThrowState.ThrowCounterPerRound + 1,
|
||||||
|
|
@ -288,6 +283,14 @@ public class GameEffects
|
||||||
BellValue = false // Reset bell after throw
|
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
|
// Default values
|
||||||
bool shouldRotatePlayer = false;
|
bool shouldRotatePlayer = false;
|
||||||
Guid? nextPlayerId = null;
|
Guid? nextPlayerId = null;
|
||||||
|
|
@ -339,19 +342,14 @@ public class GameEffects
|
||||||
_logger.LogError(ex, "Error in ProcessThrow for game type {GameType}", gameTypeName);
|
_logger.LogError(ex, "Error in ProcessThrow for game type {GameType}", gameTypeName);
|
||||||
// Continue with standard behavior on error
|
// Continue with standard behavior on error
|
||||||
newThrowPanel = ApplyStandardPinReset(newThrowPanel);
|
newThrowPanel = ApplyStandardPinReset(newThrowPanel);
|
||||||
|
shouldRotatePlayer = isRoundComplete;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No game logic service - use standard behavior
|
// No game logic service - use standard behavior
|
||||||
newThrowPanel = ApplyStandardPinReset(newThrowPanel);
|
newThrowPanel = ApplyStandardPinReset(newThrowPanel);
|
||||||
|
shouldRotatePlayer = isRoundComplete;
|
||||||
// Standard rotation: rotate after round is complete
|
|
||||||
shouldRotatePlayer = newThrowPanel.ThrowCounterPerRound >= newThrowPanel.ThrowsPerRound;
|
|
||||||
if (shouldRotatePlayer)
|
|
||||||
{
|
|
||||||
newThrowPanel = newThrowPanel with { ThrowCounterPerRound = 0 };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch result action
|
// Dispatch result action
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue