From c6e89ecdb689c74bd4028dc6b57c3f0997ba7b7e Mon Sep 17 00:00:00 2001 From: beo3000 Date: Sun, 11 Jan 2026 13:11:27 +0100 Subject: [PATCH] added gameevents --- .../ChristmasTreeGameLogicService.cs | 28 +++++++++++++++++-- .../Games/FoxHunt/FoxHuntGameLogicService.cs | 5 +++- .../Games/Shit/ShitGameLogicService.cs | 6 +++- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/Koogle.Application/Games/ChristmasTree/ChristmasTreeGameLogicService.cs b/src/Koogle.Application/Games/ChristmasTree/ChristmasTreeGameLogicService.cs index 23a3de4..7f1cebb 100644 --- a/src/Koogle.Application/Games/ChristmasTree/ChristmasTreeGameLogicService.cs +++ b/src/Koogle.Application/Games/ChristmasTree/ChristmasTreeGameLogicService.cs @@ -286,6 +286,17 @@ public class ChristmasTreeGameLogicService : IGameLogicService // Get winner ID (first player of winning team) Guid? winnerId = model.Teams[winnerIndex].PlayerIds.FirstOrDefault(); + var winningTeam = model.Teams[winnerIndex]; + + // Create game event for winning team + var gameEvents = new List + { + new TeamWonEvent + { + TeamName = winningTeam.Name, + PlayerIds = winningTeam.PlayerIds + } + }; // Calculate penalties for losing teams foreach (var (teamIndex, state) in teamTrees) @@ -318,7 +329,8 @@ public class ChristmasTreeGameLogicService : IGameLogicService WinnerTeamIndex = winnerIndex, IsInContinueMode = false, ContinueThrowsRemaining = 0, - OpponentSelectingTeamIndex = null + OpponentSelectingTeamIndex = null, + PendingGameEvents = gameEvents }; return (model, new ThrowResult @@ -577,6 +589,17 @@ public class ChristmasTreeGameLogicService : IGameLogicService } Guid? winnerId = model.Teams[winnerIndex].PlayerIds.FirstOrDefault(); + var winningTeam = model.Teams[winnerIndex]; + + // Create game event for winning team + var gameEvents = new List + { + new TeamWonEvent + { + TeamName = winningTeam.Name, + PlayerIds = winningTeam.PlayerIds + } + }; // Calculate penalties foreach (var (teamIndex, state) in teamTrees) @@ -605,7 +628,8 @@ public class ChristmasTreeGameLogicService : IGameLogicService OpponentSelectingTeamIndex = null, IsGameOver = true, WinnerId = winnerId, - WinnerTeamIndex = winnerIndex + WinnerTeamIndex = winnerIndex, + PendingGameEvents = gameEvents }; return GameActionResult.SuccessResult( diff --git a/src/Koogle.Application/Games/FoxHunt/FoxHuntGameLogicService.cs b/src/Koogle.Application/Games/FoxHunt/FoxHuntGameLogicService.cs index 5880351..56ecf2e 100644 --- a/src/Koogle.Application/Games/FoxHunt/FoxHuntGameLogicService.cs +++ b/src/Koogle.Application/Games/FoxHunt/FoxHuntGameLogicService.cs @@ -64,6 +64,7 @@ namespace Koogle.Application.Games.FoxHunt var playerStates = new Dictionary(model.PlayerStates); var triggers = new List(); + var gameEvents = new List(); var foxId = model.PlayerOrder[model.FoxIndex]; //var lastHunterId = model.GetPrev(model.PlayerOrder, model.FoxIndex); @@ -134,6 +135,7 @@ namespace Koogle.Application.Games.FoxHunt if (playerStates[key].PinCountFox - playerStates[key].PinCountHunters == maxLeading) { playerStates[key].IsWinner = true; + gameEvents.Add(new PlayerWonEvent { PlayerId = key }); } } } @@ -146,7 +148,8 @@ namespace Koogle.Application.Games.FoxHunt FoxIndex = model.FoxIndex, FoxTurn = model.FoxTurn, FoxTurnsRemaining = model.FoxTurnsRemaining, - NonFoxIndex = model.NonFoxIndex + NonFoxIndex = model.NonFoxIndex, + PendingGameEvents = gameEvents }; var result = new ThrowResult diff --git a/src/Koogle.Application/Games/Shit/ShitGameLogicService.cs b/src/Koogle.Application/Games/Shit/ShitGameLogicService.cs index c30d7c7..57f5d1f 100644 --- a/src/Koogle.Application/Games/Shit/ShitGameLogicService.cs +++ b/src/Koogle.Application/Games/Shit/ShitGameLogicService.cs @@ -59,6 +59,7 @@ public class ShitGameLogicService : IGameLogicService bool shouldRotate = false; var triggers = new List(); + var gameEvents = new List(); if (isShitNumber || isGutter) { @@ -103,10 +104,13 @@ public class ShitGameLogicService : IGameLogicService // Check for winner if (newPoints == 0) { + gameEvents.Add(new PlayerWonEvent { PlayerId = playerId }); + model = model with { WinnerId = playerId, - IsGameOver = true + IsGameOver = true, + PendingGameEvents = gameEvents }; // Fire triggers for losers (all players except winner)