00001 /***************************************************************************** 00002 * Copyright (C) 1999-2005 Eliot 00003 * Authors: Antoine Fraboulet <antoine.fraboulet@free.fr> 00004 * Olivier Teuliere <ipkiss@via.ecp.fr> 00005 * 00006 * This program 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 * This program 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 #ifndef _TRAINING_H_ 00022 #define _TRAINING_H_ 00023 00024 #include <string> 00025 00026 #include "game.h" 00027 #include "results.h" 00028 00029 using std::string; 00030 00031 00032 /** 00033 * This class handles the logic specific to a training game. 00034 * As its name indicates, it is not a game in the literal meaning of the word, 00035 * in particular because the rack can be set at will. 00036 * Note: No player should be added to this game, a human player is added 00037 * automatically (in the start() method) 00038 */ 00039 class Training: public Game 00040 { 00041 friend class GameFactory; 00042 public: 00043 virtual GameMode getMode() const { return kTRAINING; } 00044 virtual string getModeAsString() const { return "Training"; } 00045 00046 /************************* 00047 * Game handling 00048 *************************/ 00049 virtual int start(); 00050 virtual int play(const string &iCoord, const string &iWord); 00051 virtual int endTurn(); 00052 void search(); 00053 int playResult(int); 00054 00055 virtual int setRackRandom(int, bool, set_rack_mode); 00056 int setRackManual(bool iCheck, const string &iLetters); 00057 int setRack(set_rack_mode iMode, bool iCheck, const string &iLetters); 00058 00059 /************************* 00060 * Override the default behaviour of these methods, because in training 00061 * we only want a human player 00062 *************************/ 00063 virtual void addHumanPlayer(); 00064 virtual void addAIPlayer(); 00065 00066 /************************* 00067 * Functions to access the current search results 00068 * The int parameter should be 0 <= int < getNResults 00069 *************************/ 00070 const Results& getResults() const { return m_results; }; 00071 00072 /// Place a temporary word on the board for preview purpose 00073 void testPlay(int); 00074 /// Remove the temporary word(s) 00075 void removeTestPlay(); 00076 /// Get the temporary word 00077 string getTestPlayWord() const; 00078 00079 private: 00080 // Private constructor and destructor to force using the GameFactory class 00081 Training(const Dictionary &iDic); 00082 virtual ~Training(); 00083 00084 // Search results, with all the possible rounds 00085 Round m_testRound; 00086 Results m_results; 00087 }; 00088 00089 #endif /* _TRAINING_H_ */ 00090 00091 /// Local Variables: 00092 /// mode: c++ 00093 /// mode: hs-minor 00094 /// c-basic-offset: 4 00095 /// indent-tabs-mode: nil 00096 /// End: