public void ProcessDayInstruction(DayInstruction i) { var logevent = new GameEvent(); if (CurrentTurn().DayInstructions.Any()) { var existing = CurrentTurn().DayInstructions.Where(x => x.Actor == i.Actor).FirstOrDefault(); if (existing != null) { throw new Exception("Day instructions already given for player & turn."); } } CurrentTurn().DayInstructions.Add(i); Hub.DisplayVotes(this, VotesNeeded); if (CurrentTurn().DayInstructions.Count() == MobilePlayers .Where(m => m.Strategy == StrategyEnum.Human) .Count()) { // all human orders entered GetDayInstructionsFromAIs(); } if (CurrentTurn().DayInstructions.Count() == LivingPlayers.Count()) { FinishDay(); } }
public void GetDayInstructionsFromAIs() { foreach (var p in MobilePlayers.Where(p => p.Strategy == StrategyEnum.AI)) { var inst = p.AI.GetDayInstruction(MobilePlayers.Select(m => m.Id).ToList(), CurrentTurn().Id); var inst2 = new DayInstruction(this, inst); ProcessDayInstruction(inst2); } }
public void GetNightInstructionsFromAIs() { var anyHumansToWaitFor = MobilePlayers.Where(p => p.Strategy == StrategyEnum.Human).Any(); if (!anyHumansToWaitFor) { System.Threading.Thread.Sleep(5000); } foreach (var p in Players) { p.AI.ResetBeforeNight(Players.Select(m => m.Id).ToList()); } foreach (var p in MobilePlayers.Where(p => p.Strategy == StrategyEnum.AI)) { var inst = p.AI.GetNightInstruction(MobilePlayers.Select(m => m.Id).ToList(), CurrentTurn().Id); ProcessNightInstruction(inst); } }