Ejemplo n.º 1
0
 def _get_objects_gen(cls, inst, target, context, **kwargs):
     (interaction_col_id, _) = ObjectCollectionData.get_collection_info_by_definition(target.definition.id)
     if inst:
         inst._combine_data = CollectionInteractionData.COLLECTION_COMBINING_TUNING.get(interaction_col_id)
         inst._collectible_data = set(ObjectCollectionData.get_collection_data(interaction_col_id).object_list)
     for collectible in context.sim.inventory_component:
         if collectible.id == target.id and collectible.stack_count() == 1:
             pass
         while collectible.collectable_component:
             (collectible_id, _) = ObjectCollectionData.get_collection_info_by_definition(collectible.definition.id)
             if collectible_id == interaction_col_id:
                 yield collectible
Ejemplo n.º 2
0
 def _get_fruit_spawn_weight(self, fruit):
     if self._exclusive_fruits and fruit not in GardeningTuning.EXCLUSIVE_FRUITS:
         return 0
     plant_rarity = None
     fruit_rarity = None
     gardening_collection_data = ObjectCollectionData.get_collection_data(
         CollectionIdentifier.Gardening)
     for obj_data in gardening_collection_data.object_list:
         if obj_data.collectable_item is fruit.definition:
             fruit_rarity = obj_data.rarity
         if self.root_stock is not None:
             if obj_data.collectable_item is self.root_stock.main_spawner:
                 plant_rarity = obj_data.rarity
         if fruit_rarity:
             if plant_rarity:
                 break
     if fruit_rarity is None:
         fruit_rarity = ObjectCollectionRarity.COMMON
     else:
         fruit_rarity = ObjectCollectionData.COLLECTION_RARITY_MAPPING[
             fruit_rarity].rarity_value
     if self.root_stock is not None:
         if plant_rarity is None:
             plant_rarity = ObjectCollectionRarity.COMMON
         else:
             plant_rarity = ObjectCollectionData.COLLECTION_RARITY_MAPPING[
                 plant_rarity].rarity_value
         if fruit_rarity < plant_rarity:
             spawn_rarity = plant_rarity
         else:
             spawn_rarity = fruit_rarity
     else:
         spawn_rarity = fruit_rarity
     spawn_weight = GardeningTuning.SPAWN_WEIGHTS[spawn_rarity]
     return spawn_weight
Ejemplo n.º 3
0
 def _get_name(cls,
               inst,
               target=DEFAULT,
               context=DEFAULT,
               collection_type=None,
               **interaction_parameters):
     if collection_type is None:
         return
     collection_data = ObjectCollectionData.get_collection_data(
         collection_type)
     return cls.display_name(collection_data.collection_name)
Ejemplo n.º 4
0
 def _object_definitions_gen(self):
     collection_type = self.interaction_parameters.get('collection_type')
     if collection_type is None:
         return
     collection_data = ObjectCollectionData.get_collection_data(
         collection_type)
     if collection_data is None:
         return
     yield from (i.collectable_item for i in collection_data.object_list)
     yield from (i.collectable_item
                 for i in collection_data.bonus_object_list)
Ejemplo n.º 5
0
 def _get_entry_rarity_text(self, entry_def):
     (_, collectible_data,
      _) = ObjectCollectionData.get_collection_info_by_definition(
          entry_def.id)
     if collectible_data is None:
         logger.error(
             'Failed to find rarity text for Fishing Bait Entry {}.',
             entry_def)
         return
     rarity_text = ObjectCollectionData.COLLECTION_RARITY_MAPPING[
         collectible_data.rarity].text_value
     return self.entry_text_rarity(rarity_text)
 def get_definition_notebook_data(self, ingredient_cache=()):
     definition_manager = services.definition_manager()
     fruit_definition = definition_manager.get(
         self.entry_object_definition_id)
     if fruit_definition is None:
         return
     gardening_tuned_values = fruit_definition.cls._components.gardening._tuned_values
     plant_definition = gardening_tuned_values.plant
     sub_list_data = []
     sub_list_data.append(
         SubListData(None, 0, 0, True, False,
                     self.entry_text_value(fruit_definition.price / 5),
                     None, None))
     season_service = services.season_service()
     if season_service is not None:
         season_text = GardeningTuning.get_seasonality_text_from_plant(
             plant_definition)
         if season_text is None:
             season_text = GardeningTuning.PLANT_SEASONALITY_TEXT(
                 GardeningTuning.SEASONALITY_ALL_SEASONS_TEXT)
         sub_list_data.append(
             SubListData(None, 0, 0, True, False, season_text, None, None))
     sub_list_data.append(
         SubListData(
             None, 0, 0, True, False,
             LocalizationHelperTuning.get_object_description(
                 plant_definition), None, None))
     for (splice_fruit, splice_fruit_result
          ) in gardening_tuned_values.splicing_recipies.items():
         sub_list_data.append(
             SubListData(
                 None, 0, 0, True, False,
                 self.entry_text_splicing(splice_fruit,
                                          splice_fruit_result), None, None))
     gardening_collection_data = ObjectCollectionData.get_collection_data(
         CollectionIdentifier.Gardening)
     for obj_data in itertools.chain(
             gardening_collection_data.object_list,
             gardening_collection_data.bonus_object_list):
         if obj_data.collectable_item is fruit_definition:
             rarity_text = ObjectCollectionData.COLLECTION_RARITY_MAPPING[
                 obj_data.rarity].text_value
             sub_list_data.append(
                 SubListData(None, 0, 0, True, False,
                             self.entry_text_rarity(rarity_text), None,
                             None))
             break
     entry_data = EntryData(
         LocalizationHelperTuning.get_object_name(fruit_definition),
         IconInfoData(obj_def_id=fruit_definition.id), None, sub_list_data,
         None)
     return entry_data
Ejemplo n.º 7
0
 def potential_interactions(cls, target, context, **kwargs):
     for collection_type in CollectionIdentifier.values:
         if CollectionIdentifier.Unindentified == collection_type:
             continue
         if ObjectCollectionData.get_collection_data(
                 collection_type) is None:
             continue
         yield AffordanceObjectPair(cls,
                                    target,
                                    cls,
                                    None,
                                    collection_type=collection_type,
                                    **kwargs)
 def on_player_added(self, sim, target):
     self._arena_obj = target.part_owner
     candidate_cards = []
     player_card = None
     sim_inventory = sim.inventory_component
     from_inventory = True
     player_slot = self._get_slot_for_sim_position(target, sim.position)
     slotted_objects = player_slot.children
     if slotted_objects:
         player_card = player_slot.children[0]
         if sim.is_npc:
             from_inventory = False
     else:
         for obj in sim_inventory:
             if obj.definition.has_build_buy_tag(self.card_tag):
                 if obj.state_value_active(
                         self.card_information.challenge_state_value):
                     player_card = obj
                     player_card.set_state(
                         self.card_information.default_state_value.state,
                         self.card_information.default_state_value)
                     break
                 candidate_cards.append(obj)
         if player_card is None:
             if candidate_cards:
                 player_card = random.choice(candidate_cards)
             else:
                 from_inventory = False
                 card_options = ObjectCollectionData.get_collection_data(
                     self.collectable_type).object_list
                 if not card_options:
                     logger.error('Collection {} is an invalid id',
                                  self.collectable_type)
                     return
                 card_definition = random.choice(
                     card_options).collectable_item
                 player_card = create_object(card_definition)
                 card_level_state_value = random.choice(
                     self.card_information.level_state.values)
                 player_card.set_state(card_level_state_value.state,
                                       card_level_state_value)
                 player_card.persistence_group = PersistenceGroups.NONE
     if player_card is None:
         logger.error(
             'Failed to create card for player {} for card candidates {}',
             sim, candidate_cards)
     card_definition = player_card.get_game_animation_definition()
     if card_definition is None:
         logger.error(
             'Card {} has no game animation definition tuned and will not be displayed on the card battle object',
             player_card)
         return
     if self.challenger_definition is None:
         self.challenger_definition = card_definition
         sim.add_buff_from_op(buff_type=self.challenger_buff.buff_type,
                              buff_reason=self.challenger_buff.buff_reason)
     else:
         self.defender_definition = card_definition
     self._create_card_on_slot(player_card, player_slot)
     self._apply_card_placement_bonus(sim, player_card)
     reservation_handler = player_card.get_reservation_handler(sim)
     reservation_handler.begin_reservation()
     self._players_cards[sim] = (player_card, from_inventory,
                                 reservation_handler)