#include "curses_input.h"

#include "constants.h"

curses_input::curses_input(cursor *new_curse):
        curse{new_curse} {}

game_command curses_input::get_command() {
        int tmp;

        switch (curse->getcmd()) {
        case 'h':
                return game_command::MOVE_WEAT;

        case 'j':
                return game_command::MOVE_SOUTH;

        case 'k':
                return game_command::MOVE_NORTH;

        case 'l':
                return game_command::MOVE_EAST;

        case 'y':
                return game_command::MOVE_NORTHWEST;

        case 'u':
                return game_command::MOVE_NORTHEAST;

        case 'b':
                return game_command::MOVE_SOUTHWEST;

        case 'n':
                return game_command::MOVE_SOUTHEAST;

        case 'a':
                tmp = APPLY_NORTH;
                break; // wait for another command

        case '<':
                return game_command::UP_STAIRS;

        case '>':
                return game_command::DOWN_STAIRS;

        case 'q':
                return GAME_COMMAND_TERMINATE;

        case 'f':
                return game_command::THE_WORLD;

        case 'd':
                return game_command::STAR_PLATINUM;

        case 'r':
                return GAME_RESTART;

        case 'e':
                return game_command::ENTER;

        case 'i':
                return TOGGLE_INVENTORY;

        case 't':
                tmp = THROW_NORTH;
                break;

        default:
                return GAME_COMMAND_PASS;
        }

        switch (curse->getcmd()) {
        case 'h':
                return static_cast<game_command>
                       (tmp + WEST);

        case 'j':
                return static_cast<game_command>
                       (tmp + SOUTH);

        case 'k':
                return static_cast<game_command>
                       (tmp + NORTH);

        case 'l':
                return static_cast<game_command>
                       (tmp + EAST);

        case 'y':
                return static_cast<game_command>
                       (tmp + NORTHWEST);

        case 'u':
                return static_cast<game_command>
                       (tmp + NORTHEAST);

        case 'b':
                return static_cast<game_command>
                       (tmp + SOUTHWEST);

        case 'n':
                return static_cast<game_command>
                       (tmp + SOUTHEAST);

        default:
                return GAME_COMMAND_PANIC;
        }

        return game_command::GAME_COMMAND_PANIC;
}
