#include "file_input.h" #include #include #include "../constants.h" file_input::file_input(std::ifstream &&ifs): in{std::move(ifs)} {} game_command file_input::get_command() { std::string cmd; in >> cmd; 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" || cmd == "t") { auto cmdtmp = cmd; in >> cmd; if (in.eof()) return game_command_panic; auto tmp = get_direction(cmd); if (cmdtmp == "u") return static_cast(tmp + apply_north); else if (cmdtmp == "a") return static_cast(tmp + attack_north); else return static_cast(tmp + throw_north); } else if (cmd == "yes") { return game_command::enter; } else if (cmd == "i") { return toggle_inventory; } else { auto tmp = get_direction(cmd); if (tmp != game_command_panic) return static_cast (tmp + move_north); } return game_command_pass; }