Пример #1
0
        //////////Methods//////////

        /// <summary>
        /// The method that the engine calls whenever our turn arrives
        /// </summary>
        public void DoTurn(IPirateGame game)
        {
            game.Debug("start turn at {0}", game.TimeRemaining());
            // if this is the first turn
            if (game.GetTurn() == 1)
            {
                // create a new game enviroment
                this.game = new Game(game);

                // initialize the event list, and fill it up!
                this.events = new List <Event>();
                this.AddEvents();

                // initialize the states manager, and fill it up!
                this.statesManager = new StatesManager();
                this.AddStates();

                // initialize the actions chooser
                this.actionsChooser = new ActionsChooser(this.game);
            }
            // if this is NOT the first turn
            else
            {
                // update the game enviroment
                this.game.Update(game);

                // update the states manager
                this.statesManager.Update(this.game);
            }

            this.game.Log(LogType.Timing, LogImportance.Important, "finish update at {0}", this.game.GetTimeRemaining());

            // run the best events for us
            this.UpdateChooser();
            this.game.Execute(this.actionsChooser);

            this.game.Log(LogType.Timing, LogImportance.ExtremelyImportant, "finish turn at {0}", this.game.GetTimeRemaining());
            game.Debug("real finish at {0}", game.TimeRemaining());
        }