Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        public void ProcessNightInstruction(NightFormModel model)
        {
            var i = new NightInstruction(this, model);

            i.Actor.AI.LastNightAction = model;
            var logEvent = new GameEvent(i);

            AddToLog(logEvent);
            if (CurrentTurn().NightInstructions.Any())
            {
                var existing = CurrentTurn().NightInstructions.Where(x => x.Actor == i.Actor).FirstOrDefault();
                if (existing != null)
                {
                    throw new Exception("Night instructions already given for player & turn.");
                }
            }
            CurrentTurn().NightInstructions.Add(i);
            Hub.DisplayNightActionsEntered(this);
            if (CurrentTurn().NightInstructions.Count() == MobilePlayers.Count())
            {
                FinishNight();
            }
        }