def _check_main_square_in_range(self): """Notifies the user via a message in case there is no main square in range""" if not self.owner.is_local_player: return # only check this for local player for building in self.get_buildings_in_range(): if building.id == BUILDINGS.MAIN_SQUARE: if StaticPather.get_path_on_roads(self.island, self, building) is not None: # a main square is in range return # no main square found # check_duplicate: only trigger once for different settlers of a neighborhood self.session.ingame_gui.message_widget.add(point=self.position.origin, string_id='NO_MAIN_SQUARE_IN_RANGE', check_duplicate=True)
def _building_connected_to_any_of(session, building_class, *classes): """Returns the exact amount of buildings of type *building_class* that are connected to any building of a class in the building type list *classes*. Counts all player settlements.""" building_to_check = [] check_connection = [] for settlement in _get_player_settlements(session): building_to_check.extend(settlement.buildings_by_id[building_class]) for b_class in classes: for building in settlement.buildings_by_id[b_class]: check_connection.append(building) found_connected = 0 for building in building_to_check: for check in check_connection: if StaticPather.get_path_on_roads(building.island, building, check): found_connected += 1 break return found_connected
def _check_main_square_in_range(self): """Notifies the user via a message in case there is no main square in range""" if not self.owner.is_local_player: return # only check this for local player for building in self.get_buildings_in_range(): if building.id == BUILDINGS.MAIN_SQUARE: if StaticPather.get_path_on_roads(self.island, self, building) is not None: # a main square is in range if hasattr(self, "_main_square_status_icon"): RemoveStatusIcon.broadcast(self, self, SettlerNotConnectedStatus) del self._main_square_status_icon return if not hasattr(self, "_main_square_status_icon"): self._main_square_status_icon = SettlerNotConnectedStatus(self) # save ref for removal later AddStatusIcon.broadcast(self, self._main_square_status_icon) # no main square found # check_duplicate: only trigger once for different settlers of a neighborhood self.session.ingame_gui.message_widget.add(point=self.position.origin, string_id='NO_MAIN_SQUARE_IN_RANGE', check_duplicate=True)