Exemplo n.º 1
0
 def return_lost_objects(self):
     returned_objects = defaultdict(list)
     current_zone = services.current_zone()
     current_zone_id = services.current_zone_id()
     current_open_street_id = current_zone.open_street_id
     active_household = services.active_household()
     for locator in list(self._object_locators):
         if locator.zone_id != current_zone_id:
             if locator.open_street_id != current_open_street_id:
                 elapsed_time = services.time_service(
                 ).sim_now - locator.time_stamp
                 if elapsed_time.in_minutes() < locator.time_before_lost:
                     continue
                 if locator.object_data is None:
                     self.remove_object(locator.object_id)
                 else:
                     (obj_returned,
                      owner) = self._return_lost_object(locator)
                     if obj_returned is not None:
                         if owner is not None:
                             if isinstance(owner, int):
                                 if owner == active_household.id:
                                     returned_objects[owner].append(
                                         obj_returned)
                                     if owner.household is active_household:
                                         returned_objects[owner].append(
                                             obj_returned)
                             elif owner.household is active_household:
                                 returned_objects[owner].append(
                                     obj_returned)
     if not returned_objects:
         return
     returned_objects_string = None
     household_manager = services.household_manager()
     for (owner, objects) in returned_objects.items():
         if isinstance(owner, int):
             household = household_manager.get(owner)
             header = ObjectLostAndFoundService.FAMILY_NAME_HEADER(
                 household.name)
             next_string = LocalizationHelperTuning.get_bulleted_list(
                 header,
                 *(LocalizationHelperTuning.get_object_name(obj)
                   for obj in objects))
         else:
             next_string = LocalizationHelperTuning.get_bulleted_list(
                 LocalizationHelperTuning.get_sim_name(owner),
                 *(LocalizationHelperTuning.get_object_name(obj)
                   for obj in objects))
         if returned_objects_string is None:
             returned_objects_string = next_string
         else:
             returned_objects_string = LocalizationHelperTuning.NEW_LINE_LIST_STRUCTURE(
                 returned_objects_string, next_string)
     dialog = ObjectLostAndFoundService.OBJECTS_RETURN_MESSAGE_DIALOG(
         services.active_sim_info())
     dialog.show_dialog(additional_tokens=(returned_objects_string, ))
Exemplo n.º 2
0
 def get_string(self, sim_info):
     degree_tracker = sim_info.degree_tracker
     if degree_tracker is None:
         logger.error(
             'Trying to perform UniversityDynamicSignView op on sim {} with no degree tracker.',
             sim_info)
         return
     uni = self.university
     manager = services.get_instance_manager(
         sims4.resources.Types.UNIVERSITY_MAJOR)
     degree_ids = degree_tracker.get_available_degrees_to_enroll()[
         uni.guid64]
     bullet_points = ()
     if self.info_type == UniversityInfoType.PRESTIGE_DEGREES:
         bullet_points = (manager.get(i).display_name
                          for i in degree_ids
                          if i in uni.prestige_degree_ids)
     elif self.info_type == UniversityInfoType.NON_PRESTIGE_DEGREES:
         bullet_points = (manager.get(i).display_name
                          for i in degree_ids
                          if i in uni.non_prestige_degree_ids)
     final_string = LocalizationHelperTuning.get_bulleted_list(
         None, *bullet_points)
     if final_string is None:
         final_string = self.fallback_string(sim_info)
     return final_string
 def _ui_metadata_gen(self):
     additional_information = self._get_additional_information()
     if additional_information and self.show_gardening_details():
         additional_information.sort()
         object_info_names = []
         object_info_descriptions = []
         bullet_points = []
         for (_, name, value) in additional_information:
             object_info_names.append(name)
             object_info_descriptions.append(value)
             bullet_point = LocalizationHelperTuning.get_name_value_pair(name, value)
             bullet_points.append(bullet_point)
         description = LocalizationHelperTuning.get_bulleted_list(None, *bullet_points)
         plant_name = LocalizationHelperTuning.get_object_name(self.owner.definition)
     else:
         object_info_names = None
         object_info_descriptions = None
         if GardeningTuning.is_spliced(self.owner):
             description = self._spliced_description
             plant_name = GardeningTuning.SPLICED_PLANT_NAME()
         else:
             if GardeningTuning.is_shoot(self.owner) and self.root_stock is not None:
                 description = LocalizationHelperTuning.get_object_name(self.root_stock.main_spawner)
             else:
                 description = LocalizationHelperTuning.get_object_description(self.owner.definition)
             plant_name = LocalizationHelperTuning.get_object_name(self.owner.definition)
     subtext = self.owner.get_state_strings()
     yield ('object_info_names', object_info_names)
     yield ('object_info_descriptions', object_info_descriptions)
     yield ('recipe_name', plant_name)
     yield ('recipe_description', description)
     if subtext is not None:
         yield ('subtext', subtext)
Exemplo n.º 4
0
 def _apply_to_subject_and_target(self, subject, target, resolver):
     knowledge = subject.relationship_tracker.get_knowledge(target.sim_id,
                                                            initialize=True)
     if knowledge is None:
         return
     trait_tracker = target.trait_tracker
     if self.traits.learned_type == self.TRAIT_SPECIFIED:
         traits = tuple(trait for trait in self.traits.potential_traits
                        if trait_tracker.has_trait(trait)
                        if trait not in knowledge.known_traits)
     elif self.traits.learned_type == self.TRAIT_ALL:
         traits = self._select_traits(knowledge, trait_tracker)
     elif self.traits.learned_type == self.TRAIT_RANDOM:
         traits = self._select_traits(knowledge,
                                      trait_tracker,
                                      random_count=self.traits.count)
         if not traits and self.notification_no_more_traits is not None:
             interaction = resolver.interaction
             if interaction is not None:
                 self.notification_no_more_traits(
                     interaction).show_notification(
                         additional_tokens=(subject, target),
                         recipients=(subject, ),
                         icon_override=IconInfoData(obj_instance=target))
     for trait in traits:
         knowledge.add_known_trait(trait)
     if traits:
         interaction = resolver.interaction
         if interaction is not None and self.notification is not None:
             trait_string = LocalizationHelperTuning.get_bulleted_list(
                 None, *(trait.display_name(target) for trait in traits))
             self.notification(interaction).show_notification(
                 additional_tokens=(subject, target, trait_string),
                 recipients=(subject, ),
                 icon_override=IconInfoData(obj_instance=target))
Exemplo n.º 5
0
 def get_state_strings(self, first_string=None):
     obj = self.owner
     int_token = 0
     for state_int_data in self.state_value_numbers:
         state_value = state_int_data.state_value
         if state_value is None:
             continue
         if obj.has_state(state_value.state):
             if obj.get_state(state_value.state) is state_value:
                 int_token = state_int_data.number
                 break
     bullet_points = [] if first_string is None else [first_string]
     for state_string_datas in self.state_value_strings:
         for state_string_data in state_string_datas:
             state_value = state_string_data.state_value
             if state_value is None:
                 continue
             if obj.has_state(state_value.state) and obj.get_state(
                     state_value.state) is state_value:
                 bullet_point = state_string_data.text(int_token)
                 bullet_points.append(bullet_point)
                 break
     if bullet_points:
         if len(bullet_points) == 1:
             return LocalizationHelperTuning.get_raw_text(bullet_points[0])
         else:
             return LocalizationHelperTuning.get_bulleted_list(
                 None, *bullet_points)
Exemplo n.º 6
0
 def get_test_result(self, sim, cls):
     unavailable_items = Counter()
     unavailable_item_description = {}
     for item in self.ingredients:
         item_count = sim.inventory_component.get_item_quantity_by_definition(
             item.ingredient)
         if item_count < item.quantity:
             unavailable_items[
                 item.ingredient] += item.quantity - item_count
             unavailable_item_description[
                 item.ingredient] = item.missing_ingredient_additional_text
     if unavailable_items:
         tooltip = LocalizationHelperTuning.get_bulleted_list(
             ItemCost.UNAVAILABLE_TOOLTIP_HEADER(sim),
             *tuple(
                 LocalizationHelperTuning.get_object_count(
                     count,
                     ingredientDef,
                     detail_text=unavailable_item_description[ingredientDef]
                 ) for (ingredientDef, count) in unavailable_items.items()))
         return event_testing.results.TestResult(
             False,
             "Sim doesn't have the required items in inventory.",
             tooltip=lambda *_, **__: tooltip)
     return TestResult.TRUE
Exemplo n.º 7
0
 def get_interaction_tooltip(self, tooltip=None, sim=None):
     if self.ingredients:
         item_tooltip = LocalizationHelperTuning.get_bulleted_list(self.AVAILABLE_TOOLTIP_HEADER(sim), *tuple(LocalizationHelperTuning.get_object_count(ingredient.quantity, ingredient.ingredient) for ingredient in self.ingredients))
         if tooltip is None:
             return item_tooltip
         return LocalizationHelperTuning.get_new_line_separated_strings(tooltip, item_tooltip)
     return tooltip
 def _apply_to_subject_and_target(self, subject, target, resolver):
     if subject.is_npc:
         return
     obj_counter = Counter()
     if self._object_rewards.spawn_type == ObjectRewardsTuning.SPAWNER_REWARD:
         participant = resolver.get_participant(
             self._object_rewards.spawner_participant)
         if participant is not None:
             weighted_data = participant.interaction_spawner_data()
             if weighted_data is not None:
                 self._create_object_rewards(weighted_data, obj_counter,
                                             resolver)
     elif self._object_rewards.spawn_type == ObjectRewardsTuning.TUNABLE_REWARD:
         for _ in range(self._object_rewards.quantity):
             weight_pairs = [(data.weight, data.reward)
                             for data in self._object_rewards.reward_objects
                             ]
             self._create_object_rewards(weight_pairs, obj_counter,
                                         resolver)
     if obj_counter and self._notification is not None:
         obj_names = [
             LocalizationHelperTuning.get_object_count(count, obj)
             for (obj, count) in obj_counter.items()
         ]
         dialog = self._notification(subject, resolver=resolver)
         dialog.show_dialog(
             additional_tokens=(LocalizationHelperTuning.get_bulleted_list(
                 None, *obj_names), ))
     return True
Exemplo n.º 9
0
 def __call__(self, objs):
     key_fn = operator.attrgetter('definition')
     return LocalizationHelperTuning.get_bulleted_list(
         None,
         *tuple(
             self.bullet_text(definition, len(tuple(group)))
             for (definition, group) in itertools.groupby(
                 sorted(objs, key=key_fn), key=key_fn)))
Exemplo n.º 10
0
 def complete_milestone(self, aspiration, sim_info):
     aspiration_type = aspiration.aspiration_type()
     if aspiration_type == AspriationType.FULL_ASPIRATION:
         sim_info = self._owner_ref()
         if not (aspiration.is_child_aspiration and sim_info.is_child):
             return
         super().complete_milestone(aspiration, sim_info)
         if aspiration.reward is not None:
             aspiration.reward.give_reward(sim_info)
         track = self.active_track
         if track is None:
             logger.error('Active track is None when completing full aspiration.')
             return
         if aspiration in track.aspirations.values():
             if aspiration.screen_slam is not None:
                 aspiration.screen_slam.send_screen_slam_message(sim_info, sim_info, aspiration.display_name, track.display_text)
             if all(self.milestone_completed(track_aspiration.guid64) for track_aspiration in track.aspirations.values()):
                 if track.reward is not None:
                     reward_payout = track.reward.give_reward(sim_info)
                 else:
                     reward_payout = ()
                 reward_text = LocalizationHelperTuning.get_bulleted_list(None, *(reward.get_display_text() for reward in reward_payout))
                 dialog = track.notification(sim_info, SingleSimResolver(sim_info))
                 dialog.show_dialog(icon_override=(track.icon, None), secondary_icon_override=(None, sim_info), additional_tokens=(reward_text,), event_id=aspiration.guid64)
             next_aspiration = track.get_next_aspriation(aspiration)
             if next_aspiration is not None:
                 self._activate_aspiration(next_aspiration)
                 for objective in next_aspiration.objectives:
                     while objective.set_starting_point(self.data_object):
                         self.update_objective(objective.guid64, 0, objective.goal_value(), objective.is_goal_value_money)
             else:
                 self._active_aspiration = None
             with telemetry_helper.begin_hook(writer, TELEMETRY_HOOK_COMPLETE_MILESTONE, sim=sim_info.get_sim_instance()) as hook:
                 hook.write_enum('type', aspiration.aspiration_type())
                 hook.write_guid('guid', aspiration.guid64)
         services.get_event_manager().process_event(test_events.TestEvent.UnlockEvent, sim_info=sim_info, unlocked=aspiration)
     elif aspiration_type == AspriationType.FAMILIAL:
         super().complete_milestone(aspiration, sim_info)
         for relationship in aspiration.target_family_relationships:
             family_member_sim_id = sim_info.get_relation(relationship)
             family_member_sim_info = services.sim_info_manager().get(family_member_sim_id)
             while family_member_sim_info is not None:
                 services.get_event_manager().process_event(test_events.TestEvent.FamilyTrigger, sim_info=family_member_sim_info, trigger=aspiration)
     elif aspiration_type == AspriationType.WHIM_SET:
         self._whimsets_to_reset.add(aspiration.guid64)
         super().complete_milestone(aspiration, sim_info)
         self._owner_ref().whim_tracker.activate_set(aspiration)
     elif aspiration_type == AspriationType.NOTIFICATION:
         dialog = aspiration.notification(sim_info, SingleSimResolver(sim_info))
         dialog.show_dialog(event_id=aspiration.guid64)
         super().complete_milestone(aspiration, sim_info)
     else:
         super().complete_milestone(aspiration, sim_info)
 def notify_result_and_push_bill_modifier(self):
     lot = services.active_lot()
     additional_tokens = ()
     if self.policies_not_followed:
         additional_tokens = (LocalizationHelperTuning.get_bulleted_list(None, *self.policies_not_followed),)
     if self.follow_status == PolicyFollowing.NOT_FOLLOWED:
         lot.set_stat_value(self.commodity_notfollow, self.commodity_notfollow.max_value_tuning)
         self._show_inspection_notification(self.inspection_failure_notification, additional_tokens=additional_tokens)
     elif self.follow_status == PolicyFollowing.PARTIAL_FOLLOWED:
         self._show_inspection_notification(self.inspection_partial_success_notification, additional_tokens=additional_tokens)
     else:
         lot.set_stat_value(self.commodity_follow, self.commodity_follow.max_value_tuning)
         self._show_inspection_notification(self.inspection_successful_notification)
Exemplo n.º 12
0
	def _apply_to_subject_and_target (self, subject, target, resolver, placement_override_func = None, post_object_create_func = None):
		if subject.is_npc:
			return
		obj_counter = Counter()
		quantity = self._object_rewards.quantity
		quantity += self._object_rewards.tested_bonus_quantity.get_modified_value(resolver)
		for _ in range(int(quantity)):
			weight_pairs = [(data.weight, (data.reward, data.states_on_reward_object, data.quantity)) for data in self._object_rewards.reward_objects]
			self._create_object_rewards(weight_pairs, obj_counter, resolver, subject = subject, placement_override_func = placement_override_func, post_object_create_func = post_object_create_func)
		if obj_counter and self._notification is not None:
			obj_names = [LocalizationHelperTuning.get_object_count(count, obj) for (obj, count) in obj_counter.items()]
			dialog = self._notification(subject, resolver = resolver)
			dialog.show_dialog(additional_tokens = (LocalizationHelperTuning.get_bulleted_list(None, *obj_names),))
		return True
Exemplo n.º 13
0
 def _get_fish_caught_text(self, fish_caught):
     all_fish_strings = []
     for fish in fish_caught:
         type_loc_string = LocalizationHelperTuning.get_object_name(
             fish.definition)
         value_loc_string = LocalizationHelperTuning.get_money(
             fish.current_value)
         weight_loc_string = fish.get_localized_weight()
         fish_data_text = self.fish_information_text(
             weight_loc_string, type_loc_string, value_loc_string)
         all_fish_strings.append(fish_data_text)
     final_fish_text = LocalizationHelperTuning.get_bulleted_list(
         self.fish_header_text(), *all_fish_strings)
     return final_fish_text
Exemplo n.º 14
0
 def get_string(self, _):
     bullet_points = ()
     if self.info_type == UniversityInfoType.PRESTIGE_DEGREES:
         bullet_points = (d.display_name
                          for d in self.university.prestige_degrees)
     elif self.info_type == UniversityInfoType.NON_PRESTIGE_DEGREES:
         bullet_points = (
             d.display_name
             for d in self.university.non_prestige_degrees)
     elif self.info_type == UniversityInfoType.ORGANIZATIONS:
         bullet_points = (o.display_name()
                          for o in self.university.organizations
                          if not o.hidden)
     return LocalizationHelperTuning.get_bulleted_list(
         None, *bullet_points)
Exemplo n.º 15
0
 def show_royalty_notification(self, royalty_payment_dict):
     notification_text = LocalizationHelperTuning.get_new_line_separated_strings(
         *(LocalizationHelperTuning.get_bulleted_list(
             RoyaltyTracker.get_name_for_type(royalty_type),
             *(RoyaltyTracker.get_line_item_string(r.entry_name,
                                                   royalty_payment_dict[r])
               for r in royalty_list))
           for (royalty_type, royalty_list) in self._royalties.items()
           if royalty_list))
     sim_info = self.sim_info
     resolver = SingleSimResolver(sim_info)
     dialog = self.ROYALTY_NOTIFICATION(sim_info,
                                        resolver,
                                        text=lambda *_: notification_text)
     dialog.show_dialog()
Exemplo n.º 16
0
 def get_state_strings(self):
     obj = self.owner
     int_token = 0
     for state_int_data in self.state_value_numbers:
         state_value = state_int_data.state_value
         while obj.has_state(state_value.state) and obj.get_state(state_value.state) is state_value:
             int_token = state_int_data.number
             break
     bullet_points = []
     for state_string_datas in self.state_value_strings:
         for state_string_data in state_string_datas:
             state_value = state_string_data.state_value
             while obj.has_state(state_value.state) and obj.get_state(state_value.state) is state_value:
                 bullet_point = state_string_data.text(int_token)
                 bullet_points.append(bullet_point)
                 break
     if bullet_points:
         if len(bullet_points) == 1:
             return LocalizationHelperTuning.get_raw_text(bullet_points[0])
         return LocalizationHelperTuning.get_bulleted_list(None, *bullet_points)
Exemplo n.º 17
0
 def _handle_parented_objects(self, obj):
     objects_in_household_inventory = []
     for child_obj in tuple(obj.children):
         if self._allow_destruction_on_inventory_transfer(child_obj):
             child_obj.destroy(source=self.owner,
                               cause='Parent is being inventoried.')
         else:
             if self.player_try_add_object(child_obj):
                 continue
             if build_buy.move_object_to_household_inventory(child_obj):
                 objects_in_household_inventory.append(child_obj)
             else:
                 world_obj = self.owner
                 fgl_context_fn = create_fgl_context_for_object if world_obj.is_on_active_lot(
                 ) else create_fgl_context_for_object_off_lot
                 fgl_starting_location = create_starting_location(
                     position=world_obj.position)
                 (translation, orientation) = find_good_location(
                     fgl_context_fn(fgl_starting_location, child_obj))
                 if translation is not None and orientation is not None:
                     child_obj.set_parent(
                         None,
                         transform=sims4.math.Transform(
                             translation, orientation),
                         routing_surface=world_obj.routing_surface)
                 else:
                     child_obj.destroy(
                         source=self.owner,
                         cause=
                         "Parent is being inventoried and object can't be placed anywhere."
                     )
     if objects_in_household_inventory and self.PARENTED_OBJECT_MOVED_TO_HOUSEHOLD_INVENTORY_NOTIFICATION is not None:
         sim_info = self.owner.sim_info if self.owner.is_sim else services.active_sim_info(
         )
         notification = self.PARENTED_OBJECT_MOVED_TO_HOUSEHOLD_INVENTORY_NOTIFICATION(
             sim_info, resolver=SingleObjectResolver(obj))
         notification.show_dialog(
             additional_tokens=(LocalizationHelperTuning.get_bulleted_list(
                 None,
                 *(LocalizationHelperTuning.get_object_name(obj)
                   for obj in objects_in_household_inventory)), ))
Exemplo n.º 18
0
 def _ui_metadata_gen(self):
     additional_information = self._get_additional_information()
     if additional_information and self.show_gardening_details():
         additional_information.sort()
         object_info_names = []
         object_info_descriptions = []
         bullet_points = []
         for (_, name, value) in additional_information:
             object_info_names.append(name)
             object_info_descriptions.append(value)
             bullet_point = LocalizationHelperTuning.get_name_value_pair(
                 name, value)
             bullet_points.append(bullet_point)
         description = LocalizationHelperTuning.get_bulleted_list(
             None, *bullet_points)
         plant_name = LocalizationHelperTuning.get_object_name(
             self.owner.definition)
     else:
         object_info_names = None
         object_info_descriptions = None
         if GardeningTuning.is_spliced(self.owner):
             description = self._spliced_description
             plant_name = GardeningTuning.SPLICED_PLANT_NAME()
         else:
             if GardeningTuning.is_shoot(
                     self.owner) and self.root_stock is not None:
                 description = LocalizationHelperTuning.get_object_name(
                     self.root_stock.main_spawner)
             else:
                 description = LocalizationHelperTuning.get_object_description(
                     self.owner.definition)
             plant_name = LocalizationHelperTuning.get_object_name(
                 self.owner.definition)
     subtext = self.owner.get_state_strings()
     yield ('object_info_names', object_info_names)
     yield ('object_info_descriptions', object_info_descriptions)
     yield ('recipe_name', plant_name)
     yield ('recipe_description', description)
     if subtext is not None:
         yield ('subtext', subtext)
Exemplo n.º 19
0
 def _handle_promotion(self):
     self._pending_promotion = True
     previous_level_tuning = self.current_level_tuning
     previous_salary = self.get_hourly_pay()
     previous_highest_level = self._sim_info.career_tracker.get_highest_level_reached(self.guid64)
     try:
         yield None
     finally:
         if self.current_level_tuning is not previous_level_tuning:
             self._pending_promotion = False
             if self.user_level > previous_highest_level and self.current_level_tuning.promotion_reward is not None:
                 reward_payout = self.current_level_tuning.promotion_reward.give_reward(self._sim_info)
                 reward_text = LocalizationHelperTuning.get_bulleted_list(None, *(reward.get_display_text() for reward in reward_payout))
             else:
                 reward_text = None
             (_, next_work_time, _) = self.get_next_work_time()
             salary = self.get_hourly_pay()
             salary_increase = salary - previous_salary
             level_text = self.current_level_tuning.promotion_notification_text(self._sim_info)
             is_not_school = not self.get_is_school()
             if reward_text is None:
                 self.send_career_message(self.career_messages.promote_career_rewardless_notification, next_work_time, salary, salary_increase, level_text, display_career_info=is_not_school)
             else:
                 self.send_career_message(self.career_messages.promote_career_notification, next_work_time, salary, salary_increase, level_text, reward_text, display_career_info=is_not_school)
             promotion_sting = self.current_level_tuning.promotion_audio_sting
             if promotion_sting is not None:
                 play_tunable_audio(promotion_sting)
             if self.current_level_tuning.screen_slam is not None:
                 self.current_level_tuning.screen_slam.send_screen_slam_message(self._sim_info, self._sim_info, self.current_level_tuning.title(self._sim_info), self.user_level, self.current_track_tuning.career_name(self._sim_info))
             if self.has_outfit():
                 self._sim_info.refresh_current_outfit()
             else:
                 new_outfit = self._sim_info._outfits.get_outfit_for_clothing_change(None, OutfitChangeReason.DefaultOutfit, resolver=SingleSimResolver(self._sim_info))
                 self._sim_info.set_current_outfit(new_outfit)
             with telemetry_helper.begin_hook(career_telemetry_writer, TELEMETRY_HOOK_CAREER_PROMOTION, sim=self._sim_info) as hook:
                 hook.write_int(TELEMETRY_CAREER_ID, self.guid64)
                 hook.write_int(TELEMETRY_CAREER_LEVEL, self._user_level)
                 hook.write_guid(TELEMETRY_TRACK_ID, self._current_track.guid64)
                 hook.write_int(TELEMETRY_TRACK_LEVEL, self._level)
Exemplo n.º 20
0
 def _check_and_complete_aspiration_track(self, aspiration_track,
                                          completed_aspiration_id,
                                          sim_info):
     if all(
             self.milestone_completed(track_aspiration)
             for track_aspiration in aspiration_track.aspirations.values()):
         if aspiration_track.reward is not None:
             reward_payout = aspiration_track.reward.give_reward(sim_info)
         else:
             reward_payout = ()
         reward_text = LocalizationHelperTuning.get_bulleted_list(
             None,
             *(reward.get_display_text(SingleSimResolver(sim_info))
               for reward in reward_payout))
         dialog = aspiration_track.notification(sim_info,
                                                SingleSimResolver(sim_info))
         dialog.show_dialog(
             icon_override=IconInfoData(
                 icon_resource=aspiration_track.icon),
             secondary_icon_override=IconInfoData(obj_instance=sim_info),
             additional_tokens=(reward_text, ),
             event_id=completed_aspiration_id)
Exemplo n.º 21
0
 def payout_rebates(self, *_):
     if not self._rebates:
         return
     rebate_reasons = []
     for rebate_item_enum in self._rebates.keys():
         rebate_data = self.REBATES.get(rebate_item_enum)
         rebate_reasons.append(
             rebate_data.notification_text(
                 rebate_data.rebate_payout_type
                 if type(rebate_data.rebate_payout_type) is int else
                 rebate_data.rebate_payout_type * 100))
     rebate_reasons_string = LocalizationHelperTuning.get_bulleted_list(
         None, *rebate_reasons)
     total_rebate_amount = sum(self._rebates.values())
     active_sim_info = services.active_sim_info()
     dialog = self.REBATE_NOTIFICATION(active_sim_info)
     dialog.show_dialog(additional_tokens=(total_rebate_amount,
                                           rebate_reasons_string))
     self._household.funds.add(
         total_rebate_amount,
         reason=Consts_pb2.TELEMETRY_MONEY_ASPIRATION_REWARD,
         sim=active_sim_info)
     self.add_rebate_cycle()
     self.clear_rebates()
