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