00001 /* Eliot */ 00002 /* Copyright (C) 1999 Antoine Fraboulet */ 00003 /* */ 00004 /* This file is part of Eliot. */ 00005 /* */ 00006 /* Eliot is free software; you can redistribute it and/or modify */ 00007 /* it under the terms of the GNU General Public License as published by */ 00008 /* the Free Software Foundation; either version 2 of the License, or */ 00009 /* (at your option) any later version. */ 00010 /* */ 00011 /* Eliot is distributed in the hope that it will be useful, */ 00012 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 00013 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 00014 /* GNU General Public License for more details. */ 00015 /* */ 00016 /* You should have received a copy of the GNU General Public License */ 00017 /* along with this program; if not, write to the Free Software */ 00018 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 00019 00020 /** 00021 * \file history.h 00022 * \brief Game history system 00023 * \author Antoine Fraboulet 00024 * \date 2005 00025 */ 00026 00027 #ifndef _HISTORY_H 00028 #define _HISTORY_H 00029 00030 #include <vector> 00031 #include "pldrack.h" 00032 #include "round.h" 00033 #include "turn.h" 00034 00035 /** 00036 * History stores all the turns that have been played 00037 * This class is used many times in the game 00038 * - one for the complete game 00039 * - one for each of the players 00040 * 00041 * A History is never void (getSize() can be used as the is the current turn 00042 * number for the complete game history). 00043 * 00044 * History starts at zero. 00045 * 00046 * The top of the history is an empty 00047 * Turn until it has been filled and game is up to a new round. 00048 * 00049 * getCurrentRack() can/should be used to store the current played rack. 00050 * setCurrentRack must be called whenever the current played rack is 00051 * modified. 00052 * 00053 * History owns the turns that it stores. Do not delete a turn referenced by History 00054 */ 00055 00056 class History 00057 { 00058 public: 00059 History(); 00060 virtual ~History(); 00061 00062 /// get the size of the history 00063 int getSize() const; 00064 00065 /// Get the (possibly incomplete) rack 00066 const PlayedRack& getCurrentRack() const; 00067 00068 /// Set the current rack 00069 void setCurrentRack(const PlayedRack &iPld); 00070 00071 /// Get the previous turn 00072 const Turn& getPreviousTurn() const; 00073 00074 /// Get turn 'n' 00075 const Turn& getTurn(unsigned int) const; 00076 00077 /// Update the "history" with the given round and complete the turn. 00078 /// A new turn is created with the remaining letters in the rack 00079 void playRound(int player, int turn, const Round& round); 00080 00081 /// Remove last turn 00082 void removeLastTurn(); 00083 00084 /// String handling 00085 string toString() const; 00086 00087 private: 00088 vector < Turn* > m_history; 00089 }; 00090 00091 #endif 00092 00093 /// Local Variables: 00094 /// mode: c++ 00095 /// mode: hs-minor 00096 /// c-basic-offset: 4 00097 /// indent-tabs-mode: nil 00098 /// End: