def remove_settlement(self, building): """Removes the settlement property from tiles within the radius of the given building""" settlement = building.settlement buildings_to_abandon, settlement_coords_to_change = Tear.additional_removals_after_tear(building) assert building not in buildings_to_abandon self.abandon_buildings(buildings_to_abandon) flat_land_set = self.terrain_cache.cache[TerrainRequirement.LAND][(1, 1)] land_or_coast = self.terrain_cache.land_or_coast settlement_tiles_changed = [] clean_coords = set() for coords in settlement_coords_to_change: tile = self.ground_map[coords] tile.settlement = None building = tile.object if building is not None: settlement.remove_building(building) building.owner = None building.settlement = None if coords in land_or_coast: clean_coords.add(coords) settlement_tiles_changed.append(self.ground_map[coords]) del settlement.ground_map[coords] Minimap.update(coords) if coords in flat_land_set: self.available_flat_land += 1 self.available_land_cache.add_area(clean_coords) self._register_change() if self.terrain_cache: settlement.buildability_cache.modify_area(clean_coords) SettlementRangeChanged.broadcast(settlement, settlement_tiles_changed)
def remove_settlement(self, building): """Removes the settlement property from tiles within the radius of the given building""" settlement = building.settlement buildings_to_abandon, settlement_coords_to_change = Tear.additional_removals_after_tear( building) assert building not in buildings_to_abandon self.abandon_buildings(buildings_to_abandon) flat_land_set = self.terrain_cache.cache[TerrainRequirement.LAND][(1, 1)] land_or_coast = self.terrain_cache.land_or_coast settlement_tiles_changed = [] clean_coords = set() for coords in settlement_coords_to_change: tile = self.ground_map[coords] tile.settlement = None building = tile.object if building is not None: settlement.remove_building(building) building.owner = None building.settlement = None if coords in land_or_coast: clean_coords.add(coords) settlement_tiles_changed.append(self.ground_map[coords]) del settlement.ground_map[coords] Minimap.update(coords) if coords in flat_land_set: self.available_flat_land += 1 self.available_land_cache.add_area(clean_coords) self._register_change() if self.terrain_cache: settlement.buildability_cache.modify_area(clean_coords) SettlementRangeChanged.broadcast(settlement, settlement_tiles_changed)
def confirm_ranged_delete(self, building): buildings_to_destroy = len(Tear.additional_removals_after_tear(building)[0]) if buildings_to_destroy == 0: return True title = _("Destroy all buildings") msg = _("This will destroy all the buildings that fall outside of" " the settlement range.") msg += u"\n\n" msg += N_("%s additional building will be destroyed.", "%s additional buildings will be destroyed", buildings_to_destroy) % buildings_to_destroy return building.session.ingame_gui.show_popup(title, msg, show_cancel_button=True)
def confirm_ranged_delete(self, building): buildings_to_destroy = len(Tear.additional_removals_after_tear(building)[0]) if buildings_to_destroy == 0: return True title = T("Destroy all buildings") msg = T("This will destroy all the buildings that fall outside of" " the settlement range.") msg += u"\n\n" msg += NT("%s additional building will be destroyed.", "%s additional buildings will be destroyed", buildings_to_destroy) % buildings_to_destroy return building.session.ingame_gui.open_popup(title, msg, show_cancel_button=True)