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