2005-02-05 12:14:56 +01:00
|
|
|
/*****************************************************************************
|
2008-01-08 14:52:32 +01:00
|
|
|
* Eliot
|
|
|
|
* Copyright (C) 1999-2007 Antoine Fraboulet & Olivier Teulière
|
|
|
|
* 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
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _TRAINING_H_
|
|
|
|
#define _TRAINING_H_
|
|
|
|
|
2005-03-27 23:45:04 +02:00
|
|
|
#include <string>
|
|
|
|
|
2005-02-05 12:14:56 +01:00
|
|
|
#include "game.h"
|
2008-01-08 14:52:32 +01:00
|
|
|
#include "round.h"
|
2005-02-17 21:01:59 +01:00
|
|
|
#include "results.h"
|
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
|
|
|
|
{
|
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 kTRAINING; }
|
2005-02-09 23:33:56 +01:00
|
|
|
virtual string getModeAsString() const { return "Training"; }
|
2005-02-05 12:14:56 +01:00
|
|
|
|
|
|
|
/*************************
|
|
|
|
* Game handling
|
|
|
|
*************************/
|
|
|
|
virtual int start();
|
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-01-08 14:52:32 +01:00
|
|
|
const Results& getResults() const { return m_results; };
|
|
|
|
int playResult(unsigned int);
|
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...
|
|
|
|
*/
|
|
|
|
void setRackRandom(bool, set_rack_mode);
|
|
|
|
|
2006-01-22 13:23:52 +01:00
|
|
|
int setRackManual(bool iCheck, const wstring &iLetters);
|
2008-11-22 14:09:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Deprecated: use setRackRandom() or setRackManual() instead.
|
|
|
|
*/
|
2006-01-22 13:23:52 +01:00
|
|
|
int setRack(set_rack_mode iMode, bool iCheck, const wstring &iLetters);
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2005-03-03 23:14:41 +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
|
2005-03-03 23:14:41 +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
|
|
|
/*************************
|
|
|
|
* Functions to access the current search results
|
|
|
|
* The int parameter should be 0 <= int < getNResults
|
|
|
|
*************************/
|
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
/// Place a temporary word on the board for preview purposes
|
|
|
|
void testPlay(unsigned int);
|
|
|
|
/// Remove the temporary word
|
2005-03-27 23:45:04 +02:00
|
|
|
void removeTestPlay();
|
2005-12-26 19:07:26 +01:00
|
|
|
/// Get the temporary word
|
2006-01-22 13:23:52 +01:00
|
|
|
wstring getTestPlayWord() const;
|
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
|
2005-02-24 09:06:24 +01:00
|
|
|
Training(const Dictionary &iDic);
|
|
|
|
|
2008-11-22 14:09:28 +01:00
|
|
|
/// Record a player move
|
|
|
|
void recordPlayerMove(const Move &iMove, unsigned int p);
|
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
void endTurn();
|
|
|
|
|
|
|
|
/// Search results, with all the possible rounds
|
2005-02-17 21:01:59 +01:00
|
|
|
Results m_results;
|
2008-01-08 14:52:32 +01:00
|
|
|
|
|
|
|
/// Round corresponding to the last test play (if any)
|
|
|
|
Round m_testRound;
|
2005-02-05 12:14:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _TRAINING_H_ */
|
2006-01-01 20:49:35 +01:00
|
|
|
|