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)
|
// Get winner ID (first player of winning team)
|
||||||
Guid? winnerId = model.Teams[winnerIndex].PlayerIds.FirstOrDefault();
|
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
|
// Calculate penalties for losing teams
|
||||||
foreach (var (teamIndex, state) in teamTrees)
|
foreach (var (teamIndex, state) in teamTrees)
|
||||||
|
|
@ -318,7 +329,8 @@ public class ChristmasTreeGameLogicService : IGameLogicService
|
||||||
WinnerTeamIndex = winnerIndex,
|
WinnerTeamIndex = winnerIndex,
|
||||||
IsInContinueMode = false,
|
IsInContinueMode = false,
|
||||||
ContinueThrowsRemaining = 0,
|
ContinueThrowsRemaining = 0,
|
||||||
OpponentSelectingTeamIndex = null
|
OpponentSelectingTeamIndex = null,
|
||||||
|
PendingGameEvents = gameEvents
|
||||||
};
|
};
|
||||||
|
|
||||||
return (model, new ThrowResult
|
return (model, new ThrowResult
|
||||||
|
|
@ -577,6 +589,17 @@ public class ChristmasTreeGameLogicService : IGameLogicService
|
||||||
}
|
}
|
||||||
|
|
||||||
Guid? winnerId = model.Teams[winnerIndex].PlayerIds.FirstOrDefault();
|
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
|
// Calculate penalties
|
||||||
foreach (var (teamIndex, state) in teamTrees)
|
foreach (var (teamIndex, state) in teamTrees)
|
||||||
|
|
@ -605,7 +628,8 @@ public class ChristmasTreeGameLogicService : IGameLogicService
|
||||||
OpponentSelectingTeamIndex = null,
|
OpponentSelectingTeamIndex = null,
|
||||||
IsGameOver = true,
|
IsGameOver = true,
|
||||||
WinnerId = winnerId,
|
WinnerId = winnerId,
|
||||||
WinnerTeamIndex = winnerIndex
|
WinnerTeamIndex = winnerIndex,
|
||||||
|
PendingGameEvents = gameEvents
|
||||||
};
|
};
|
||||||
|
|
||||||
return GameActionResult.SuccessResult(
|
return GameActionResult.SuccessResult(
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ namespace Koogle.Application.Games.FoxHunt
|
||||||
|
|
||||||
var playerStates = new Dictionary<Guid, FoxHuntPlayerState>(model.PlayerStates);
|
var playerStates = new Dictionary<Guid, FoxHuntPlayerState>(model.PlayerStates);
|
||||||
var triggers = new List<TriggerEvent>();
|
var triggers = new List<TriggerEvent>();
|
||||||
|
var gameEvents = new List<GameEvent>();
|
||||||
|
|
||||||
var foxId = model.PlayerOrder[model.FoxIndex];
|
var foxId = model.PlayerOrder[model.FoxIndex];
|
||||||
//var lastHunterId = model.GetPrev(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)
|
if (playerStates[key].PinCountFox - playerStates[key].PinCountHunters == maxLeading)
|
||||||
{
|
{
|
||||||
playerStates[key].IsWinner = true;
|
playerStates[key].IsWinner = true;
|
||||||
|
gameEvents.Add(new PlayerWonEvent { PlayerId = key });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +148,8 @@ namespace Koogle.Application.Games.FoxHunt
|
||||||
FoxIndex = model.FoxIndex,
|
FoxIndex = model.FoxIndex,
|
||||||
FoxTurn = model.FoxTurn,
|
FoxTurn = model.FoxTurn,
|
||||||
FoxTurnsRemaining = model.FoxTurnsRemaining,
|
FoxTurnsRemaining = model.FoxTurnsRemaining,
|
||||||
NonFoxIndex = model.NonFoxIndex
|
NonFoxIndex = model.NonFoxIndex,
|
||||||
|
PendingGameEvents = gameEvents
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = new ThrowResult
|
var result = new ThrowResult
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ public class ShitGameLogicService : IGameLogicService
|
||||||
|
|
||||||
bool shouldRotate = false;
|
bool shouldRotate = false;
|
||||||
var triggers = new List<TriggerEvent>();
|
var triggers = new List<TriggerEvent>();
|
||||||
|
var gameEvents = new List<GameEvent>();
|
||||||
|
|
||||||
if (isShitNumber || isGutter)
|
if (isShitNumber || isGutter)
|
||||||
{
|
{
|
||||||
|
|
@ -103,10 +104,13 @@ public class ShitGameLogicService : IGameLogicService
|
||||||
// Check for winner
|
// Check for winner
|
||||||
if (newPoints == 0)
|
if (newPoints == 0)
|
||||||
{
|
{
|
||||||
|
gameEvents.Add(new PlayerWonEvent { PlayerId = playerId });
|
||||||
|
|
||||||
model = model with
|
model = model with
|
||||||
{
|
{
|
||||||
WinnerId = playerId,
|
WinnerId = playerId,
|
||||||
IsGameOver = true
|
IsGameOver = true,
|
||||||
|
PendingGameEvents = gameEvents
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fire triggers for losers (all players except winner)
|
// Fire triggers for losers (all players except winner)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue