2005-02-05 12:14:56 +01:00
|
|
|
/*****************************************************************************
|
2008-01-08 14:52:32 +01:00
|
|
|
* Eliot
|
2012-10-07 16:25:41 +02:00
|
|
|
* Copyright (C) 2004-2012 Olivier Teulière & Antoine Fraboulet
|
2008-01-08 14:52:32 +01:00
|
|
|
* 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
|
|
|
|
2009-11-29 17:01:31 +01:00
|
|
|
#ifndef PLAYER_H_
|
|
|
|
#define PLAYER_H_
|
2004-08-07 20:25:03 +02:00
|
|
|
|
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"
|
2012-02-18 22:26:52 +01:00
|
|
|
#include "logging.h"
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2008-01-19 20:33:08 +01:00
|
|
|
using std::wstring;
|
|
|
|
|
2012-10-06 01:57:39 +02:00
|
|
|
class TurnData;
|
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
|
|
|
|
{
|
2012-02-18 22:26:52 +01:00
|
|
|
DEFINE_LOGGER();
|
2005-02-05 12:14:56 +01:00
|
|
|
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; }
|
|
|
|
|
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 09:18:03 +01: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 20:17:33 +01:00
|
|
|
|
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
|
|
|
|
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 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
|
|
|
|
2008-01-19 20:33:08 +01: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-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
|
|
|
|
|