コード例 #1
0
ファイル: BuildStructureCommand.cs プロジェクト: dpetrova/HQC
        public override void Execute(params string[] commandParams)
        {
            ICity city = this.Engine.Continent.GetCityByName(commandParams[1]);

            if (city == null)
            {
                throw new ArgumentNullException("city");
            }

            IArmyStructure structure = this.Engine.ArmyStructureFactory.CreateStructure(commandParams[0]);

            if (city.CityType < structure.RequiredCityType)
            {
                throw new InsufficientCitySizeException("Structure requires a more advanced city");
            }

            if (city.ControllingHouse.TreasuryAmount < structure.BuildCost)
            {
                throw new InsufficientFundsException(
                          String.Format("House {0} doesn't have sufficient funds to build {1}", city.ControllingHouse.Name, structure.GetType().Name));
            }

            city.ControllingHouse.TreasuryAmount -= structure.BuildCost;
            city.AddArmyStructure(structure);

            this.Engine.Render("Successfully built {0} in {1}", structure.GetType().Name, city.Name);
        }
コード例 #2
0
        public virtual void AddArmyStructure(IArmyStructure structure)
        {
            if (structure.RequiredCityType > this.CityType)
            {
                throw new InsufficientCitySizeException(string.Format(
                                                            InsufficientCitySizeErrorMessage,
                                                            this.Name,
                                                            structure.GetType().Name));
            }

            this.armyStructures.Add(structure);
        }
コード例 #3
0
ファイル: City.cs プロジェクト: simooo93/Exams
        public virtual void AddArmyStructure(IArmyStructure structure)
        {
            if (structure.RequiredCityType > this.CityType)
            {
                throw new InsufficientCitySizeException(string.Format(
                    InsufficientCitySizeErrorMessage,
                    this.Name,
                    structure.GetType().Name));
            }

            this.armyStructures.Add(structure);
        }