diff --git a/docs/prompts.md b/docs/prompts.md index 86f49de..1bbd355 100644 --- a/docs/prompts.md +++ b/docs/prompts.md @@ -1,6 +1,5 @@ -@DeathBoxGameLogicService: erster Spieler muss mit einem X starten - +## Open Issues - 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 diff --git a/src/Koogle.Application/Games/DeathBox/DeathBoxGameLogicService.cs b/src/Koogle.Application/Games/DeathBox/DeathBoxGameLogicService.cs index 191fa45..44001ed 100644 --- a/src/Koogle.Application/Games/DeathBox/DeathBoxGameLogicService.cs +++ b/src/Koogle.Application/Games/DeathBox/DeathBoxGameLogicService.cs @@ -97,12 +97,12 @@ public class DeathBoxGameLogicService : IGameLogicService } // Check X conversion (3 X's -> 1 mark) - if (currentState.XCount >= 3) - { - currentState.XCount = 0; - currentState.Marks++; - lastThrow = lastThrow with { ConvertedXsToMark = true }; - } + //if (currentState.XCount >= 3) + //{ + // currentState.XCount = 0; + // currentState.Marks++; + // lastThrow = lastThrow with { ConvertedXsToMark = true }; + //} } // 2. GUTTER / NO WOOD processing (0 pins knocked) @@ -381,7 +381,8 @@ public class DeathBoxGameLogicService : IGameLogicService { // New round = 9 pins were standing before this throw // If it's a strike, all 9 were knocked down from 9 standing - if (afterThrow.IsStrike) return true; + if (afterThrow.IsStrike) + return true; // Otherwise check if standing pins before throw = 9 // We can infer this from: if all pins are now accounted for (knocked + still standing = 9) diff --git a/test/Koogle.Tests/Application/Games/DeathBoxGameLogicServiceTests.cs b/test/Koogle.Tests/Application/Games/DeathBoxGameLogicServiceTests.cs index f4bd125..4e49b18 100644 --- a/test/Koogle.Tests/Application/Games/DeathBoxGameLogicServiceTests.cs +++ b/test/Koogle.Tests/Application/Games/DeathBoxGameLogicServiceTests.cs @@ -50,7 +50,7 @@ public class DeathBoxGameLogicServiceTests // Assert var model = (DeathBoxGameModel)result; model.PlayerStates[playerId].Marks.Should().Be(0); - model.PlayerStates[playerId].XCount.Should().Be(0); + model.PlayerStates[playerId].XCount.Should().Be(1); model.PlayerStates[playerId].EggCount.Should().Be(0); model.PlayerStates[playerId].IsEliminated.Should().BeFalse(); model.CoffinSize.Should().Be(10); @@ -110,19 +110,20 @@ public class DeathBoxGameLogicServiceTests public void ProcessThrow_NewRound_CollectsX() { // Arrange - var playerId = Guid.NewGuid(); + var playerId1 = Guid.NewGuid(); + var playerId2 = Guid.NewGuid(); var setup = DeathBoxGameSetup.Create(coffinSize: 12); - var model = (DeathBoxGameModel)_sut.CreateInitialModel([playerId], setup); - - // New round with 5 pins knocked (>= 3) - var afterThrow = CreateAfterThrowState(playerId, 5, isNewRound: true); + var model = (DeathBoxGameModel)_sut.CreateInitialModel([playerId1, playerId2], setup); + + // New round with 9 pins knocked (>= 3) -> Board cleared + var afterThrow = CreateAfterThrowState(model.PlayerOrder.First(), 9, isNewRound: true, isCleared:true); // Act var (updatedModel, _) = _sut.ProcessThrow(model, afterThrow); // Assert var updated = (DeathBoxGameModel)updatedModel; - updated.PlayerStates[playerId].XCount.Should().Be(1); + updated.PlayerStates[model.PlayerOrder.Last()].XCount.Should().Be(1); updated.LastThrow!.EarnedX.Should().BeTrue(); updated.LastThrow.WasPenalty.Should().BeFalse(); } @@ -152,23 +153,27 @@ public class DeathBoxGameLogicServiceTests public void ProcessThrow_ThreeXs_ConvertToOneMark() { // Arrange - var playerId = Guid.NewGuid(); + var playerId1 = Guid.NewGuid(); + var playerId2 = Guid.NewGuid(); var setup = DeathBoxGameSetup.Create(coffinSize: 12); - var model = (DeathBoxGameModel)_sut.CreateInitialModel([playerId], setup); + var model = (DeathBoxGameModel)_sut.CreateInitialModel([playerId1, playerId2], setup); + playerId1 = model.PlayerOrder.First(); + playerId2 = model.PlayerOrder.Last(); // Set player to have 2 Xs already - model.PlayerStates[playerId].XCount = 2; + model.PlayerStates[playerId2].XCount = 2; // New round - will get 3rd X - var afterThrow = CreateAfterThrowState(playerId, 5, isNewRound: true); + // player1 clears the pins -> player2 will have to start new round and gets a X + var afterThrow = CreateAfterThrowState(playerId1, 9, isNewRound: true, isCleared:true); // Act var (updatedModel, _) = _sut.ProcessThrow(model, afterThrow); // Assert var updated = (DeathBoxGameModel)updatedModel; - updated.PlayerStates[playerId].XCount.Should().Be(0); - updated.PlayerStates[playerId].Marks.Should().Be(1); + updated.PlayerStates[playerId2].XCount.Should().Be(0); + updated.PlayerStates[playerId2].Marks.Should().Be(1); updated.LastThrow!.ConvertedXsToMark.Should().BeTrue(); }