2005-02-05 12:14:56 +01:00
|
|
|
/*****************************************************************************
|
2008-01-08 14:52:32 +01:00
|
|
|
* Eliot
|
2012-10-07 16:25:41 +02:00
|
|
|
* Copyright (C) 1999-2012 Antoine Fraboulet & Olivier Teulière
|
2008-01-08 14:52:32 +01:00
|
|
|
* Authors: Antoine Fraboulet <antoine.fraboulet @@ free.fr>
|
|
|
|
* Olivier Teulière <ipkiss @@ gmail.com>
|
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
|
2005-10-23 16:53:42 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2005-02-05 12:14:56 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-11-29 17:01:31 +01:00
|
|
|
#ifndef TRAINING_H_
|
|
|
|
#define TRAINING_H_
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2005-03-27 23:45:04 +02:00
|
|
|
#include <string>
|
|
|
|
|
2005-02-05 12:14:56 +01:00
|
|
|
#include "game.h"
|
2005-02-17 21:01:59 +01:00
|
|
|
#include "results.h"
|
2011-01-30 00:47:20 +01:00
|
|
|
#include "logging.h"
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2008-11-23 09:18:03 +01:00
|
|
|
class Player;
|
|
|
|
|
2005-02-05 12:14:56 +01:00
|
|
|
using std::string;
|
2006-01-22 13:23:52 +01:00
|
|
|
using std::wstring;
|
2005-02-05 12:14:56 +01:00
|
|
|
|
|
|
|
|
2005-03-27 19:30:48 +02:00
|
|
|
/**
|
|
|
|
* This class handles the logic specific to a training game.
|
|
|
|
* As its name indicates, it is not a game in the literal meaning of the word,
|
|
|
|
* in particular because the rack can be set at will.
|
2008-01-08 14:52:32 +01:00
|
|
|
*
|
2005-03-27 19:30:48 +02:00
|
|
|
* Note: No player should be added to this game, a human player is added
|
|
|
|
* automatically (in the start() method)
|
|
|
|
*/
|
2005-02-05 12:14:56 +01:00
|
|
|
class Training: public Game
|
|
|
|
{
|
2011-01-30 00:47:20 +01:00
|
|
|
DEFINE_LOGGER();
|
2005-02-24 09:06:24 +01:00
|
|
|
friend class GameFactory;
|
2005-02-05 12:14:56 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
/*************************
|
|
|
|
* Game handling
|
|
|
|
*************************/
|
2008-11-23 18:04:40 +01:00
|
|
|
virtual void start();
|
2008-01-08 14:52:32 +01:00
|
|
|
|
2011-01-30 01:23:45 +01:00
|
|
|
virtual bool isFinished() const;
|
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
/// See description of Game::play()
|
2006-01-22 13:23:52 +01:00
|
|
|
virtual int play(const wstring &iCoord, const wstring &iWord);
|
2008-01-08 14:52:32 +01:00
|
|
|
|
2005-02-17 21:01:59 +01:00
|
|
|
void search();
|
2008-11-30 21:51:42 +01:00
|
|
|
const Results& getResults() const { return m_results; }
|
|
|
|
int playResult(unsigned int iResultIndex);
|
2005-12-26 23:53:26 +01:00
|
|
|
|
2008-11-22 14:09:28 +01:00
|
|
|
/**
|
|
|
|
* Complete (or reset) the rack randomly.
|
|
|
|
* @exception EndGameException if it is impossible to complete the rack
|
|
|
|
* for some reason...
|
|
|
|
*/
|
2008-11-30 21:51:42 +01:00
|
|
|
void setRackRandom(bool iCheck, set_rack_mode iRackMode);
|
2008-11-22 14:09:28 +01:00
|
|
|
|
2009-01-24 11:28:20 +01:00
|
|
|
/**
|
|
|
|
* Set the rack with the given letters
|
|
|
|
* @exception EndGameException if the game is over
|
|
|
|
* @exception GameException if any other error occurs
|
|
|
|
*/
|
|
|
|
void setRackManual(bool iCheck, const wstring &iLetters);
|
2008-11-22 14:09:28 +01:00
|
|
|
|
2012-01-12 17:43:57 +01:00
|
|
|
/**
|
2008-01-28 20:17:33 +01:00
|
|
|
* Override the default behaviour of addPlayer(), because in training
|
2008-01-08 14:52:32 +01:00
|
|
|
* mode we only want a human player
|
2012-01-12 17:43:57 +01:00
|
|
|
*/
|
2008-01-28 20:17:33 +01:00
|
|
|
virtual void addPlayer(Player *iPlayer);
|
2005-03-03 23:14:41 +01:00
|
|
|
|
2005-02-17 21:01:59 +01:00
|
|
|
private:
|
2008-01-08 14:52:32 +01:00
|
|
|
/// Private constructor and destructor to force using the GameFactory class
|
2012-12-30 16:14:13 +01:00
|
|
|
Training(const GameParams &iParams, const Game *iMasterGame);
|
2005-02-24 09:06:24 +01:00
|
|
|
|
2008-11-22 14:09:28 +01:00
|
|
|
/// Record a player move
|
2008-11-23 09:18:03 +01:00
|
|
|
void recordPlayerMove(const Move &iMove, Player &ioPlayer);
|
2008-11-22 14:09:28 +01:00
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
void endTurn();
|
|
|
|
|
2009-01-22 19:30:22 +01:00
|
|
|
/// Search results, with all the possible rounds up to a predefined limit
|
|
|
|
LimitResults m_results;
|
2005-02-05 12:14:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _TRAINING_H_ */
|
2006-01-01 20:49:35 +01:00
|
|
|
|