コード例 #1
0
ファイル: Hull.cs プロジェクト: jezzay/DominionWar
        public void ReadHull(StreamReader fin)
        {
            InitHull();

            this.hullStrength = ValidationUtil.ParseStringToNumber(fin.ReadLine());
            if (!ValidationUtil.ValidNumber(hullStrength))
            {
                throw new Exception("Invalid hull strength");
            }
        }
コード例 #2
0
        private int ValidateSeed()
        {
            int seed = ValidationUtil.ParseStringToNumber(seedValueTextBox.Text);

            if (!ValidationUtil.ValidNumber(seed))
            {
                throw new Exception("Invalid seed value entered");
            }
            return(seed);
        }
コード例 #3
0
ファイル: Fleet.cs プロジェクト: jezzay/DominionWar
        private void CreateFleetShips(StreamReader fileReader)
        {
            string shipClassName  = fileReader.ReadLine();
            int    numberRequired = ValidationUtil.ParseStringToNumber(fileReader.ReadLine());

            if (!ValidationUtil.ValidNumber(numberRequired))
            {
                throw new Exception("Invalid number of ships");
            }
            if (String.IsNullOrEmpty(shipClassName) || !IsValidShipClass(shipClassName))
            {
                throw new Exception(shipClassName + " is not a valid ship class name");
            }
            // create ship
            CreateShip(shipClassName, numberRequired);
        }
コード例 #4
0
 private static bool ValidInputArguments(string[] arguments, out int seed)
 {
     seed = 0;
     if (arguments == null || arguments.Length != CommandLineArgumentsRequired)
     {
         ConsoleUtil.PrintInvalidArguments();
         return(false);
     }
     seed = ValidationUtil.ParseStringToNumber(arguments[0]);
     if (ValidationUtil.ValidNumber(seed))
     {
         return(true);
     }
     ConsoleUtil.PrintInvalidSeed();
     return(false);
 }
コード例 #5
0
        public void ReadWeapon(StreamReader fin)
        {
            InitWeapons();

            this.weaponBase = ValidationUtil.ParseStringToNumber(fin.ReadLine());
            // read in weapon base
            if (!ValidationUtil.ValidNumber(weaponBase))
            {
                throw new Exception("Invalid weapon base");
            }
            // read in weapon rand
            this.weaponRand = ValidationUtil.ParseStringToNumber(fin.ReadLine());
            if (!ValidationUtil.ValidNumber(weaponRand))
            {
                throw new Exception("Invalid weapon random");
            }
        }
コード例 #6
0
ファイル: Shield.cs プロジェクト: jezzay/DominionWar
        public void ReadShield(StreamReader fin)
        {
            InitShield();

            this.shieldStrength = ValidationUtil.ParseStringToNumber(fin.ReadLine());
            if (!ValidationUtil.ValidNumber(shieldStrength))
            {
                throw new Exception("Invalid shield strength");
            }

            this.regenerationRate = ValidationUtil.ParseStringToNumber(fin.ReadLine());
            if (!ValidationUtil.ValidNumber(regenerationRate) ||
                (regenerationRate > shieldStrength))
            {
                throw new Exception("Invalid regen rate");
            }
        }
コード例 #7
0
ファイル: Fleet.cs プロジェクト: jezzay/DominionWar
        private void ReadShipsVersionOne(StreamReader fin)
        {
            // read number of ships in fleet
            int numberOfShips = ValidationUtil.ParseStringToNumber(fin.ReadLine());

            if (!ValidationUtil.ValidNumber(numberOfShips))
            {
                throw new Exception("Invalid number of ships");
            }

            // create required ships
            for (int i = 0; i < numberOfShips; i++)
            {
                Ship ship = new Ship(rand);
                ship.ReadShip(fin);
                ShipsInService.Add(ship);
            }
        }