From 70041c80b376f1aae987cd53f397c48082d297bc Mon Sep 17 00:00:00 2001 From: Antoine Fraboulet Date: Sun, 5 Nov 2006 13:27:49 +0000 Subject: [PATCH] - extra debug output command for board cross info --- utils/eliottxt.cpp | 19 +++++++++++++++++- utils/game_io.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++ utils/game_io.h | 4 ++++ 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/utils/eliottxt.cpp b/utils/eliottxt.cpp index edfc153..1de5ab0 100644 --- a/utils/eliottxt.cpp +++ b/utils/eliottxt.cpp @@ -188,8 +188,10 @@ void help_training() printf(" gj -- grille + jokers\n"); printf(" gm -- grille + valeur des cases\n"); printf(" gn -- grille + valeur des cases (variante)\n"); + printf(" gd -- grille + debug cross (debug only)\n"); printf(" l -- lettres non jouées\n"); printf(" p -- partie\n"); + printf(" pd -- partie (debug)\n"); printf(" P -- partie (format standard)\n"); printf(" r -- recherche\n"); printf(" s -- score\n"); @@ -292,6 +294,9 @@ void display_data(const Game &iGame, const wchar_t *delim, wchar_t **state) case L'\0': GameIO::printBoard(cout, iGame); break; + case L'd': + GameIO::printBoardDebug(cout, iGame); + break; case L'j': GameIO::printBoardJoker(cout, iGame); break; @@ -313,7 +318,17 @@ void display_data(const Game &iGame, const wchar_t *delim, wchar_t **state) GameIO::printNonPlayed(cout, iGame); break; case L'p': - iGame.save(cout,Game::FILE_FORMAT_ADVANCED); + switch (token[1]) + { + case '\0': + iGame.save(cout,Game::FILE_FORMAT_ADVANCED); + break; + case 'd': + GameIO::printGameDebug(cout, iGame); + break; + default: + printf("commande inconnue\n"); + } break; case L'P': iGame.save(cout,Game::FILE_FORMAT_STANDARD); @@ -419,7 +434,9 @@ void loop_training(Training &iGame) { int n = _wtoi(token); if (n <= 0) + { iGame.back(n == 0 ? 1 : -n); + } else { if (iGame.playResult(--n)) diff --git a/utils/game_io.cpp b/utils/game_io.cpp index 2e2dfd2..fd276f7 100644 --- a/utils/game_io.cpp +++ b/utils/game_io.cpp @@ -51,6 +51,32 @@ void GameIO::printBoard(ostream &out, const Game &iGame) } } +/* this mode is used for regression tests */ +void GameIO::printBoardDebug(ostream &out, const Game &iGame) +{ + int row, col; + + /* first printf row cell contents */ + for (row = BOARD_MIN; row <= BOARD_MAX; row++) + { + out << " " << (char)(row - BOARD_MIN + 'A') << "r "; + for (col = BOARD_MIN; col <= BOARD_MAX; col++) + { + out << iGame.getBoard().getCellContent_row(row, col); + } + out << endl; + } + out << " -" << endl; + for (row = BOARD_MIN; row <= BOARD_MAX; row++) + { + out << " " << (char)(row - BOARD_MIN + 'A') << "c "; + for (col = BOARD_MIN; col <= BOARD_MAX; col++) + { + out << iGame.getBoard().getCellContent_col(row, col); + } + out << endl; + } +} void GameIO::printBoardJoker(ostream &out, const Game &iGame) { @@ -221,3 +247,27 @@ void GameIO::printAllPoints(ostream &out, const Game &iGame) } } + +void GameIO::printGameDebug(ostream &out, const Game &iGame) +{ + out << "Game:: joueur en cours " << iGame.currPlayer() << " sur " << iGame.getNPlayers() << endl; + out << "Game:: mode " << iGame.getModeAsString() << endl; + out << "Game:: variante "; + switch (iGame.getVariant()) + { + case Game::kNONE: + out << "aucune" << endl; + break; + case Game::kJOKER: + out << "joker" << endl; + break; + default: + out << "inconnu" << endl; + break; + } + out << "Game:: rack size " << iGame.RACK_SIZE << endl; + out << "Game:: history --" << endl; + out << convertToMb(iGame.getHistory().toString()); + out << "--" << endl; + out << "" << endl; +} diff --git a/utils/game_io.h b/utils/game_io.h index c7db943..2d3db2e 100644 --- a/utils/game_io.h +++ b/utils/game_io.h @@ -41,9 +41,11 @@ class GameIO { public: static void printBoard(ostream &out, const Game &iGame); + static void printBoardDebug(ostream &out, const Game &iGame); static void printBoardJoker(ostream &out, const Game &iGame); static void printBoardMultipliers(ostream &out, const Game &iGame); static void printBoardMultipliers2(ostream &out, const Game &iGame); + static void printNonPlayed(ostream &out, const Game &iGame); static void printPlayedRack(ostream &out, const Game &iGame, int n); static void printAllRacks(ostream &out, const Game &iGame); @@ -51,6 +53,8 @@ public: static void printPoints(ostream &out, const Game &iGame); static void printAllPoints(ostream &out, const Game &iGame); + static void printGameDebug(ostream &out, const Game &iGame); + private: /// This class is a toolbox, and should not be instanciated GameIO();