int PlayGame(void* p = NULL) { bool isFirstTurn = true; std::string current_line; std::string map_data; while (true) { int c = std::cin.get(); if(c < 0) break; current_line += (char)(unsigned char)c; if (c == '\n') { if (current_line.length() >= 2 && current_line.substr(0, 2) == "go") { Game game; game.ParseGameState(map_data); #ifdef GAMEDEBUG if(isFirstTurn) Viewer_pushInitialGame(new Game(game)); else Viewer_pushGameState(new GameState(game.state)); #endif map_data = ""; DoTurn(game); game.FinishTurn(); isFirstTurn = false; } else { map_data += current_line; } current_line = ""; } } return 0; }
int main(int argc, char *argv[]) { std::string current_line; std::string map_data; while (true) { int c = std::cin.get(); current_line += (char)c; if (c == '\n') { if (current_line.length() >= 2 && current_line.substr(0, 2) == "go") { Game game; game.ParseGameState(map_data); map_data = ""; DoTurn(game); game.FinishTurn(); } else { map_data += current_line; } current_line = ""; } } return 0; }