Exemplo n.º 22
0
 def complete_milestone(self, aspiration, sim_info):
     aspiration_type = aspiration.aspiration_type()
     if aspiration_type == AspriationType.FULL_ASPIRATION:
         sim_info = self._owner_ref()
         if not (aspiration.is_child_aspiration and sim_info.is_child):
             return
         super().complete_milestone(aspiration, sim_info)
         if aspiration.reward is not None:
             aspiration.reward.give_reward(sim_info)
         track = self.active_track
         if track is None:
             logger.error(
                 'Active track is None when completing full aspiration.')
             return
         if aspiration in track.aspirations.values():
             if aspiration.screen_slam is not None:
                 aspiration.screen_slam.send_screen_slam_message(
                     sim_info, sim_info, aspiration.display_name,
                     track.display_text)
             if all(
                     self.milestone_completed(track_aspiration.guid64)
                     for track_aspiration in track.aspirations.values()):
                 if track.reward is not None:
                     reward_payout = track.reward.give_reward(sim_info)
                 else:
                     reward_payout = ()
                 reward_text = LocalizationHelperTuning.get_bulleted_list(
                     None,
                     *(reward.get_display_text()
                       for reward in reward_payout))
                 dialog = track.notification(sim_info,
                                             SingleSimResolver(sim_info))
                 dialog.show_dialog(icon_override=(track.icon, None),
                                    secondary_icon_override=(None,
                                                             sim_info),
                                    additional_tokens=(reward_text, ),
                                    event_id=aspiration.guid64)
             next_aspiration = track.get_next_aspriation(aspiration)
             if next_aspiration is not None:
                 self._activate_aspiration(next_aspiration)
                 for objective in next_aspiration.objectives:
                     while objective.set_starting_point(self.data_object):
                         self.update_objective(
                             objective.guid64, 0, objective.goal_value(),
                             objective.is_goal_value_money)
             else:
                 self._active_aspiration = None
             with telemetry_helper.begin_hook(
                     writer,
                     TELEMETRY_HOOK_COMPLETE_MILESTONE,
                     sim=sim_info.get_sim_instance()) as hook:
                 hook.write_enum('type', aspiration.aspiration_type())
                 hook.write_guid('guid', aspiration.guid64)
         services.get_event_manager().process_event(
             test_events.TestEvent.UnlockEvent,
             sim_info=sim_info,
             unlocked=aspiration)
     elif aspiration_type == AspriationType.FAMILIAL:
         super().complete_milestone(aspiration, sim_info)
         for relationship in aspiration.target_family_relationships:
             family_member_sim_id = sim_info.get_relation(relationship)
             family_member_sim_info = services.sim_info_manager().get(
                 family_member_sim_id)
             while family_member_sim_info is not None:
                 services.get_event_manager().process_event(
                     test_events.TestEvent.FamilyTrigger,
                     sim_info=family_member_sim_info,
                     trigger=aspiration)
     elif aspiration_type == AspriationType.WHIM_SET:
         self._whimsets_to_reset.add(aspiration.guid64)
         super().complete_milestone(aspiration, sim_info)
         self._owner_ref().whim_tracker.activate_set(aspiration)
     elif aspiration_type == AspriationType.NOTIFICATION:
         dialog = aspiration.notification(sim_info,
                                          SingleSimResolver(sim_info))
         dialog.show_dialog(event_id=aspiration.guid64)
         super().complete_milestone(aspiration, sim_info)
     else:
         super().complete_milestone(aspiration, sim_info)
Exemplo n.º 23
0
 def decide(self, interaction):
     self._actions = self._default_actions
     picked_sims = interaction.get_participants(ParticipantType.PickedSim)
     if picked_sims:
         valid_sim_ids = set()
         picked_sim_count = len(picked_sims)
         actor = interaction.sim
         if picked_sim_count == 1:
             sim = next(iter(picked_sims))
             (return_val, error_string) = self._get_error_and_string(interaction, sim)
             if not return_val:
                 if sims.sim_log.outcome_archiver.enabled:
                     sims.sim_log.log_interaction_outcome(interaction, 'partial Outcome: single fail')
                 if self._single_failure_string:
                     text = self._single_failure_string(error_string)
                     self._send_notification(text, actor)
                     if sims.sim_log.outcome_archiver.enabled:
                         sims.sim_log.log_interaction_outcome(interaction, 'partial Outcome: single success')
                     valid_sim_ids.add(sim.id)
                     if self._single_success_string:
                         text = self._single_success_string(actor, sim)
                         self._send_notification(text, actor)
             else:
                 if sims.sim_log.outcome_archiver.enabled:
                     sims.sim_log.log_interaction_outcome(interaction, 'partial Outcome: single success')
                 valid_sim_ids.add(sim.id)
                 if self._single_success_string:
                     text = self._single_success_string(actor, sim)
                     self._send_notification(text, actor)
         else:
             bullet_points = []
             for sim in picked_sims:
                 (return_val, error_string) = self._get_error_and_string(interaction, sim)
                 if not return_val:
                     bullet_points.append(error_string)
                 else:
                     valid_sim_ids.add(sim.id)
             valid_sim_count = len(valid_sim_ids)
             if valid_sim_count == picked_sim_count:
                 if sims.sim_log.outcome_archiver.enabled:
                     sims.sim_log.log_interaction_outcome(interaction, 'partial Outcome: multiple total success')
                 if self._all_success_string:
                     text = interaction.create_localized_string(self._all_success_string)
                     self._send_notification(text, actor)
             else:
                 bullet_text = LocalizationHelperTuning.get_bulleted_list(None, *bullet_points)
                 if valid_sim_count == 0:
                     if sims.sim_log.outcome_archiver.enabled:
                         sims.sim_log.log_interaction_outcome(interaction, 'partial Outcome: multiple total failure')
                     if self._all_failure_string:
                         text = self._all_failure_string(bullet_text)
                         self._send_notification(text, actor)
                 else:
                     if sims.sim_log.outcome_archiver.enabled:
                         sims.sim_log.log_interaction_outcome(interaction, 'partial Outcome: partial success')
                     if self._partial_success_string:
                         text = self._partial_success_string(bullet_text)
                         self._send_notification(text, actor)
         interaction.interaction_parameters['picked_item_ids'] = valid_sim_ids
         if not valid_sim_ids:
             if self._total_failure is not None:
                 self._actions = self._total_failure
     elif sims.sim_log.outcome_archiver.enabled:
         sims.sim_log.log_interaction_outcome(interaction, 'partial Outcome: No picked sims')
     interaction.outcome_result = self._actions.outcome_result
     interaction.outcome_display_message = self._actions.display_message
Exemplo n.º 24
0
 def _get_treasure_caught_text(self, treasure_caught):
     treasure_string = LocalizationHelperTuning.get_bulleted_list(
         self.treasure_header_text(),
         *(LocalizationHelperTuning.get_object_name(treasure)
           for treasure in treasure_caught))
     return treasure_string
Exemplo n.º 25
0
 def get_results_list(self, *additional_tokens):
     return LocalizationHelperTuning.get_bulleted_list(
         None, *additional_tokens, *self._get_strings_for_results_list())
Exemplo n.º 26
0
 def get_current_trends_loc_string(self):
     self._update_trends()
     trend_list = LocalizationHelperTuning.get_bulleted_list(
         None, *(trend.trend_name for trend in self._current_trends))
     return LocalizationHelperTuning.get_new_line_separated_strings(
         trend_list, self._get_description_string())
Exemplo n.º 27
0
 def show_royalty_notification(self, royalty_payment_dict):
     notification_text = LocalizationHelperTuning.get_new_line_separated_strings(*(LocalizationHelperTuning.get_bulleted_list(RoyaltyTracker.get_name_for_type(royalty_type), *(RoyaltyTracker.get_line_item_string(r.entry_name, royalty_payment_dict[r]) for r in royalty_list)) for (royalty_type, royalty_list) in self._royalties.items()))
     notification_text = LocalizationHelperTuning.get_new_line_separated_strings(self.ROYALTY_NOTIFICATION_HEADER, notification_text)
     sim_info = self.sim_info
     resolver = SingleSimResolver(sim_info)
     dialog = self.ROYALTY_NOTIFICATION(sim_info, resolver, text=lambda *_: notification_text)
     dialog.show_dialog()