eliot/game/freegame.h
Olivier Teulière 57c1fcaf8e Added an ASSERT macro, which aborts execution if the condition given as a
parameter is not verified. This simplifies te code in several places.
The old PDEBUG macro has been removed.
2005-03-27 21:45:04 +00:00

68 lines
2.3 KiB
C++

/*****************************************************************************
* Copyright (C) 2005 Eliot
* Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
*
* $Id: freegame.h,v 1.5 2005/03/27 21:45:04 ipkiss Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*****************************************************************************/
#ifndef _FREEGAME_H_
#define _FREEGAME_H_
#include "game.h"
#include "tile.h"
using std::string;
using std::vector;
/**
* This class handles the logic specific to a "free" game.
*
* The algorithm is simple: players play at their turn, and they can either
* play a word or change letters (changing letters implies passing its turn).
*
* When a player has no more letters (end of the game), the points of the
* letters left in the racks of his opponents are added to his score, and
* removed from the score of the latters.
*/
class FreeGame: public Game
{
friend class GameFactory;
public:
virtual GameMode getMode() const { return kFREEGAME; }
virtual string getModeAsString() const { return "Free game"; }
/*************************
* Game handling
*************************/
virtual int start();
virtual int setRackRandom(int, bool, set_rack_mode);
virtual int play(const string &iCoord, const string &iWord);
virtual int endTurn();
int pass(const string &iToChange, int n);
private:
// Private constructor and destructor to force using the GameFactory class
FreeGame(const Dictionary &iDic);
virtual ~FreeGame();
void freegameAI(int n);
void end();
int helperPass(const vector<Tile> &iToChange, int n);
};
#endif /* _FREEGAME_H_ */