Пример #1
0
        protected virtual bool AddBattleShips(IGame game, List <string> battleShipData)
        {
            bool validateShipCount = this.validateBattleShipNumber(game.BattleArea1, battleShipData.Count);

            if (!validateShipCount)
            {
                System.Console.WriteLine("The BattleShipCount are more than battle area dimension");
                return(false);
            }

            foreach (var item in battleShipData)
            {
                int         width;
                int         height;
                ShipType    shipType;
                CoOrdinates ship1Coords;
                CoOrdinates ship2Coords;

                string[] battleShipDataArray = item.Split(Separator);
                if (!this.FetchShipData(this._game, battleShipDataArray, out height, out width, out shipType, out ship1Coords, out ship2Coords))
                {
                    return(false);
                }

                game.AddShip(game.BattleArea1, height, width, ship1Coords, shipType);
                game.AddShip(game.BattleArea2, height, width, ship2Coords, shipType);
            }

            return(true);
        }