diff --git a/ttt_interface/ttt.cpp b/ttt_interface/ttt.cpp index 9a82d31d89c4e16d8ef94c0251dbb4c7830d6b28..9585fa1f0418597fe679d4095edc14404ac61efa 100644 --- a/ttt_interface/ttt.cpp +++ b/ttt_interface/ttt.cpp @@ -193,7 +193,7 @@ string makeMove(GAME_CODE theGameCode, PLAYER_CODE thePlayerCode, SQUARE theSide } int getRows(GAME_CODE theGameCode) { - return strToInt(parseGameStatus(theGameCode)["rows"]); + return strToInt(parseGameStatus(theGameCode)["rows"]); } int getCols(GAME_CODE theGameCode) { @@ -204,6 +204,12 @@ string getBoard(GAME_CODE theGameCode) { return parseGameStatus(theGameCode)["board"]; } +SQUARE getBoardSquare(string board, int theRow, int theCol) { + int cols = board.find("\\n"); + return board[theRow*(cols+2)+theCol]; +} + + SQUARE getHasWon(GAME_CODE theGameCode) { return parseGameStatus(theGameCode)["hasWon"][0]; } diff --git a/ttt_interface/ttt.h b/ttt_interface/ttt.h index c326b708feb60e03f24462e755533e8403801416..562e81c153e34049063c44d4ba883dbbaf784407 100644 --- a/ttt_interface/ttt.h +++ b/ttt_interface/ttt.h @@ -97,10 +97,18 @@ SQUARE getToMove(GAME_CODE theGameCode); /** * @param theGameCode The code of the Game in question. - * @return A tstring representing the current board in the game with the given game code. + * @return A string representing the current board in the game with the given game code. */ string getBoard(GAME_CODE theGameCode); +/** + * @param board a game board produced by the function getBoard(GAME_CODE theGameCode). + * @param theRow a row on the game board. + * @param theCol a colum on the game board. + * @return The square at row [theRow] and column [theCol] on the given board. + */ +SQUARE getBoardSquare(string board, int theRow, int theCol); + /** * @param theGameCode The code of the Game in question. * @return Who has won the game, or '-' if no one has won yet.