예제 #1
0
def try_use(player):
    chosen_item = inventory_menu(
        player,
        'Press the key next to an item to use it, x to examine, or any other to cancel.\n')
    if chosen_item is not None:
        actions.use(player, chosen_item.owner)
        return True
    return False
예제 #2
0
def try_use(player):
    chosen_item = inventory_menu(
        player,
        'Press the key next to an item to use it, x to examine, or any other to cancel.\n')
    if chosen_item is not None:
        actions.use(player, chosen_item.owner)
        return True
    return False
예제 #3
0
파일: vault.py 프로젝트: brewerdave/vault
def handle_input(player):
    ui.poll()

    if ui.key.vk == libtcodpy.KEY_ENTER and ui.key.lalt:
        libtcodpy.console_set_fullscreen(not libtcodpy.console_is_fullscreen())

    elif ui.key.vk == libtcodpy.KEY_ESCAPE:
        return 'exit'

    if player.game_state == 'playing':

        if ui.key.vk == libtcodpy.KEY_UP or chr(ui.key.c) == 'k':
            player_move_or_attack(player, 0, -1)

        elif ui.key.vk == libtcodpy.KEY_DOWN or chr(ui.key.c) == 'j':
            player_move_or_attack(player, 0, 1)

        elif ui.key.vk == libtcodpy.KEY_LEFT or chr(ui.key.c) == 'h':
            player_move_or_attack(player, -1, 0)

        elif ui.key.vk == libtcodpy.KEY_RIGHT or chr(ui.key.c) == 'l':
            player_move_or_attack(player, 1, 0)

        elif chr(ui.key.c) == 'u':
            player_move_or_attack(player, 1, -1)

        elif chr(ui.key.c) == 'y':
            player_move_or_attack(player, -1, -1)

        elif chr(ui.key.c) == 'n':
            player_move_or_attack(player, 1, 1)

        elif chr(ui.key.c) == 'b':
            player_move_or_attack(player, -1, 1)

        else:
            if chr(ui.key.c) == 'g':
                for entity in player.current_map.map_entities:
                    if entity.x_pos == player.x_pos and entity.y_pos == player.y_pos and entity.item:
                        actions.pick_up_item(player, entity)
                        break

            if chr(ui.key.c) == 'i':
                chosen_item = inventory_menu(player, 'Inventory')
                if chosen_item is not None:
                    actions.use(player, chosen_item.owner)

            return 'didnt-take-turn'
예제 #4
0
파일: prompt.py 프로젝트: AlexB138/game
def basePrompt(player, room):
    """
    Desc: Main game prompt.
    Called by: main game loop
    Notes:
    returns either a room or None. If returning None, all necessary actions are taken within the called function.
    """
    command = None
    while not command:
        commandFull = raw_input(player.showHP() + ">")
        parts = commandFull.lower().split(" ")
        command = parts[0]
        args = parts[1:]
    if command in ("1","2","3","4","enter"):
        if command in ("1","2","3","4"):
            command = int(command)
            return actions.enter(command, room, player)
        elif command == "enter":
            try:
                args = int(args)
                return actions.enter(args, room, player)
            except:
                print "That is not a valid door."
    elif command == "help":
        #need to extend this to look at other commands
        if len(args) == 0:
            actions.ghelp()
        else:
            actions.ghelp(args[0])
        return
    elif command in ("l", "look"):
        if len(args) == 0:
            actions.look(room)
        else:
            actions.examine(player, args[0])
        return
    elif command in ("quit", "exit"):
        actions.quit(player)
        return
    elif command in ("stat","stats","status"):
        actions.status(player)
        return
    elif command == "use":
        if len(args) == 0:
            print "That command requires a target.\n"
        else:
            actions.use(player, args[0])
        return
    elif command in ("i", "inv", "inven", "inventory"):
        actions.inventory(player)
        return
    elif command in ("e", "eq", "equip"):
        if len(args) == 0:
            actions.worn(player)
        else:
            actions.equipCommand(player, args[0])
        return
    elif command == "worn":
        actions.worn(player)
        return
    elif command in ("un", "une", "uneq", "unequip"):
        if len(args) == 0:
            print "That command requires a target.\n"
        else:
            actions.unequipCommand(player, args[0])
        return
    elif command == "get":
        if len(args) == 0:
            print "That command requires a target.\n"
        else:
            actions.get(player, room, args[0])
    elif command == "drop":
        if len(args) == 0:
            print "That command requires a target.\n"
        else:
            actions.drop(player, room, args[0])
    elif command in ("ex", "exam", "examine"):
        if len(args) == 0:
            print "That command requires a target.\n"
        else:
            actions.examine(player, args[0])
    elif command == "set":
        if len(args) == 0:
            actions.set(player)
        elif len(args) == 1:
            print "Set command requires a hotkey and a skill.\n"
        elif len(args) == 2:
            actions.set(player, args[0], args[1])
        else:
            actions.set(player, args[0], args[1], args[2])
    else:
        return
예제 #5
0
파일: skills.py 프로젝트: AlexB138/game
def use(player, item):
    if actions.check_inventory(player, item):
        player.ap -= 50
        actions.use(player, item)
        return "You use your {}".format(item)