def _check_market_place_in_range(self): """Notifies the user via a message in case there is no market place in range""" for building in self.get_buildings_in_range(): if building.id == BUILDINGS.MARKET_PLACE_CLASS: if StaticPather.get_path_on_roads(self.island, self, building) is not None: # a market place is in range return # no market place found self.session.ingame_gui.message_widget.add(self.position.origin.x, self.position.origin.y, \ 'NO_MARKET_PLACE_IN_RANGE')
def _check_main_square_in_range(self): """Notifies the user via a message in case there is no main square in range""" for building in self.get_buildings_in_range(): if building.id == BUILDINGS.MAIN_SQUARE_CLASS: 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(self.position.origin.x, self.position.origin.y, \ '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 classes. Counts all 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 _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 classes. Counts all settlements.""" building_to_check = [] check_connection = [] for settlement in _get_player_settlements(session): for building in settlement.buildings: if building.id == building_class: building_to_check.append(building) else: for b_class in classes: if building.id == b_class: check_connection.append(building) break 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