private void handleInsanityTrackEffect(Game game) { EvidenceTrack insanityTrack = game.Board.GetInsanityTrack(); int modValue = (insanityTrack.Value - 1); if (modValue > 0) { modValue *= -1; game.Board.AspectTracks.ForEach(t => t.AddToValue(modValue)); } }
private void handleGuiltTrackEffect(Game game) { EvidenceTrack guiltTrack = game.Board.GetGuiltTrack(); int modValue = guiltTrack.Value - 2; if (modValue > 0) { List <Jury> unlockedJuries = game.Board.Juries.FindAll(j => !j.SwayTrack.IsLocked); unlockedJuries.ForEach(j => j.SwayTrack.AddToValue(modValue)); } }
private void mainLogic() { if (game.NotifyStartOfTurn != null) { game.NotifyStartOfTurn(); } // Reveal all jury aspects. foreach (Jury jury in game.Board.Juries) { jury.Aspects.ForEach(a => a.Reveal()); } EvidenceTrack guiltTrack = game.Board.GetGuiltTrack(); if (guiltTrack.Value < 2) { if (game.NotifyGameEnd != null) { game.NotifyGameEnd(Player.PlayerSide.Defense, true, 0); } goto GameEnd; } handleGuiltTrackEffect(game); handleInsanityTrackEffect(game); game.Board.Juries.ForEach(j => j.RevealAllTraits()); List <Jury> usedJuries = new List <Jury>(); Dictionary <Player.PlayerSide, bool> playerSidePassed = new Dictionary <Player.PlayerSide, bool>(); while (playerSidePassed.Count < 2) { List <Jury> lockedJuries; if (curPlayer.Side == Player.PlayerSide.Prosecution) { lockedJuries = game.Board.Juries.FindAll(j => j.SwayTrack.IsLocked && j.SwayTrack.Value == j.SwayTrack.MaxValue); } else { lockedJuries = game.Board.Juries.FindAll(j => j.SwayTrack.IsLocked && j.SwayTrack.Value == j.SwayTrack.MinValue); } lockedJuries = lockedJuries.Except(usedJuries).ToList(); if (lockedJuries.Count > 0) { Jury usedJury = performJuryForDeliberation(lockedJuries, curPlayer); usedJuries.Add(usedJury); } else { playerSidePassed[curPlayer.Side] = true; } if (!playerSidePassed.ContainsKey(game.GetOtherPlayer(curPlayer).Side)) { passToNextPlayer(); } } // Calculate winning player. int totalScore = 0; foreach (Jury jury in game.Board.Juries) { int score = jury.CalculateGuiltScore(); totalScore += score; } Player.PlayerSide winningPlayer = totalScore >= GameConstants.PROSECUTION_SCORE_THRESHOLD ? Player.PlayerSide.Prosecution : Player.PlayerSide.Defense; if (game.NotifyGameEnd != null) { game.NotifyGameEnd(winningPlayer, false, totalScore); } GameEnd: { GotoNextState(); } }