2005-02-05 12:14:56 +01:00
|
|
|
/*****************************************************************************
|
2008-01-08 14:52:32 +01:00
|
|
|
* Eliot
|
|
|
|
* Copyright (C) 2004-2007 Olivier Teulière & Antoine Fraboulet
|
|
|
|
* Authors: Olivier Teulière <ipkiss @@ gmail.com>
|
|
|
|
* Antoine Fraboulet <antoine.fraboulet @@ free.fr>
|
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
|
|
|
*****************************************************************************/
|
2004-08-07 20:25:03 +02:00
|
|
|
|
|
|
|
#ifndef _PLAYER_H_
|
|
|
|
#define _PLAYER_H_
|
|
|
|
|
2005-02-05 12:14:56 +01:00
|
|
|
#include <vector>
|
2005-12-26 23:52:38 +01:00
|
|
|
#include <string>
|
2005-11-06 00:57:41 +01:00
|
|
|
#include "pldrack.h"
|
2005-12-26 22:18:21 +01:00
|
|
|
#include "history.h"
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2008-01-19 20:33:08 +01:00
|
|
|
using std::wstring;
|
|
|
|
|
2005-11-06 15:53:15 +01:00
|
|
|
class Turn;
|
2008-11-22 14:09:28 +01:00
|
|
|
class Rack;
|
2005-02-05 12:14:56 +01:00
|
|
|
|
|
|
|
|
2005-03-27 19:30:48 +02:00
|
|
|
/**
|
2005-11-06 01:38:16 +01:00
|
|
|
* This class is the parent class for all the players involved in a game.
|
2005-11-06 02:09:41 +01:00
|
|
|
* It defines the common methods to update the rack, score, etc...
|
2005-03-27 19:30:48 +02:00
|
|
|
*/
|
2005-02-05 12:14:56 +01:00
|
|
|
class Player
|
|
|
|
{
|
|
|
|
public:
|
2008-01-28 20:17:33 +01:00
|
|
|
explicit Player();
|
2008-01-08 14:52:32 +01:00
|
|
|
virtual ~Player() {}
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2005-02-17 21:01:59 +01:00
|
|
|
// Pseudo RTTI
|
|
|
|
virtual bool isHuman() const = 0;
|
|
|
|
|
2008-01-19 20:33:08 +01:00
|
|
|
/// Get the name of the player
|
|
|
|
const wstring & getName() const { return m_name; }
|
|
|
|
/// Set the name of the player
|
|
|
|
void setName(const wstring &iName) { m_name = iName; }
|
|
|
|
|
2008-11-23 09:18:03 +01:00
|
|
|
/// ID handling
|
|
|
|
unsigned int getId() const { return m_id; }
|
2008-01-28 20:17:33 +01:00
|
|
|
void setId(unsigned int iId) { m_id = iId; }
|
|
|
|
|
2005-02-05 12:14:56 +01:00
|
|
|
/**************************
|
|
|
|
* General getters
|
|
|
|
**************************/
|
2008-01-19 20:33:08 +01:00
|
|
|
/// Get the (possibly incomplete) rack of the player
|
2005-02-09 23:33:56 +01:00
|
|
|
const PlayedRack & getCurrentRack() const;
|
2008-01-19 20:33:08 +01:00
|
|
|
/// Get the previous rack
|
2005-02-05 12:14:56 +01:00
|
|
|
const PlayedRack & getLastRack() const;
|
2008-01-08 14:52:32 +01:00
|
|
|
/// Get the previous move (corresponding to the previous rack...)
|
|
|
|
const Move & getLastMove() const;
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2005-02-09 23:33:56 +01:00
|
|
|
void setCurrentRack(const PlayedRack &iPld);
|
|
|
|
|
2005-12-26 22:18:21 +01:00
|
|
|
const History& getHistory() const { return m_history; }
|
2008-11-23 09:18:03 +01:00
|
|
|
History & accessHistory() { return m_history; }
|
2008-01-19 20:33:08 +01:00
|
|
|
|
2005-12-27 02:06:54 +01:00
|
|
|
/// Remove last turn
|
|
|
|
void removeLastTurn();
|
2005-12-26 22:18:21 +01:00
|
|
|
|
2005-02-05 12:14:56 +01:00
|
|
|
/**************************
|
2008-07-03 22:14:46 +02:00
|
|
|
* Accessors for the score of the player
|
2005-02-05 12:14:56 +01:00
|
|
|
**************************/
|
2005-02-17 21:01:59 +01:00
|
|
|
// Add (or remove, if iPoints is negative) points to the score
|
|
|
|
// of the player
|
2005-02-05 12:14:56 +01:00
|
|
|
void addPoints(int iPoints) { m_score += iPoints; }
|
2005-02-17 21:01:59 +01:00
|
|
|
int getPoints() const { return m_score; }
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2006-01-22 13:23:52 +01:00
|
|
|
wstring toString() const;
|
2005-12-26 23:52:38 +01:00
|
|
|
|
2005-02-05 12:14:56 +01:00
|
|
|
private:
|
2005-11-06 18:13:45 +01:00
|
|
|
/// ID of the player
|
2008-01-08 14:52:32 +01:00
|
|
|
unsigned int m_id;
|
2005-11-06 18:13:45 +01:00
|
|
|
|
2005-11-06 00:57:41 +01:00
|
|
|
/// Score of the player
|
2005-02-05 12:14:56 +01:00
|
|
|
int m_score;
|
|
|
|
|
2008-01-19 20:33:08 +01:00
|
|
|
/// Name of the player
|
|
|
|
wstring m_name;
|
|
|
|
|
2005-11-06 00:57:41 +01:00
|
|
|
/// History of the racks and rounds for the player
|
2005-12-26 22:18:21 +01:00
|
|
|
History m_history;
|
2005-02-17 21:01:59 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-03-27 19:30:48 +02:00
|
|
|
/**
|
|
|
|
* Human player.
|
|
|
|
*/
|
2005-02-17 21:01:59 +01:00
|
|
|
class HumanPlayer: public Player
|
|
|
|
{
|
|
|
|
public:
|
2008-01-28 20:17:33 +01:00
|
|
|
HumanPlayer(): Player() {}
|
2005-02-17 21:01:59 +01:00
|
|
|
virtual ~HumanPlayer() {}
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2005-02-17 21:01:59 +01:00
|
|
|
// Pseudo RTTI
|
|
|
|
virtual bool isHuman() const { return true; }
|
2005-02-05 12:14:56 +01:00
|
|
|
};
|
2004-08-07 20:25:03 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|