Beispiel #1
0
        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);
        }