added gameevents
This commit is contained in:
parent
99b9994c32
commit
c6e89ecdb6
|
|
@ -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<GameEvent>
|
||||
{
|
||||
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<GameEvent>
|
||||
{
|
||||
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(
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ namespace Koogle.Application.Games.FoxHunt
|
|||
|
||||
var playerStates = new Dictionary<Guid, FoxHuntPlayerState>(model.PlayerStates);
|
||||
var triggers = new List<TriggerEvent>();
|
||||
var gameEvents = new List<GameEvent>();
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public class ShitGameLogicService : IGameLogicService
|
|||
|
||||
bool shouldRotate = false;
|
||||
var triggers = new List<TriggerEvent>();
|
||||
var gameEvents = new List<GameEvent>();
|
||||
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue