Пример #1
0
 def __init__(self, cost: int, item_type: ItemType, name: str):
     self.cost = cost
     self.item_type = item_type
     self.name = name
     self.item_effect = get_item_effect(self.item_type)
     self.item_equipment_category = ITEMS[
         self.item_type].item_equipment_category
Пример #2
0
 def set_item_inventory(self, items: List[ItemType]):
     for slot_number, item_type in enumerate(items):
         if item_type:
             item_effect = get_item_effect(item_type)
             item_data = ITEMS[item_type]
             item_equipment_category = item_data.item_equipment_category
             event = self.game_state.player_state.item_inventory.put_item_in_inventory_slot(
                 item_effect, item_equipment_category, slot_number)
             self._handle_item_equip_event(event)
Пример #3
0
 def _try_pick_up_item_from_ground(self, item: ItemOnGround):
     item_effect = get_item_effect(item.item_type)
     item_data = ITEMS[item.item_type]
     item_equipment_category = item_data.item_equipment_category
     did_add_item = try_add_item_to_inventory(self.game_state, item_effect,
                                              item_equipment_category)
     if did_add_item:
         play_sound(SoundId.EVENT_PICKED_UP)
         self.game_state.items_on_ground.remove(item)
         self.info_message.set_message("You picked up " + item_data.name)
     else:
         self.info_message.set_message("No space for " + item_data.name)
    def on_select(self, game_state: GameState) -> Optional[str]:
        player_has_it = game_state.player_state.item_inventory.has_item_in_inventory(
            ITEM_TYPE_FROG)
        if player_has_it:
            game_state.player_state.item_inventory.lose_item_from_inventory(
                ITEM_TYPE_FROG)

            reward_item_type = get_reward_for_hero(
                game_state.player_state.hero_id)
            reward_effect = get_item_effect(reward_item_type)
            reward_data = ITEMS[reward_item_type]
            reward_equipment_category = reward_data.item_equipment_category
            did_add_item = try_add_item_to_inventory(
                game_state, reward_effect, reward_equipment_category)
            if not did_add_item:
                game_state.items_on_ground.append(
                    create_item_on_ground(
                        reward_item_type,
                        game_state.player_entity.get_position()))
            play_sound(SoundId.EVENT_COMPLETED_QUEST)
            return "Reward gained: " + reward_data.name
        else:
            play_sound(SoundId.WARNING)
            return "You don't have that!"
Пример #5
0
 def add_starting_item(self, item_type: ItemType):
     data = ITEMS[item_type]
     item_effect = get_item_effect(item_type)
     try_add_item_to_inventory(self.game_state, item_effect,
                               data.item_equipment_category)
Пример #6
0
 def _equip_item_on_startup(self, item_type):
     data = ITEMS[item_type]
     item_effect = get_item_effect(item_type)
     try_add_item_to_inventory(self.game_state, item_effect,
                               data.item_equipment_category)
Пример #7
0
 def _handle_item_equip_event(self, event):
     if isinstance(event, ItemWasDeactivated):
         get_item_effect(event.item_type).apply_end_effect(self.game_state)
     elif isinstance(event, ItemWasActivated):
         get_item_effect(event.item_type).apply_start_effect(
             self.game_state)