add: IsCleared
This commit is contained in:
parent
125226127d
commit
37b8fc0e8d
|
|
@ -21,13 +21,15 @@ public record BeforeThrowState(
|
|||
/// <param name="IsCircle">Whether a circle (Kranz) was scored.</param>
|
||||
/// <param name="IsStrike">Whether all 9 pins were knocked down.</param>
|
||||
/// <param name="IsGutter">Whether the throw was a gutter (Rinne).</param>
|
||||
/// <param name="IsCleared">Whether all remaining pins are hit (Abgeräumt).</param>
|
||||
public record AfterThrowState(
|
||||
ThrowPanelSnapshot ThrowPanel,
|
||||
Guid CurrentPlayerId,
|
||||
int PinsKnocked,
|
||||
bool IsCircle,
|
||||
bool IsStrike,
|
||||
bool IsGutter
|
||||
bool IsGutter,
|
||||
bool IsCleared
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -81,7 +83,7 @@ public record ThrowPanelSnapshot
|
|||
ThrowCounterPerRound = throwCounterPerRound,
|
||||
TotalThrowCounter = totalThrowCounter,
|
||||
ThrowMode = throwMode,
|
||||
BellValue = bellValue
|
||||
BellValue = bellValue,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -102,6 +104,15 @@ public static class GameProgressExtensions
|
|||
public static int StandingPinCount(this ThrowPanelSnapshot snapshot)
|
||||
=> snapshot.Pins.Count(p => p == PinStatus.Standing);
|
||||
|
||||
/// <summary>
|
||||
/// No remaining pins, no matter if others are fallen or disabled
|
||||
/// </summary>
|
||||
/// <param name="snapshot"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsCleared(this ThrowPanelSnapshot snapshot)
|
||||
=> snapshot.Pins.Count(p => p == PinStatus.Standing) == 0;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a circle (Kranz) was scored - 8 outer pins down, center standing.
|
||||
/// Pin layout: 1=top, 5=center, 9=bottom
|
||||
|
|
@ -127,10 +138,10 @@ public static class GameProgressExtensions
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if all 9 pins were knocked down (strike).
|
||||
/// Checks if all 9 pins were knocked down (strike) in a single throw.
|
||||
/// </summary>
|
||||
public static bool IsStrike(this ThrowPanelSnapshot snapshot)
|
||||
=> snapshot.Pins.All(p => p == PinStatus.Fallen);
|
||||
=> snapshot.Pins.All(p => p == PinStatus.Fallen) && snapshot.PinCount() == 9;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if no pins were knocked down (gutter/Rinne).
|
||||
|
|
@ -167,7 +178,8 @@ public static class GameProgressExtensions
|
|||
PinsKnocked: pinsKnocked,
|
||||
IsCircle: afterThrow.IsCircle(),
|
||||
IsStrike: afterThrow.IsStrike(),
|
||||
IsGutter: isGutter
|
||||
IsGutter: isGutter,
|
||||
IsCleared: afterThrow.IsCleared()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,11 @@ public class TrainingGameLogicService : IGameLogicService
|
|||
stats.GutterCount++;
|
||||
}
|
||||
|
||||
if (afterThrow.IsCleared)
|
||||
{
|
||||
stats.ClearedCount++;
|
||||
}
|
||||
|
||||
// Determine if player should rotate (round complete)
|
||||
var shouldRotate = afterThrow.ThrowPanel.IsRoundComplete();
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@ public record TrainingPlayerStats
|
|||
/// </summary>
|
||||
public int ThrowCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total number of pins have been cleared.
|
||||
/// </summary>
|
||||
public int ClearedCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total number of pins knocked down.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@
|
|||
@inject IState<DayState> DayState
|
||||
|
||||
<MudPaper Class="pa-4">
|
||||
<MudText Typo="Typo.h6" Class="mb-4">
|
||||
@* <MudText Typo="Typo.h6" Class="mb-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.TableChart" Class="mr-2" />
|
||||
Training - Tafel
|
||||
</MudText>
|
||||
</MudText> *@
|
||||
|
||||
@if (_playerStats.Count == 0)
|
||||
{
|
||||
|
|
@ -36,16 +36,19 @@
|
|||
<MudTh>Spieler</MudTh>
|
||||
<MudTh Style="text-align: right">Würfe</MudTh>
|
||||
<MudTh Style="text-align: right">Kegel</MudTh>
|
||||
<MudTh Style="text-align: right">Abgeräumt</MudTh>
|
||||
<MudTh Style="text-align: right">Kränze</MudTh>
|
||||
<MudTh Style="text-align: right">Strikes</MudTh>
|
||||
<MudTh Style="text-align: right">Rinnen</MudTh>
|
||||
<MudTh Style="text-align: right">alle 9</MudTh>
|
||||
<MudTh Style="text-align: right">Gossen</MudTh>
|
||||
<MudTh Style="text-align: right">⌀</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd>
|
||||
@if (context.IsCurrentPlayer)
|
||||
{
|
||||
<MudBadge Color="Color.Primary" Dot="true" Overlap="true">
|
||||
<MudBadge Color="Color.Primary" Dot="true" Overlap="false"
|
||||
Icon=@Icons.Material.Filled.ArrowCircleDown
|
||||
Origin="Origin.TopLeft">
|
||||
<MudText Typo="Typo.body1" Style="font-weight: 600">
|
||||
@context.PlayerName
|
||||
</MudText>
|
||||
|
|
@ -58,6 +61,7 @@
|
|||
</MudTd>
|
||||
<MudTd Style="text-align: right">@context.ThrowCount</MudTd>
|
||||
<MudTd Style="text-align: right">@context.PinCount</MudTd>
|
||||
<MudTd Style="text-align: right">@context.ClearedCount</MudTd>
|
||||
<MudTd Style="text-align: right">
|
||||
@if (context.CircleCount > 0)
|
||||
{
|
||||
|
|
@ -180,6 +184,7 @@
|
|||
PlayerId = playerId,
|
||||
PlayerName = playerName,
|
||||
ThrowCount = stats.ThrowCount,
|
||||
ClearedCount = stats.ClearedCount,
|
||||
PinCount = stats.PinCount,
|
||||
CircleCount = stats.CircleCount,
|
||||
StrikeCount = stats.StrikeCount,
|
||||
|
|
@ -208,6 +213,7 @@
|
|||
public Guid PlayerId { get; init; }
|
||||
public string PlayerName { get; init; } = "";
|
||||
public int ThrowCount { get; init; }
|
||||
public int ClearedCount { get; init; }
|
||||
public int PinCount { get; init; }
|
||||
public int CircleCount { get; init; }
|
||||
public int StrikeCount { get; init; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue