fix decrease mode
This commit is contained in:
parent
aa8cf4d83a
commit
061ba4dbdb
|
|
@ -171,6 +171,13 @@
|
||||||
private void HandlePinClick(int pinNumber)
|
private void HandlePinClick(int pinNumber)
|
||||||
{
|
{
|
||||||
var currentStatus = GetPinStatus(pinNumber);
|
var currentStatus = GetPinStatus(pinNumber);
|
||||||
|
|
||||||
|
// In Decrease mode, fallen pins cannot be reset to standing
|
||||||
|
if (GameState.Value.ThrowPanel.ThrowMode == ThrowMode.Decrease && currentStatus == PinStatus.Fallen)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var newStatus = currentStatus == PinStatus.Standing ? PinStatus.Fallen : PinStatus.Standing;
|
var newStatus = currentStatus == PinStatus.Standing ? PinStatus.Fallen : PinStatus.Standing;
|
||||||
|
|
||||||
Dispatcher.Dispatch(new SetPinStatusAction(pinNumber, newStatus));
|
Dispatcher.Dispatch(new SetPinStatusAction(pinNumber, newStatus));
|
||||||
|
|
@ -246,18 +253,25 @@
|
||||||
if (newThrowPanel.ThrowCounterPerRound >= newThrowPanel.ThrowsPerRound)
|
if (newThrowPanel.ThrowCounterPerRound >= newThrowPanel.ThrowsPerRound)
|
||||||
{
|
{
|
||||||
newThrowPanel = newThrowPanel with { ThrowCounterPerRound = 0 };
|
newThrowPanel = newThrowPanel with { ThrowCounterPerRound = 0 };
|
||||||
|
// Reset all pins at end of round (both modes)
|
||||||
// Reset pins if in Reposition mode
|
newThrowPanel = newThrowPanel.ResetPins();
|
||||||
if (newThrowPanel.ThrowMode == ThrowMode.Reposition)
|
|
||||||
{
|
|
||||||
newThrowPanel = newThrowPanel.ResetPins();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (newThrowPanel.ThrowMode == ThrowMode.Reposition)
|
else if (newThrowPanel.ThrowMode == ThrowMode.Reposition)
|
||||||
{
|
{
|
||||||
// In Reposition mode, always reset pins after each throw
|
// In Reposition mode, always reset pins after each throw
|
||||||
newThrowPanel = newThrowPanel.ResetPins();
|
newThrowPanel = newThrowPanel.ResetPins();
|
||||||
}
|
}
|
||||||
|
else if (newThrowPanel.ThrowMode == ThrowMode.Decrease)
|
||||||
|
{
|
||||||
|
// In Decrease mode: Mark fallen pins as disabled (not available for next throw)
|
||||||
|
newThrowPanel = newThrowPanel.MarkFallenAsDisabled();
|
||||||
|
|
||||||
|
// If all pins are down, reset all pins for a fresh set
|
||||||
|
if (newThrowPanel.AllPinsDown())
|
||||||
|
{
|
||||||
|
newThrowPanel = newThrowPanel.ResetPins();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Dispatch record throw action
|
// Dispatch record throw action
|
||||||
Dispatcher.Dispatch(new RecordThrowAction(newThrowPanel, GameState.Value.GameModel));
|
Dispatcher.Dispatch(new RecordThrowAction(newThrowPanel, GameState.Value.GameModel));
|
||||||
|
|
|
||||||
|
|
@ -257,6 +257,27 @@ public record ThrowPanelState
|
||||||
9 => this with { Pin9 = status },
|
9 => this with { Pin9 = status },
|
||||||
_ => this
|
_ => this
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Marks all fallen pins as disabled (for Decrease mode).
|
||||||
|
/// </summary>
|
||||||
|
public ThrowPanelState MarkFallenAsDisabled() => this with
|
||||||
|
{
|
||||||
|
Pin1 = Pin1 == PinStatus.Fallen ? PinStatus.Disabled : Pin1,
|
||||||
|
Pin2 = Pin2 == PinStatus.Fallen ? PinStatus.Disabled : Pin2,
|
||||||
|
Pin3 = Pin3 == PinStatus.Fallen ? PinStatus.Disabled : Pin3,
|
||||||
|
Pin4 = Pin4 == PinStatus.Fallen ? PinStatus.Disabled : Pin4,
|
||||||
|
Pin5 = Pin5 == PinStatus.Fallen ? PinStatus.Disabled : Pin5,
|
||||||
|
Pin6 = Pin6 == PinStatus.Fallen ? PinStatus.Disabled : Pin6,
|
||||||
|
Pin7 = Pin7 == PinStatus.Fallen ? PinStatus.Disabled : Pin7,
|
||||||
|
Pin8 = Pin8 == PinStatus.Fallen ? PinStatus.Disabled : Pin8,
|
||||||
|
Pin9 = Pin9 == PinStatus.Fallen ? PinStatus.Disabled : Pin9
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if all pins are knocked down (fallen or disabled).
|
||||||
|
/// </summary>
|
||||||
|
public bool AllPinsDown() => GetPins().All(p => p != PinStatus.Standing);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue