def _post_change(self):
     self._recursion_count -= 1
     if self._recursion_count <= 0:
         self._recursion_count = 0
         if self._new_venue_type is None:
             self._new_venue_type = self.source_venue_type
         if self.active_venue_type != self._new_venue_type:
             self.active_venue_type = self._new_venue_type
             services.venue_game_service().change_venue_type(
                 self, self.active_venue_type, self.source_venue_type)
Example #2
0
 def _scheduled_end_action(self):
     if self._end_alarm is None:
         return
     self._end_alarm = None
     services.venue_game_service().on_venue_type_changed.unregister(
         self._on_venue_type_changed)
     if self._zone_ids_impacted:
         for zone_id in self._zone_ids_impacted:
             self._turn_on_utilities_for_zone(zone_id)
         self._zone_ids_impacted = None
 def close_voting(self):
     if services.venue_game_service() is None:
         return
     self._pre_change()
     super().close_voting()
     self._post_change()
     self._log_event('close voting')
Example #4
0
 def _get_civic_policy_provider(self, *args, **kwargs):
     zone_id = self._get_zone_id(**kwargs)
     if zone_id is None:
         return
     venue_game_service = services.venue_game_service()
     if venue_game_service is None:
         return
     return venue_game_service.get_provider(zone_id)
 def is_eligible_voter(self, sim_info):
     venue_game_service = services.venue_game_service()
     if venue_game_service is None:
         return False
     zone = venue_game_service.get_zone_for_provider(self)
     world_id = services.get_persistence_service().get_world_id_from_zone(
         zone.id)
     return world_id == sim_info.household.get_home_world_id()
Example #6
0
 def _scheduled_start_action(self, scheduler, alarm_data, extra_data):
     if self._end_alarm is not None:
         if self._end_alarm.finishing_time < alarm_data.end_time:
             alarms.cancel_alarm(self._end_alarm)
             self._end_alarm = None
         else:
             return
     now = services.time_service().sim_now
     time_to_end = alarm_data.end_time - now.time_since_beginning_of_week()
     self._end_alarm = alarms.add_alarm(
         self,
         time_to_end,
         lambda _: self._scheduled_end_action(),
         cross_zone=True)
     self._zone_ids_impacted = self._collect_residential_zones()
     for zone_id in self._zone_ids_impacted:
         self._turn_off_utilities_for_zone(zone_id)
     services.venue_game_service().on_venue_type_changed.register(
         self._on_venue_type_changed)
 def get_world_description_id(self):
     venue_game_service = services.venue_game_service()
     if venue_game_service is None:
         return 0
     zone = venue_game_service.get_zone_for_provider(self)
     if zone is None:
         return 0
     else:
         world_description_id = get_world_description_id_from_zone_id(
             zone.id)
         if world_description_id is None:
             return 0
     return world_description_id
Example #8
0
def set_venue(venue_tuning: TunableInstanceParam(sims4.resources.Types.VENUE),
              _connection=None):
    if venue_tuning is None:
        sims4.commands.output(
            'Requesting an unknown venue type: {0}'.format(venue_tuning),
            _connection)
        return False
    venue_game_service = services.venue_game_service()
    if venue_game_service is None:
        return services.venue_service().on_change_venue_type_at_runtime(
            venue_tuning)
    else:
        provider = venue_game_service.get_provider(services.current_zone_id())
        return venue_game_service.change_venue_type(provider, venue_tuning)
 def open_close_voting_loot_resolver_list(self):
     venue_game_service = services.venue_game_service()
     if venue_game_service is None:
         return ()
     zone = venue_game_service.get_zone_for_provider(self)
     if zone is None:
         return ()
     if zone.is_instantiated:
         household_id = zone.lot.owner_household_id
     else:
         zone_data = services.get_persistence_service().get_zone_proto_buff(
             zone.id)
         if zone_data is not None:
             household_id = zone_data.household_id
     if household_id == 0:
         return ()
     household = services.household_manager().get(household_id)
     if household is None:
         return ()
     return [
         SingleSimResolver(sim_info) for sim_info in household.sim_infos()
     ]
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