eliot/game/topping.h

97 lines
2.7 KiB
C
Raw Normal View History

2012-12-25 17:30:03 +01:00
/*****************************************************************************
* Eliot
* Copyright (C) 2012 Olivier Teulière
* Authors: Olivier Teulière <ipkiss @@ gmail.com>
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
#ifndef TOPPING_H_
#define TOPPING_H_
#include <string>
#include "game.h"
#include "move.h"
2012-12-25 17:30:03 +01:00
#include "logging.h"
class Player;
using std::string;
using std::wstring;
/**
* This class handles the logic specific to a topping game.
* In this mode, the player plays against time, to find the top move
* (or one of them if there are several moves with the same score)
* This mode is mostly interesting for (good) duplicate players.
*/
class Topping: public Game
{
DEFINE_LOGGER();
friend class GameFactory;
public:
/*************************
* Game handling
*************************/
virtual void start();
virtual bool isFinished() const;
/// See description of Game::play()
virtual int play(const wstring &iCoord, const wstring &iWord);
/**
* Override the default behaviour of addPlayer(), because in topping
* mode we only want a human player
*/
virtual void addPlayer(Player *iPlayer);
/**
* Word played by the player, with the corresponding elapsed time, in seconds
*/
void tryWord(const wstring &iWord, const wstring &iCoord, int iElapsed);
/**
* Return all the moves tried by the player (including the invalid ones).
* The moves are returned in chronological order.
*/
vector<Move> getTriedMoves() const;
2012-12-25 17:30:03 +01:00
private:
/// Private constructor and destructor to force using the GameFactory class
Topping(const GameParams &iParams, const Game *iMasterGame);
2012-12-25 17:30:03 +01:00
/// Record a player move
void recordPlayerMove(const Move &iMove, Player &ioPlayer);
void endTurn();
/// Finish the game
void endGame();
/**
* Return the score of the top move.
* If no move is possible at all, return -1.
*/
int getTopScore() const;
2012-12-25 17:30:03 +01:00
};
#endif