added: input and its subclasses

This commit is contained in:
2024-07-04 22:47:25 -04:00
parent c67dbcc62a
commit f5b5f180a0
9 changed files with 245 additions and 18 deletions

75
src/curses_input.cc Normal file
View File

@ -0,0 +1,75 @@
#include "curses_input.h"
curses_input::curses_input(const std::unique_ptr<cursor> &new_curse):
curse{new_curse} {}
game_command curses_input::get_command() {
switch (curse->getcmd()) {
case 'h':
return game_command::move_west;
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':
break; // wait for another command
case '<':
return game_command::up_stairs;
case '>':
return game_command::down_stairs;
default:
return game_command_pass;
}
switch (curse->getcmd()) {
case 'h':
return game_command::apply_west;
case 'j':
return game_command::apply_south;
case 'k':
return game_command::apply_north;
case 'l':
return game_command::apply_east;
case 'y':
return game_command::apply_northwest;
case 'u':
return game_command::apply_northeast;
case 'b':
return game_command::apply_southwest;
case 'n':
return game_command::apply_southeast;
default:
return game_command::apply_panic;
}
return game_command::game_command_panic;
}