Exemple #1
0
        /// <summary>
        /// This method takes care of moves the opponent made, as far
        /// as they are provided by the game engine.
        /// </summary>
        /// <param name="commandLine">Command line.</param>
        public void OpponentMoves(string commandLine)
        {
            commandLine = commandLine.Remove (0, 14);
            commandLine = commandLine.Trim ();
            string[] parts = commandLine.Split (' ');

            if (parts.Length < 4) {
                return;
            }

            List<Move> opponentMoves = new List<Move> ();
            Region sourceRegion;
            Region targetRegion;

            for (int i = 0; i < parts.Length; i += 4) {
                if (parts [i + 1].Equals ("place_armies")) {
                    sourceRegion = State.CompleteMap.Regions [int.Parse (parts [i + 2])];
                    PlaceArmiesMove placeArmiesMove = new PlaceArmiesMove (parts [i], sourceRegion, int.Parse (parts [i + 3]));
                    opponentMoves.Add (placeArmiesMove);
                    State.ProcessPlaceArmiesMove (placeArmiesMove);
                }

                if (parts [i + 1].Equals ("attack/transfer")) {
                    sourceRegion = State.CompleteMap.Regions [int.Parse (parts [i + 2])];
                    targetRegion = State.CompleteMap.Regions [int.Parse (parts [i + 3])];
                    AttackTransferMove attackTransferMove =
                        new AttackTransferMove (parts [i], sourceRegion, targetRegion, int.Parse (parts [i + 4]));
                    opponentMoves.Add (attackTransferMove);
                    State.ProcessAttackTransferMove (attackTransferMove);
                    i++;
                }
            }

            State.EnemyBot.MovesLastTurn = opponentMoves;

            if (Logger.IsDebug ()) {
                Logger.Debug ("Parser:\tProcessed the opponent's moves.");
            }
        }
Exemple #2
0
        /// <summary>
        /// Processes a PlaceArmiesMove, and updates the number of armies
        /// in the target region.
        /// </summary>
        /// <param name="move">Move.</param>
        public void ProcessPlaceArmiesMove(PlaceArmiesMove move)
        {
            Region region = VisibleMap.Regions [move.Region.Id];
            region.Armies += move.Armies;

            if (Logger.IsDebug ()) {
                Logger.Debug (string.Format("State:\tProcessed placement of {0} armies into {1}.",
                    move.Region.Id, move.Armies));
            }
        }