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); }
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); }