public override void Update() { for (int i = 0; i < this.Houses.Count; i++) { if (this.Houses[i].ControlledCities.Count() >= 10 && this.Houses[i] is House) { GreatHouse temp = new GreatHouse(this.Houses[i].Name, this.Houses[i].TreasuryAmount); foreach (ICity city in this.Houses[i].ControlledCities) { temp.AddCityToHouse(city); } this.Houses[i] = temp; } else if (this.Houses[i].ControlledCities.Count() < 5 && this.Houses[i] is GreatHouse) { House temp = new House(this.Houses[i].Name, this.Houses[i].TreasuryAmount); foreach (ICity city in this.Houses[i].ControlledCities) { temp.AddCityToHouse(city); } this.Houses[i] = temp; } } base.Update(); }
private void DowngradeHouses() { var greatHouseToHouse = this.Houses .Where(house => (house is GreatHouse) && house.ControlledCities.Count() < 5) .ToList(); foreach (var house in greatHouseToHouse) { var downGradedGreatHouse = new House(house.Name, house.TreasuryAmount); foreach (var city in house.ControlledCities) { downGradedGreatHouse.AddCityToHouse(city); } this.Houses.Remove(house); this.Houses.Add(downGradedGreatHouse); } }
private void DowngradeHouses() { var housesToDowngrade = this.Houses .Where(h => (h is GreatHouse) && h.ControlledCities.Count() < DowngradeHouseNumberOfCitiesThreshold) .ToList(); foreach (var greatHouse in housesToDowngrade) { var regularHouse = new House(greatHouse.Name, greatHouse.TreasuryAmount); foreach (var controlledCity in greatHouse.ControlledCities) { regularHouse.AddCityToHouse(controlledCity); } this.Houses.Remove(greatHouse); this.Houses.Add(regularHouse); } }