freegame.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (C) 2005 Eliot
00003  * Authors: Olivier Teuliere  <ipkiss@via.ecp.fr>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  *****************************************************************************/
00019 
00020 #ifndef _FREEGAME_H_
00021 #define _FREEGAME_H_
00022 
00023 #include "game.h"
00024 #include "tile.h"
00025 
00026 using std::string;
00027 using std::vector;
00028 
00029 
00030 /**
00031  * This class handles the logic specific to a "free" game.
00032  *
00033  * The algorithm is simple: players play at their turn, and they can either
00034  * play a word or change letters (changing letters implies passing its turn).
00035  *
00036  * When a player has no more letters (end of the game), the points of the
00037  * letters left in the racks of his opponents are added to his score, and
00038  * removed from the score of the latters.
00039  */
00040 class FreeGame: public Game
00041 {
00042     friend class GameFactory;
00043 public:
00044     virtual GameMode getMode() const { return kFREEGAME; }
00045     virtual string getModeAsString() const { return "Free game"; }
00046 
00047     /*************************
00048      * Game handling
00049      *************************/
00050     virtual int start();
00051     virtual int setRackRandom(int, bool, set_rack_mode);
00052     virtual int play(const string &iCoord, const string &iWord);
00053     virtual int endTurn();
00054     int pass(const string &iToChange, int n);
00055 
00056 private:
00057     // Private constructor and destructor to force using the GameFactory class
00058     FreeGame(const Dictionary &iDic);
00059     virtual ~FreeGame();
00060 
00061     void freegameAI(int n);
00062     void end();
00063     int helperPass(const vector<Tile> &iToChange, int n);
00064 };
00065 
00066 #endif /* _FREEGAME_H_ */
00067 
00068 /// Local Variables:
00069 /// mode: c++
00070 /// mode: hs-minor
00071 /// c-basic-offset: 4
00072 /// indent-tabs-mode: nil
00073 /// End:

Generated on Thu Dec 29 02:01:14 2005 for Eliot by  doxygen 1.4.5