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) 2004-2012 Olivier Teulière & Antoine Fraboulet
|
2008-01-08 13:52:32 +00:00
|
|
|
* Authors: Olivier Teulière <ipkiss @@ gmail.com>
|
|
|
|
* Antoine Fraboulet <antoine.fraboulet @@ free.fr>
|
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
|
|
|
*****************************************************************************/
|
2004-08-07 18:25:03 +00:00
|
|
|
|
2009-11-29 16:01:31 +00:00
|
|
|
#ifndef PLAYER_H_
|
|
|
|
#define PLAYER_H_
|
2004-08-07 18:25:03 +00:00
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
#include <vector>
|
2005-12-26 22:52:38 +00:00
|
|
|
#include <string>
|
2005-11-05 23:57:41 +00:00
|
|
|
#include "pldrack.h"
|
2005-12-26 21:18:21 +00:00
|
|
|
#include "history.h"
|
2012-02-18 22:26:52 +01:00
|
|
|
#include "logging.h"
|
2005-02-05 11:14:56 +00:00
|
|
|
|
2008-01-19 19:33:08 +00:00
|
|
|
using std::wstring;
|
|
|
|
|
2012-10-06 01:57:39 +02:00
|
|
|
class TurnData;
|
2008-11-22 13:09:28 +00:00
|
|
|
class Rack;
|
2005-02-05 11:14:56 +00:00
|
|
|
|
|
|
|
|
2005-03-27 17:30:48 +00:00
|
|
|
/**
|
2005-11-06 00:38:16 +00:00
|
|
|
* This class is the parent class for all the players involved in a game.
|
2005-11-06 01:09:41 +00:00
|
|
|
* It defines the common methods to update the rack, score, etc...
|
2005-03-27 17:30:48 +00:00
|
|
|
*/
|
2005-02-05 11:14:56 +00:00
|
|
|
class Player
|
|
|
|
{
|
2012-02-18 22:26:52 +01:00
|
|
|
DEFINE_LOGGER();
|
2005-02-05 11:14:56 +00:00
|
|
|
public:
|
2008-01-28 19:17:33 +00:00
|
|
|
explicit Player();
|
2008-01-08 13:52:32 +00:00
|
|
|
virtual ~Player() {}
|
2005-02-05 11:14:56 +00:00
|
|
|
|
2005-02-17 20:01:59 +00:00
|
|
|
// Pseudo RTTI
|
|
|
|
virtual bool isHuman() const = 0;
|
|
|
|
|
2008-01-19 19:33:08 +00: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; }
|
|
|
|
|
2012-03-19 12:39:13 +01:00
|
|
|
/// Accessors for the table number
|
|
|
|
unsigned getTableNb() const { return m_tableNb; }
|
|
|
|
void setTableNb(unsigned tableNb) { m_tableNb = tableNb; }
|
|
|
|
|
2008-11-23 08:18:03 +00:00
|
|
|
/// ID handling
|
|
|
|
unsigned int getId() const { return m_id; }
|
2012-03-19 12:39:13 +01:00
|
|
|
void setId(unsigned int iId);
|
2008-01-28 19:17:33 +00:00
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
/**************************
|
|
|
|
* General getters
|
|
|
|
**************************/
|
2008-01-19 19:33:08 +00:00
|
|
|
/// Get the (possibly incomplete) rack of the player
|
2005-02-09 22:33:56 +00:00
|
|
|
const PlayedRack & getCurrentRack() const;
|
2008-01-19 19:33:08 +00:00
|
|
|
/// Get the previous rack
|
2005-02-05 11:14:56 +00:00
|
|
|
const PlayedRack & getLastRack() const;
|
2008-01-08 13:52:32 +00:00
|
|
|
/// Get the previous move (corresponding to the previous rack...)
|
|
|
|
const Move & getLastMove() const;
|
2005-02-05 11:14:56 +00:00
|
|
|
|
2005-02-09 22:33:56 +00:00
|
|
|
void setCurrentRack(const PlayedRack &iPld);
|
|
|
|
|
2005-12-26 21:18:21 +00:00
|
|
|
const History& getHistory() const { return m_history; }
|
2008-11-23 08:18:03 +00:00
|
|
|
History & accessHistory() { return m_history; }
|
2008-01-19 19:33:08 +00:00
|
|
|
|
2005-12-27 01:06:54 +00:00
|
|
|
/// Remove last turn
|
|
|
|
void removeLastTurn();
|
2005-12-26 21:18:21 +00:00
|
|
|
|
2012-04-22 22:30:53 +02:00
|
|
|
/// Return the total number of warnings received
|
|
|
|
unsigned getWarningsNb() const;
|
|
|
|
|
2012-10-05 18:34:31 +02:00
|
|
|
/// Return the total number of points received for moves alone
|
|
|
|
int getMovePoints() const;
|
|
|
|
|
2012-04-30 08:29:38 +02:00
|
|
|
/**
|
|
|
|
* Return the total number of penalties received
|
|
|
|
* (including the penalties due to warnings)
|
|
|
|
*/
|
|
|
|
int getPenaltyPoints() const;
|
|
|
|
|
|
|
|
/// Return the total number of solo points received
|
|
|
|
int getSoloPoints() const;
|
|
|
|
|
2012-10-05 18:19:06 +02:00
|
|
|
/// Return the total number of end game points
|
|
|
|
int getEndGamePoints() const;
|
|
|
|
|
2012-10-05 18:34:31 +02:00
|
|
|
/// Return the total score of the player, including solos, penalties, ...
|
2012-10-05 16:49:58 +02:00
|
|
|
int getTotalScore() const;
|
|
|
|
|
2006-01-22 12:23:52 +00:00
|
|
|
wstring toString() const;
|
2005-12-26 22:52:38 +00:00
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
private:
|
2005-11-06 17:13:45 +00:00
|
|
|
/// ID of the player
|
2008-01-08 13:52:32 +00:00
|
|
|
unsigned int m_id;
|
2005-11-06 17:13:45 +00:00
|
|
|
|
2008-01-19 19:33:08 +00:00
|
|
|
/// Name of the player
|
|
|
|
wstring m_name;
|
|
|
|
|
2012-03-19 12:39:13 +01:00
|
|
|
// Table number (optional: set to 0 if not used)
|
|
|
|
unsigned m_tableNb;
|
|
|
|
|
2005-11-05 23:57:41 +00:00
|
|
|
/// History of the racks and rounds for the player
|
2005-12-26 21:18:21 +00:00
|
|
|
History m_history;
|
2005-02-17 20:01:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-03-27 17:30:48 +00:00
|
|
|
/**
|
|
|
|
* Human player.
|
|
|
|
*/
|
2005-02-17 20:01:59 +00:00
|
|
|
class HumanPlayer: public Player
|
|
|
|
{
|
|
|
|
public:
|
2008-01-28 19:17:33 +00:00
|
|
|
HumanPlayer(): Player() {}
|
2005-02-17 20:01:59 +00:00
|
|
|
virtual ~HumanPlayer() {}
|
2005-02-05 11:14:56 +00:00
|
|
|
|
2005-02-17 20:01:59 +00:00
|
|
|
// Pseudo RTTI
|
|
|
|
virtual bool isHuman() const { return true; }
|
2005-02-05 11:14:56 +00:00
|
|
|
};
|
2004-08-07 18:25:03 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|