示例#1
0
文件: main.py 项目: Relvius/Drake
    def pickup(self):
        indexes = adjacent_items(player.loc.col, player.loc.row)
        if len(indexes) == 0:
            message("You don't see anything around you.")
            return "no turn"
        elif len(indexes) > 0:
            n = 0
            if len(indexes) > 1:
                options = [area.items[x]["item"].name.capitalize() for x in indexes]
                n = menus.menu('Pick what up?', options, 40, area.con, MAP_WIDTH, MAP_HEIGHT)
            if n == "exit":
                return "no turn"
            item = area.items[indexes[n]]
            held = player.inv.pick_up(item)
            if held != '':
                # Picked it up with an empty hamd/mouth.
                message("You pick up the " + item["item"].name + " with your " + held + ".", lt.yellow)
                area.items.pop(indexes[n])
                return "took turn"

            else:
                # Hands/mouth are full.
                part_list = []
                options = []
                # Presents a modified version of the self.drop menu.
                for key, value in player.inv.holding_slots.iteritems():
                    item_name = value["item"].name.capitalize()
                    part_list.append(key)
                    text = item_name + '   {' + key + '}'
                    options.append(text)
                key = menus.menu("You can't grab anything else! What do you want to drop?", options, MENU_WIDTH, area.con, MAP_WIDTH, MAP_HEIGHT)
                if key == 'exit':
                    return "no turn"
                else:
                    choice = part_list[key]
                player.inv.drop(choice, area.items)

                # Need to repeat the ["inv"].pick_up() call, because the first must have failed:
                player.inv.pick_up(item)
                area.items.pop(indexes[n])
                message("You drop the " + item["item"].name + " and pick up the " + item["item"].name, lt.yellow)

                return "took turn"
示例#2
0
文件: main.py 项目: Relvius/Drake
 def drop(self):
     options = []
     part_list = []
     for key, value in player.inv.holding_slots.iteritems():
         item_name = 'Nothing'
         if value:
             item_name = value["item"].name.capitalize()
         part_list.append(key)
         text = item_name + '   {' + key + '}'
         options.append(text)
     key = menus.menu('Drop what?', options, 40, area.con, MAP_WIDTH, MAP_HEIGHT)
     if key == 'exit':
         return "no turn"
     else:
         choice = part_list[key]
     if player.inv.holding_slots[choice] is not None:
         item_name = player.inv.holding_slots[choice]["item"].name
         message("You drop the " + item_name + ".", lt.yellow)
         player.inv.drop(choice, area.items)
         return "took turn"
     else:
         message("You're not holding anything with that.", lt.yellow)
         return "no turn"