fix ShitGameLogic
This commit is contained in:
parent
fc97a266d4
commit
b8bd1b0939
|
|
@ -84,19 +84,19 @@ public class ShitGameLogicService : IGameLogicService
|
||||||
// Pins are collected - player can choose to continue or pass
|
// Pins are collected - player can choose to continue or pass
|
||||||
// If continuing, pins are added to collected and subtracted from player
|
// If continuing, pins are added to collected and subtracted from player
|
||||||
var currentPoints = model.PlayerPoints.GetValueOrDefault(playerId, model.StartNumber);
|
var currentPoints = model.PlayerPoints.GetValueOrDefault(playerId, model.StartNumber);
|
||||||
var newPoints = currentPoints - pinsKnocked;
|
var newPoints = currentPoints - model.CollectedPoints - pinsKnocked;
|
||||||
|
|
||||||
// Clamp to 0 minimum
|
// Clamp to 0 minimum
|
||||||
if (newPoints < 0) newPoints = 0;
|
if (newPoints < 0) newPoints = 0;
|
||||||
|
|
||||||
var updatedPoints = new Dictionary<Guid, int>(model.PlayerPoints)
|
//var updatedPoints = new Dictionary<Guid, int>(model.PlayerPoints)
|
||||||
{
|
//{
|
||||||
[playerId] = newPoints
|
// [playerId] = newPoints
|
||||||
};
|
//};
|
||||||
|
|
||||||
model = model with
|
model = model with
|
||||||
{
|
{
|
||||||
PlayerPoints = updatedPoints,
|
//PlayerPoints = updatedPoints,
|
||||||
CollectedPoints = model.CollectedPoints + pinsKnocked
|
CollectedPoints = model.CollectedPoints + pinsKnocked
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -144,6 +144,20 @@ public class ShitGameLogicService : IGameLogicService
|
||||||
{
|
{
|
||||||
var model = CastModel(gameModel);
|
var model = CastModel(gameModel);
|
||||||
|
|
||||||
|
var currentPoints = model.PlayerPoints.GetValueOrDefault(currentPlayerId, model.StartNumber);
|
||||||
|
var newPoints = currentPoints - model.CollectedPoints;
|
||||||
|
|
||||||
|
var updatedPoints = new Dictionary<Guid, int>(model.PlayerPoints)
|
||||||
|
{
|
||||||
|
[currentPlayerId] = newPoints
|
||||||
|
};
|
||||||
|
|
||||||
|
model = model with
|
||||||
|
{
|
||||||
|
PlayerPoints = updatedPoints,
|
||||||
|
CollectedPoints = 0
|
||||||
|
};
|
||||||
|
|
||||||
if (model.IsGameOver)
|
if (model.IsGameOver)
|
||||||
{
|
{
|
||||||
return (model, new ThrowResult
|
return (model, new ThrowResult
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,9 @@
|
||||||
<MudTd>
|
<MudTd>
|
||||||
@if (context.IsCurrentPlayer && !_model.IsGameOver)
|
@if (context.IsCurrentPlayer && !_model.IsGameOver)
|
||||||
{
|
{
|
||||||
<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>
|
||||||
|
|
@ -134,6 +136,9 @@
|
||||||
<MudChip T="string" Size="Size.Small" Color="Color.Primary" Variant="Variant.Outlined">
|
<MudChip T="string" Size="Size.Small" Color="Color.Primary" Variant="Variant.Outlined">
|
||||||
Am Zug
|
Am Zug
|
||||||
</MudChip>
|
</MudChip>
|
||||||
|
|
||||||
|
<MudText Color="Color.Error">Verwerfen: @(context.Points + _model.CollectedPoints)</MudText>
|
||||||
|
<MudText Color="Color.Success">Passen: @(context.Points - _model.CollectedPoints)</MudText>
|
||||||
}
|
}
|
||||||
</MudTd>
|
</MudTd>
|
||||||
</RowTemplate>
|
</RowTemplate>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue