예제 #1
0
 def _try_pick_up_item_from_ground(self, item: ItemOnGround):
     item_name = build_item_name(item.item_id)
     did_add_item = try_add_item_to_inventory(self.game_state, item.item_id)
     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_name)
     else:
         self.info_message.set_message("No space for " + item_name)
예제 #2
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)
예제 #3
0
    def on_select(self, game_state: GameState):
        player_state = game_state.player_state
        can_afford = player_state.money >= self.cost
        if not can_afford:
            play_sound(SoundId.WARNING)
            return "Not enough gold!"

        did_add_item = try_add_item_to_inventory(game_state, self.item_id)
        if not did_add_item:
            play_sound(SoundId.WARNING)
            return "Not enough space!"

        player_state.modify_money(-self.cost)
        play_sound(SoundId.EVENT_PURCHASED_SOMETHING)
        return "Bought " + self.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_id: ItemId):
     try_add_item_to_inventory(self.game_state, item_id)
예제 #6
0
 def _equip_item_on_startup(self, item_id):
     try_add_item_to_inventory(self.game_state, item_id)
예제 #7
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)
예제 #8
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)