def handle_event(self, sim_info, event, resolver): super().handle_event(sim_info, event, resolver) if self.owner is not None and self.owner.get_staff_member( ) is not None: group = self.get_valid_group_to_seat() if group is None: return log_host_action( 'Leaving Arriving State for Right This Way State because there is someone waiting for a table.', 'Success') self._change_state(self.owner._right_this_way_situation_state())
def on_activate(self, reader=None): super().on_activate(reader) log_host_action('Starting Host Station State', 'Success') self._test_event_register(TestEvent.GroupWaitingToBeSeated) self._test_event_register(TestEvent.InteractionComplete) group = self.get_valid_group_to_seat() if group is None: return log_host_action( 'Leaving Host Station State for existing waiting table', 'Success') self._change_state(self.owner._right_this_way_situation_state())
def handle_event(self, sim_info, event, resolver): group = None if event == TestEvent.GroupWaitingToBeSeated: group = self.get_valid_group_to_seat() if event == TestEvent.InteractionComplete: if self.owner is not None: if self.owner.sim_of_interest(sim_info): group = self.get_valid_group_to_seat() if group is None: return log_host_action( 'Leaving Host Station State for discovered waiting table', 'Success') self._change_state(self.owner._right_this_way_situation_state())
def handle_event(self, sim_info, event, resolver): if event != TestEvent.InteractionExitedPipeline: return if self.owner is None or not self.owner.sim_of_interest(sim_info): return if not resolver(self._interaction_of_interest): return if self._group is not None: for sim in self._group.all_sims_in_situation_gen(): services.get_event_manager().process_event( test_events.TestEvent.RestaurantTableClaimed, sim_info=sim.sim_info) log_host_action('Leaving Show To Table State', 'Success') self._change_state(self.owner._arriving_situation_state())
def on_activate(self, reader=None): super().on_activate(reader) log_host_action('Starting Show To Table State', 'Success') self._group = self.get_valid_group_to_seat() if self._group is None: self._change_state(self.owner._arriving_situation_state()) return if not self.owner.push_show_table_interactions(self._group): log_host_action( 'Leaving Show To Table State', 'Failed - Leaving without performing interactions.') self._change_state(self.owner._arriving_situation_state()) for custom_key in self._interaction_of_interest.custom_keys_gen(): self._test_event_register(TestEvent.InteractionExitedPipeline, custom_key)
def push_show_table_interactions(self, group): if self.host_show_to_table_interaction is None or self.guest_take_seat_interaction is None: log_host_action( 'During Show To Table State', 'Failed - No Interactions to push on one of the Sims.') return False zone_director = get_restaurant_zone_director() if zone_director is None: log_host_action('During Show To Table State', "Failed - Can't find the zone director.") return False master_sim = group.get_main_sim() if master_sim is None: master_sim = next(group.all_sims_in_situation_gen()) zone_director.claim_table(master_sim) return self.push_host_show_table_interaction(group, zone_director, master_sim)
def push_guest_take_seat_interaction(self, guest, zone_director): (seat_id, _) = zone_director.get_sims_seat(guest) if seat_id is None: log_host_action( 'During Show To Table Seat', "Failed - couldn't find a seat for the Sim {}.".format(guest)) return seat = services.current_zone().object_manager.get(seat_id) if seat is None: log_host_action( 'During Show To Table Seat', "Failed - couldn't find a seat for the Sim {}.".format(guest)) return context = InteractionContext(guest, InteractionContext.SOURCE_SCRIPT, Priority.High) if not guest.push_super_affordance(self.guest_take_seat_interaction, seat, context): log_host_action('During Show To Table State', 'Failed to Push Guest Interaction') else: log_host_action('During Show To Table State', 'Push Guest Interaction on {}'.format(guest))
def on_activate(self, reader=None): super().on_activate(reader=reader) log_host_action('Starting Right This Way State', 'Success') self._group = self.get_valid_group_to_seat() if self._group is None: self.owner._change_state(self.owner._arriving_situation_state()) return if not self.owner.push_right_this_way_social(self._group): log_host_action('Leaving Right This Way State', 'Failed to Push Right This Way Interaction') self.owner._change_state( self.owner._show_to_table_situation_state()) return log_host_action('During Right This Way State', 'Pushed Right This Way Interaction') for custom_key in self._interaction_of_interest.custom_keys_gen(): self._test_event_register(TestEvent.InteractionExitedPipeline, custom_key)
def handle_event(self, sim_info, event, resolver): super().handle_event(sim_info, event, resolver) if event == TestEvent.InteractionExitedPipeline and ( resolver(self._interaction_of_interest) and self.owner.sim_of_interest(sim_info) ) and not resolver.interaction.is_finishing_naturally: log_host_action( 'During Right This Way State', 'Interaction left pipeline without finishing naturally.') self._fail_count += 1 if self._fail_count < self.max_attempts_to_run_social and self.owner.push_right_this_way_social( self._group): log_host_action('During Right This Way State', 'Pushed Right This Way Interaction Again.') return log_host_action('Leaving Right This Way State', 'Max Attempts to Push Affordance') self.owner._change_state( self.owner._show_to_table_situation_state())
def push_host_show_table_interaction(self, group, zone_director, master_sim): host = self.get_staff_member() group_tables = zone_director.get_tables_by_group_id(group.id) if not group_tables: log_host_action( 'During Show To Table', 'Failed to push show to table interactions. Unable to find tables the group reserved.' ) return False context = InteractionContext(host, InteractionContext.SOURCE_SCRIPT, Priority.High) master_sim_context = InteractionContext( master_sim, InteractionContext.SOURCE_SCRIPT, Priority.High) object_manager = services.current_zone().object_manager table_id = group_tables.pop() table = object_manager.get(table_id) (master_sim_chair_id, _) = zone_director.get_sims_seat(master_sim) master_sim_chair = object_manager.get(master_sim_chair_id) if not host.push_super_affordance( self.host_show_to_table_interaction, table, context, saved_participants=[master_sim, master_sim_chair, None, None]): log_host_action( 'During Show To Table State', 'Failed to Push Host Interaction on {}'.format(host)) return False log_host_action('During Show To Table State', 'Pushed Host Interaction on {}'.format(host)) def timer_expired(handle): self.push_master_sim_interaction(group, table, master_sim, master_sim_context, host, master_sim_chair) self._alarm_handle = None self._alarm_handle = alarms.add_alarm( self, clock.interval_in_sim_minutes(self.host_head_start_in_sim_minutes), timer_expired) return True
def push_master_sim_interaction(self, group, table, master_sim, master_sim_context, host, master_sim_chair): if not master_sim.push_super_affordance( self.requesting_sim_show_to_table_interaction, table, master_sim_context, saved_participants=[host, master_sim_chair, None, None]): log_host_action( 'During Show To Table State', 'Failed to Push Master Sim Interaction on {}'.format( master_sim)) else: log_host_action( 'During Show To Table State', 'Pushed Master Sim Interaction on {}'.format(master_sim)) zone_director = get_restaurant_zone_director() if zone_director is None: log_host_action('During Show To Table State', 'Failed - unable to find zone director.') return for guest in group.all_sims_in_situation_gen(): if guest is not master_sim: self.push_guest_take_seat_interaction(guest, zone_director)
def _on_interaction_of_interest_complete(self, **kwargs): log_host_action('Leaving Arriving State', 'Success') self._change_state(self.owner._host_station_situation_state())
def on_activate(self, reader=None): super().on_activate(reader) self._test_event_register(TestEvent.GroupWaitingToBeSeated) log_host_action('Starting Arriving State', 'Success')
def timer_expired(self): log_host_action('During Show To Table State', 'Failed - Timeout occured.') self.owner._change_state(self.owner._arriving_situation_state())
def timer_expired(self): log_host_action('During Right This Way State', 'Failed - Timer expired.') self.owner._change_state(self.owner._show_to_table_situation_state())
def _on_interaction_of_interest_complete(self, **kwargs): log_host_action('Leaving Right This Way State', 'Success') self.owner._change_state(self.owner._show_to_table_situation_state())