Files
cc3k/src/file_input.cc
Peisong Xiao 74de68cf0d added: list of arguments
edit: future framework of main
2024-07-05 12:11:09 -04:00

32 lines
986 B
C++

#include "file_input.h"
#include <utility>
#include <string>
file_input::file_input(std::ifstream &&ifs):
in{std::move(ifs)} {}
game_command file_input::get_command() {
std::string cmd;
in >> cmd;
game_command tmp;
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")
return (game_command)((tmp = get_direction(cmd)) ==
game_command_panic
? tmp : tmp - move_north + apply_north);
else if (cmd == "a")
return (game_command)((tmp = get_direction(cmd)) ==
game_command_panic
? tmp : tmp - move_north + attack_north);
else // is just moving
return get_direction(cmd);
return game_command_pass;
}