def sell_lot_response(dialog): if not dialog.accepted: return business_manager = services.business_service( ).get_business_manager_for_zone() current_zone = services.current_zone() lot = current_zone.lot lot_value = lot.furnished_lot_value business_manager.modify_funds(lot_value) business_manager.transfer_balance_to_household() services.get_zone_manager().clear_lot_ownership(current_zone.id) business_tracker = services.business_service( ).get_business_tracker_for_household(business_manager.owner_household_id, business_manager.business_type) if business_tracker is None: logger.warn( 'Business tracker is None for household {} for business type {}', business_manager.owner_household_id, business_manager.business_type) return business_tracker.remove_owner(current_zone.id) current_zone.disown_household_objects() with telemetry_helper.begin_hook( business_telemetry_writer, TELEMETRY_HOOK_BUSINESS_SOLD, household=services.household_manager().get( business_manager.owner_household_id)) as hook: hook.write_enum(TELEMETRY_HOOK_BUSINESS_TYPE, business_manager.business_type) msg = InteractionOps_pb2.SellRetailLot() msg.retail_zone_id = current_zone.id distributor.system.Distributor.instance().add_event( Consts_pb2.MSG_SELL_RETAIL_LOT, msg)
def travel_to_venue(self): if self._zone_id is None: logger.error('Failed to travel to venue') return active_sim_info = services.active_sim_info() active_sim = active_sim_info.get_sim_instance( allow_hidden_flags=ALL_HIDDEN_REASONS_EXCEPT_UNINITIALIZED) if active_sim is None: return lot_id = None zone = services.get_zone_manager().get(self._zone_id) if zone is None: lot_id = services.get_persistence_service( ).get_lot_id_from_zone_id(self._zone_id) else: lot_id = zone.lot.lot_id if lot_id is None: return pick = PickInfo(pick_type=PickType.PICK_TERRAIN, lot_id=lot_id, ignore_neighborhood_id=True) context = interactions.context.InteractionContext( active_sim, interactions.context.InteractionContext. SOURCE_SCRIPT_WITH_USER_INTENT, interactions.priority.Priority.High, insert_strategy=interactions.context.QueueInsertStrategy.NEXT, pick=pick) active_sim.push_super_affordance( VenueEventDramaNode.GO_TO_VENUE_ZONE_INTERACTION, None, context)
def sell_retail_lot_response(dialog): if not dialog.accepted: return business_service = services.business_service() business_manager = business_service.get_business_manager_for_zone() current_zone = services.current_zone() lot = current_zone.lot lot_value = lot.furnished_lot_value business_manager.modify_funds(lot_value) business_manager.transfer_balance_to_household() zone_id = current_zone.id services.get_zone_manager().clear_lot_ownership(zone_id) business_service.remove_owner( zone_id, household_id=business_manager.owner_household_id) msg = InteractionOps_pb2.SellRetailLot() msg.retail_zone_id = current_zone.id distributor.system.Distributor.instance().add_event( Consts_pb2.MSG_SELL_RETAIL_LOT, msg)
def _get_lot_commodity_tracker(self): zone = services.get_zone_manager().get(self._zone_id) if zone is None: return statistic_component = zone.lot.get_component( objects.components.types.STATISTIC_COMPONENT) if statistic_component is None: return return statistic_component.get_commodity_tracker()
def clear_owned_business(self, household_id): if household_id not in self._business_trackers: return zone_manager = services.get_zone_manager() business_trackers = self._business_trackers[household_id] for business_tracker in business_trackers: for zone_id in business_tracker.business_managers: zone_manager.clear_lot_ownership(zone_id) del self._business_trackers[household_id]
def _collect_resolvers(self): resolvers = [] zone_manager = services.get_zone_manager() lot_id_to_zone_id_dict = get_lot_id_to_zone_ids_dict(self._street) for (lot_id, zone_ids) in lot_id_to_zone_id_dict.items(): if not zone_ids: continue zone_id = zone_ids[0] zone = zone_manager.get(zone_id, allow_uninstantiated_zones=True) if zone is not None: resolvers.append(LotResolver(zone.lot)) return resolvers
def force_set_eco_footprint_value(self, new_value, update_lot_values=True): if not self._is_eco_footprint_compatible: return street = services.street_service().get_street(self) street_footprint = self.get_street_footprint() street_footprint.set_value(new_value) if update_lot_values: zone_manager = services.get_zone_manager() for (lot_id, zone_ids ) in world.street.get_lot_id_to_zone_ids_dict(street).items(): zone = zone_manager.get(zone_ids[0], allow_uninstantiated_zones=True) if zone is not None: zone.lot.commodity_tracker.set_value( EcoFootprintTunables.LOT_FOOTPRINT, new_value) self._fully_compute_street_convergence() self._update_eco_footprint_effects(skip_nudge=True)
def generate_olaf_service_deleted_clone_schema_data(*args, zone_id: int = None, filter=None, **kwargs): lost_and_found = services.get_object_lost_and_found_service() zone_manager = services.get_zone_manager() if not (lost_and_found and zone_manager): return [] clones_to_delete_by_zone = lost_and_found.clones_to_delete_by_zone clones_to_delete_by_street = lost_and_found.clones_to_delete_by_street clones_to_delete = [] object_ids = set() for (zone_id, objects) in clones_to_delete_by_zone.items(): if zone_id is not None and zone_id != zone_id: continue zone = zone_manager.get(zone_id) for object_id in objects: street_str = 'n/a' for (street_id, objects) in clones_to_delete_by_street.items(): if object_id in objects: street_str = str(street_id) break clones_to_delete.append({ 'object': _olaf_obj_str(zone, object_id), 'zone': _olaf_zone_str(zone_id, zone), 'street': street_str }) object_ids.add(object_id) if zone_id is None: for (street_id, objects) in clones_to_delete_by_street.items(): for object_id in objects: if object_id in object_ids: continue clones_to_delete.append({ 'object': _olaf_obj_str(services.current_zone(), object_id), 'zone': 'n/a', 'street': street_id }) return clones_to_delete
def on_enter(self): super().on_enter() client = services.client_manager().get_first_client() home_zone_id = client.household.home_zone_id if home_zone_id == 0: return _ZoneSpinUpStateResult.DONE zone_manager = services.get_zone_manager() loaded_zones = set() loaded_zones.add(services.current_zone_id()) for sim_info in services.sim_info_manager().values(): if sim_info.is_selectable: start_away_actions = True sim_zone_id = sim_info.zone_id if sim_zone_id == 0: start_away_actions = False elif sim_zone_id not in loaded_zones: zone_manager.load_uninstantiated_zone_data(sim_zone_id) loaded_zones.add(sim_zone_id) travel_group = sim_info.travel_group if travel_group is not None: if travel_group.zone_id == 0: start_away_actions = False elif travel_group.zone_id not in loaded_zones: zone_manager.load_uninstantiated_zone_data( travel_group.zone_id) loaded_zones.add(travel_group.zone_id) if sim_info.away_action_tracker is not None: if start_away_actions: if sim_info.away_action_tracker.is_sim_info_valid_to_run_away_actions( ): sim_info.away_action_tracker.start() else: sim_info.away_action_tracker.stop() if sim_info.away_action_tracker is not None: sim_info.away_action_tracker.stop() elif sim_info.away_action_tracker is not None: sim_info.away_action_tracker.stop() home_zone_id = client.household.home_zone_id if home_zone_id not in loaded_zones: zone_manager.load_uninstantiated_zone_data(home_zone_id) return _ZoneSpinUpStateResult.DONE
def on_enter(self): super().on_enter() client = services.client_manager().get_first_client() home_zone_id = client.household.home_zone_id if home_zone_id == 0: return _ZoneSpinUpStateResult.DONE zone_manager = services.get_zone_manager() loaded_zones = set() loaded_zones.add(services.current_zone_id()) for sim_info in services.sim_info_manager().values(): if sim_info.is_selectable: if sim_info.zone_id not in loaded_zones: zone_manager.load_uninstantiated_zone_data( sim_info.zone_id) loaded_zones.add(sim_info.zone_id) sim_info.away_action_tracker.start() else: sim_info.away_action_tracker.stop() home_zone_id = client.household.home_zone_id if home_zone_id not in loaded_zones: zone_manager.load_uninstantiated_zone_data(home_zone_id) return _ZoneSpinUpStateResult.DONE
def generate_object_lost_and_found_service_data(*args, zone_id: int = None, filter=None, **kwargs): lost_and_found = services.get_object_lost_and_found_service() zone_manager = services.get_zone_manager() sim_info_manager = services.sim_info_manager() household_manager = services.household_manager() if not (lost_and_found and (zone_manager and sim_info_manager) and household_manager): return [] registered_objects = [] for locator in lost_and_found.registered_object_locators: if zone_id is not None and zone_id != locator.zone_id: continue zone = zone_manager.get(locator.zone_id) sim_str = str(locator.sim_id) sim_info = sim_info_manager.get(locator.sim_id) if sim_info: sim_str = '{}:{}'.format(str(sim_info), locator.sim_id) household_str = str(locator.household_id) household = household_manager.get(locator.household_id) if household: household_str = '{}:{}'.format(household.name, locator.household_id) registered_objects.append({ 'object': _olaf_obj_str(zone, locator.object_id), 'zone': _olaf_zone_str(locator.zone_id, zone), 'street': locator.open_street_id, 'sim': sim_str, 'household': household_str }) return registered_objects
def get_zone_for_provider(self, provider): zone_manager = services.get_zone_manager() for (zone, stored_provider) in self._zone_provider.items(): if stored_provider is provider: return zone_manager.get(zone, allow_uninstantiated_zones=True)
def generate_venue_game_service_data(*args, zone_id: int = None, **kwargs): service_info = [] venue_game_service = services.venue_game_service() venue_service = services.venue_service() street_service = services.street_service() zone_manager = services.get_zone_manager() if venue_game_service is None: return service_info active_zone = services.current_zone() voting_open = street_service.voting_open for (zone_id, instance) in venue_game_service._zone_provider.items(): zone = zone_manager.get(zone_id, allow_uninstantiated_zones=True) if zone is None: continue lot_name = zone.lot.get_lot_name() try: household = zone.lot.get_household() except: household = None household_name = '' if household is None else '(' + household.name + ')' zone_str = lot_name + household_name + ' ' + str(zone) civic_policy_entry = [] enacted_policies = instance.get_enacted_policies(tuning=True) balloted_policies = instance.get_balloted_policies(tuning=True) up_for_repeal = instance.get_up_for_repeal_policies(tuning=True) source_venue = None for policy in instance.get_civic_policies(tuning=True): status_str = '' if not enacted_policies: source_venue = VenueService.get_variable_venue_source_venue( policy.sub_venue) if source_venue is not None: if policy.sub_venue is source_venue: status_str += '[Enacted by default] ' if policy in enacted_policies: status_str += 'Enacted ' if policy in balloted_policies: status_str += 'Balloted ' if policy in up_for_repeal: status_str += 'Up for Repeal' if status_str == '': status_str = 'Dormant' if policy.vote_count_statistic is None: votes = 'n/a' else: votes = instance.get_stat_value(policy.vote_count_statistic) entry = { 'civic_policy': str(policy), 'status': status_str, 'votes': votes } civic_policy_entry.append(entry) entry = { 'zone': zone_str, 'voting_open': 'Yes' if voting_open else 'No', 'active': str(type(venue_service.active_venue)) if zone is active_zone else '', 'civic_policies': civic_policy_entry } service_info.append(entry) service_info = sorted(service_info, key=lambda entry: entry['zone']) return service_info