Example #1
0
 def sell(item_name):
     item = game.find_item_by_name(item_name.lower())
     if not item:
         print(text.get_message_item_not_owned(item_name))
     else:
         game.player.gold += int(item.price * 0.5)
         inventory.remove_item(item)
         print(text.get_message_item_sold(item))
def take_item():
    item_name = input("Which item do you want to take?\n> ")
    item = game.find_item_by_name(item_name, items)
    if not item:
        print("Sorry, item " + item_name + " not in chest.")
        return show()
    else:
        inventory.add_item(item)
        items.remove(item)
        return show()
def leave_item():
    item_name = input("Which item do you want to leave?\n> ")
    item = game.find_item_by_name(item_name, game.player.inventory)
    if not item:
        print("Sorry, you do not own " + item_name + ".")
        return show()
    else:
        items.append(item)
        inventory.remove_item(item)
        return show()
Example #4
0
    def buy(self, item_name):
        item = game.find_item_by_name(item_name.lower(), self.inventory)
        if not item:
            print(text.get_message_item_not_selling(item_name))
            return

        if game.player.gold < item.price:
            print(text.MESSAGE_NOT_ENOUGH_GOLD)
        else:
            game.player.gold -= item.price
            inventory.add_item(item)
            if self.name == "grave digger":
                self.inventory.remove(item)
            print(text.get_message_item_bought(item))
Example #5
0
def set_default_rooms():
    room_1_monsters = [
        copy.deepcopy(game.find_monster_by_name("rat")),
        copy.deepcopy(game.find_monster_by_name("gnoll"))
    ]
    room_1_rewards = None
    room_2_monsters = [
        copy.deepcopy(game.find_monster_by_name("wolf")),
        copy.deepcopy(game.find_monster_by_name("rat"))
    ]
    room_2_rewards = [game.find_item_by_name("potion")]
    room_1 = {"monsters": room_1_monsters, "rewards": room_1_rewards}
    room_2 = {"monsters": room_2_monsters, "rewards": room_2_rewards}
    global default_rooms
    default_rooms = [Room(**room_1), Room(**room_2)]