public bool IsPlayerCanContinue(IMafiaGame game, IMafiaPlayer player) { //1 killed //2 voted more than half of playersCount var killed = player.State.Effects.ContainsActualEffect(ActionEffectConstants.Killed); var votedCount = player.State.Effects.CountEffects(ActionEffectConstants.Voted); var voted = votedCount > (game.Players.Count - 1) / 2; return(!killed && !voted); }
public void Apply(IMafiaGame game) { foreach (var team in game.Teams) { switch (team.TeamName) { case TeamNameConstants.Mafia: team.Priority = MafiaPririty; break; case TeamNameConstants.Sheriff: team.Priority = SheriffPriority; break; default: team.Priority = CivilianPriority; break; } } }
public IRoundResult GetCurrentResult(IMafiaGame game) { var noMafia = game.Teams.Where(t => t.TeamName == TeamNameConstants.Mafia) .All(t => t.Participants.Count == 0); var allMafia = game.Teams.Where(i => i.TeamName != TeamNameConstants.Mafia) .All(t => t.Participants.Count == 0); var lastRound = game.Rounds[game.Rounds.Count - 1]; if (noMafia) { return(new MafiaRoundResult(true, lastRound, TeamNameConstants.Civilian)); } if (allMafia) { return(new MafiaRoundResult(true, lastRound, TeamNameConstants.Mafia)); } return(new MafiaRoundResult(false, lastRound)); }
public MafiaRoundBuilder(IMafiaGame game) { _game = game; Initialize(); }