def get_active_lot_decoration_type_id(self):
     deco_lot = self._get_active_lot_decoration_state()
     if deco_lot is None:
         decorations_logger.error(
             "Could not find active lot's decoration data.")
         return
     return deco_lot.deco_type_id
Exemple #2
0
 def remove_decoration(self, deco_location):
     if self._apply_client_decoration(deco_location, lot_decoration=None):
         self._visual_state = DecoratedLotVisualState.CUSTOM
         self._get_modifiable_deco_state().remove_decoration(deco_location)
         return True
     decorations_logger.error('Failed to remove lot decoration at {}',
                              deco_location)
     return False
 def does_lot_have_custom_decorations(self, holiday_id):
     if holiday_id is None:
         decorations_logger.error(
             'None is being used as holiday_id.  holiday_id should always be numeric.'
         )
         holiday_id = 0
     decoration_state = self._get_active_lot_decoration_state()
     return decoration_state is not None and decoration_state.has_custom_decorations(
         holiday_id)
 def _get_active_lot_decoration_state(self):
     zone_id = services.current_zone_id()
     neighborhood_decoration_state = self.get_neighborhood_state_for_zone(
         zone_id)
     if neighborhood_decoration_state is None:
         decorations_logger.error(
             'Could not find neighborhood state zone {}', zone_id)
         return
     return neighborhood_decoration_state.get_deco_lot_by_zone_id(zone_id)
 def handle_lot_owner_changed(self, zone_id, household):
     state = self.get_neighborhood_state_for_zone(zone_id)
     if state is None:
         return
     lot = state.get_deco_lot_by_zone_id(zone_id)
     if lot is None:
         decorations_logger.error(
             'Could not find decorated lot info for zone {}', zone_id)
         return
     lot.on_household_owner_changed(household)
Exemple #6
0
 def reset_decorations(self):
     if self.deco_type_id in self._decoration_states:
         for (location, _) in self.deco_state.custom_decorations:
             self.remove_decoration(location)
         if not self.deco_state.custom_decorations:
             del self._decoration_states[self.deco_type_id]
     else:
         decorations_logger.error(
             'No decorations on lot for decoration type {}',
             self.deco_type_id)
Exemple #7
0
 def apply_decoration(self, lot_decoration, deco_location):
     if self._apply_client_decoration(deco_location,
                                      lot_decoration=lot_decoration):
         self._visual_state = DecoratedLotVisualState.CUSTOM
         self._get_modifiable_deco_state().apply_decoration(
             lot_decoration, deco_location)
         return True
     decorations_logger.error('Failed to set lot decoration {} at {}',
                              lot_decoration, deco_location)
     return False
Exemple #8
0
 def perform(self):
     decorations_manager = services.get_instance_manager(
         Types.LOT_DECORATION)
     guid = self._interaction.get_participant(ParticipantType.PickedItemId)
     decoration = decorations_manager.get(guid)
     if decoration is None:
         decorations_logger.error('Referencing unknown decoration guid {}',
                                  guid)
     else:
         for location in self._locations_to_decorate:
             if location not in decoration.available_locations:
                 continue
             self._decoration_service.apply_decoration_for_holiday(
                 decoration, location, self.occasion())
Exemple #9
0
 def save_deco_states_to_proto(self, lot_decorations_proto):
     if not self._decoration_states and self.deco_type_id == DEFAULT_DECORATION_PROVIDER.decoration_type_id:
         return
     with ProtocolBufferRollback(
             lot_decorations_proto) as lot_setting_proto:
         lot_setting_proto.zone_id = self.zone_id
         lot_setting_proto.active_decoration_state = self.deco_type_id
         for (deco_type_id,
              decorated_state) in self._decoration_states.items():
             if decorated_state is EMPTY_DECORATED_STATE:
                 decorations_logger.error(
                     'Trying to save an empty decorated state into for deco type id {}.  This should never happen!',
                     deco_type_id)
             else:
                 with ProtocolBufferRollback(
                         lot_setting_proto.decoration_states
                 ) as deco_state_proto:
                     deco_state_proto.decoration_type_id = deco_type_id
                     decorated_state.save_locations_to_proto(
                         deco_state_proto.decorated_locations)