fix deathbox handling

This commit is contained in:
beo3000 2025-12-28 22:43:21 +01:00
parent f75b08d98d
commit 7795c3064f
4 changed files with 69 additions and 12 deletions

View File

@ -1,4 +1,7 @@
@DeathBoxGameLogicService: Nachdem ein Spieler ein Ei verdienst hat, muss der nächste zwangsweise wieder in die Vollen, also auf alle 9 Pins werden. Dafür muss er ein X bekommen, was aktuell nicht der Fall ist.
- neuer Tag -> optional Gäste und nicht alle Teilnehmer
- Tag beendnden -> alle Teilnehmer hinzufügen, und strafen hinzufügen
- offene Sachstrafen von einem Tag zum nächsten fortschreiben

View File

@ -60,6 +60,7 @@ public class DeathBoxGameLogicService : IGameLogicService
var playerStates = new Dictionary<Guid, DeathBoxPlayerState>(model.PlayerStates);
var eliminatedPlayers = new List<Guid>(model.EliminatedPlayers);
var triggers = new List<TriggerEvent>();
var assignX = false;
// Get current player state
var currentState = playerStates[playerId];
@ -83,8 +84,8 @@ public class DeathBoxGameLogicService : IGameLogicService
if (isNewRound)
{
// Always collect X on new round
currentState.XCount++;
lastThrow = lastThrow with { EarnedX = true };
//currentState.XCount++;
//lastThrow = lastThrow with { EarnedX = true };
// Penalty for <3 pins on new round
if (pinsKnocked < 3)
@ -135,10 +136,10 @@ public class DeathBoxGameLogicService : IGameLogicService
}
// 3. CLEARED processing (all remaining pins hit)
Guid? previousPlayerPenalizedId = null;
//Guid? previousPlayerPenalizedId = null;
bool previousPlayerEliminated = false;
if (afterThrow.IsCleared && !isNewRound)
if (afterThrow.IsCleared /*&& !isNewRound*/)
{
// Current player gets egg
currentState.EggCount++;
@ -156,6 +157,9 @@ public class DeathBoxGameLogicService : IGameLogicService
// Eggs expire if no marks to remove
}
// in case eggs have been earned, next player will get another X
assignX = true;
// Previous player gets mark (if exists and not eliminated)
if (model.PreviousPlayerId.HasValue &&
playerStates.TryGetValue(model.PreviousPlayerId.Value, out var prevState) &&
@ -167,7 +171,7 @@ public class DeathBoxGameLogicService : IGameLogicService
PreviousPlayerGotMark = true,
PreviousPlayerPenalizedId = model.PreviousPlayerId.Value
};
previousPlayerPenalizedId = model.PreviousPlayerId.Value;
//previousPlayerPenalizedId = model.PreviousPlayerId.Value;
// Check if previous player is eliminated
if (prevState.Marks >= model.CoffinSize)
@ -238,6 +242,36 @@ public class DeathBoxGameLogicService : IGameLogicService
if (currentIndex < 0) currentIndex = model.CurrentPlayerIndex;
int nextPlayerIndex = GetNextActivePlayerIndex(model.PlayerOrder, currentIndex, playerStates);
var nextPlayerId = model.PlayerOrder[nextPlayerIndex];
if (assignX)
{
var nextState = playerStates[nextPlayerId];
nextState.XCount ++;
lastThrow = lastThrow with { EarnedX = true };
lastThrow = lastThrow with
{
EarnedX = true,
NextPlayerPenalizedId = nextPlayerId
};
// Check X conversion (3 X's -> 1 mark)
if (nextState.XCount >= 3)
{
lastThrow = lastThrow with
{
NextPlayerGotMark = true,
NextPlayerPenalizedId = nextPlayerId
};
nextState.XCount = 0;
nextState.Marks++;
lastThrow = lastThrow with { ConvertedXsToMark = true };
}
playerStates[nextPlayerId] = nextState;
}
// Update model
model = model with

View File

@ -149,6 +149,16 @@ public record DeathBoxLastThrow
/// </summary>
public bool ConvertedEggsToRemoveMark { get; init; }
/// <summary>
/// Whether the next player got a mark (cleared penalty).
/// </summary>
public bool NextPlayerGotMark { get; init; }
/// <summary>
/// ID of next player who got a mark (if any).
/// </summary>
public Guid? NextPlayerPenalizedId { get; init; }
/// <summary>
/// Whether the previous player got a mark (cleared penalty).
/// </summary>

View File

@ -283,10 +283,6 @@
// Pin count
messages.Add($"{playerName}: {lt.PinsKnocked} Pin(s)");
// X earned
if (lt.EarnedX)
messages.Add("X gesammelt");
// Penalty for <3 pins
if (lt.WasPenalty)
messages.Add("Weniger als 3 Pins! +1 Strich");
@ -308,12 +304,26 @@
messages.Add($"{prevName} bekommt +1 Strich");
}
// Conversions
if (lt.ConvertedXsToMark)
messages.Add("3 Xe → +1 Strich");
// Conversions PreviousPlayer
if (lt.ConvertedEggsToRemoveMark)
messages.Add("3 Eier → -1 Strich!");
// X earned
if (lt.EarnedX && lt.NextPlayerPenalizedId.HasValue)
{
var nextName = GetPlayerName(lt.NextPlayerPenalizedId.Value);
messages.Add($"{nextName}: X gesammelt");
}
// Conversions NextPlayer
if (lt.ConvertedXsToMark && lt.NextPlayerPenalizedId.HasValue)
{
var nextName = GetPlayerName(lt.NextPlayerPenalizedId.Value);
messages.Add($"{nextName} 3 Xe → +1 Strich");
}
// Eliminations
if (lt.PlayerEliminated)
messages.Add($"{playerName} ist ausgeschieden!");