finished the bulk of game

This commit is contained in:
2024-07-14 21:32:41 -04:00
parent b3475b7530
commit af8bc4112c
110 changed files with 1876 additions and 1481 deletions

View File

@ -0,0 +1,46 @@
#include "console_input.h"
#include <utility>
#include <string>
#include "../constants.h"
console_input::console_input(std::istream &cin):
in{cin} {}
game_command console_input::get_command() {
std::string cmd;
in >> cmd;
game_command tmp;
if (in.eof())
return game_command_terminate;
if (cmd == "q")
return game_command_terminate;
else if (cmd == "f")
return the_world;
else if (cmd == "r")
return game_restart;
else if (cmd == "u" || cmd == "a") {
bool use = cmd == "u";
in >> cmd;
if (in.eof())
return game_command_panic;
return (game_command)((tmp = get_direction(cmd)) ==
game_command_panic
? tmp : tmp - move_north +
(use ? apply_north : attack_north));
} else if (cmd == "yes") {
return game_command::enter;
} else {
auto tmp = get_direction(cmd);
if (tmp != game_command_panic)
return tmp;
}
return game_command_pass;
}