2005-02-05 12:14:56 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* Copyright (C) 2005 Eliot
|
|
|
|
* Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
|
|
|
|
*
|
2005-03-29 08:56:06 +02:00
|
|
|
* $Id: freegame.h,v 1.6 2005/03/29 06:56:06 afrab Exp $
|
2005-02-05 12:14:56 +01:00
|
|
|
*
|
|
|
|
* 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"
|
2005-03-27 23:45:04 +02:00
|
|
|
#include "tile.h"
|
2005-02-05 12:14:56 +01:00
|
|
|
|
|
|
|
using std::string;
|
2005-03-27 23:45:04 +02:00
|
|
|
using std::vector;
|
2005-02-05 12:14:56 +01:00
|
|
|
|
|
|
|
|
2005-03-27 19:30:48 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2005-02-05 12:14:56 +01:00
|
|
|
class FreeGame: public Game
|
|
|
|
{
|
2005-02-24 09:06:24 +01:00
|
|
|
friend class GameFactory;
|
2005-02-05 12:14:56 +01:00
|
|
|
public:
|
|
|
|
virtual GameMode getMode() const { return kFREEGAME; }
|
2005-02-09 23:33:56 +01:00
|
|
|
virtual string getModeAsString() const { return "Free game"; }
|
2005-02-05 12:14:56 +01:00
|
|
|
|
|
|
|
/*************************
|
|
|
|
* 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();
|
2005-03-29 08:56:06 +02:00
|
|
|
virtual string getCurrentRack(int);
|
2005-02-05 12:14:56 +01:00
|
|
|
int pass(const string &iToChange, int n);
|
|
|
|
|
|
|
|
private:
|
2005-02-24 09:06:24 +01:00
|
|
|
// Private constructor and destructor to force using the GameFactory class
|
|
|
|
FreeGame(const Dictionary &iDic);
|
|
|
|
virtual ~FreeGame();
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2005-03-27 23:45:04 +02:00
|
|
|
void freegameAI(int n);
|
2005-02-05 12:14:56 +01:00
|
|
|
void end();
|
2005-03-27 23:45:04 +02:00
|
|
|
int helperPass(const vector<Tile> &iToChange, int n);
|
2005-02-05 12:14:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _FREEGAME_H_ */
|