2005-02-05 12:14:56 +01:00
|
|
|
/*****************************************************************************
|
2005-02-09 23:33:56 +01:00
|
|
|
* Copyright (C) 2004-2005 Eliot
|
2005-02-05 12:14:56 +01:00
|
|
|
* Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "tile.h"
|
|
|
|
#include "rack.h"
|
|
|
|
#include "pldrack.h"
|
|
|
|
#include "round.h"
|
|
|
|
#include "results.h"
|
|
|
|
#include "board.h"
|
|
|
|
#include "player.h"
|
2005-11-06 15:53:15 +01:00
|
|
|
#include "turn.h"
|
2005-12-26 22:18:21 +01:00
|
|
|
#include "history.h"
|
2006-01-22 13:23:52 +01:00
|
|
|
#include "encoding.h"
|
2005-02-05 12:14:56 +01:00
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
2005-11-06 00:57:41 +01:00
|
|
|
|
2005-11-06 18:13:45 +01:00
|
|
|
Player::Player(int iId)
|
2005-02-05 12:14:56 +01:00
|
|
|
{
|
2005-11-06 18:13:45 +01:00
|
|
|
m_id = iId;
|
2005-11-06 00:57:41 +01:00
|
|
|
m_score = 0;
|
2005-02-05 12:14:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Player::~Player()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-09 23:33:56 +01:00
|
|
|
const PlayedRack & Player::getCurrentRack() const
|
2005-02-05 12:14:56 +01:00
|
|
|
{
|
2005-12-26 22:18:21 +01:00
|
|
|
return m_history.getCurrentRack();
|
2005-02-05 12:14:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-09 23:33:56 +01:00
|
|
|
void Player::setCurrentRack(const PlayedRack &iPld)
|
|
|
|
{
|
2005-12-26 22:18:21 +01:00
|
|
|
m_history.setCurrentRack(iPld);
|
2005-02-09 23:33:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-05 12:14:56 +01:00
|
|
|
const PlayedRack & Player::getLastRack() const
|
|
|
|
{
|
2005-12-26 22:18:21 +01:00
|
|
|
return m_history.getPreviousTurn().getPlayedRack();
|
2005-02-05 12:14:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const Round & Player::getLastRound() const
|
|
|
|
{
|
2005-12-26 22:18:21 +01:00
|
|
|
return m_history.getPreviousTurn().getRound();
|
2005-02-05 12:14:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Player::endTurn(const Round &iRound, int iTurn)
|
|
|
|
{
|
2005-12-26 22:18:21 +01:00
|
|
|
m_history.playRound(m_id,iTurn,iRound);
|
2005-02-05 12:14:56 +01:00
|
|
|
}
|
|
|
|
|
2005-12-27 02:06:54 +01:00
|
|
|
void Player::removeLastTurn()
|
|
|
|
{
|
|
|
|
m_history.removeLastTurn();
|
|
|
|
}
|
2005-12-26 23:52:38 +01:00
|
|
|
|
2006-01-22 13:23:52 +01:00
|
|
|
wstring Player::toString() const
|
2005-12-26 23:52:38 +01:00
|
|
|
{
|
2006-01-22 13:23:52 +01:00
|
|
|
wstring res;
|
|
|
|
|
|
|
|
wchar_t buff[6];
|
|
|
|
_swprintf(buff, 5, L"Player %d\n", m_id);
|
|
|
|
res = wstring(buff);
|
|
|
|
res += m_history.toString() + L"\n";
|
|
|
|
_swprintf(buff, 5, L"score %d\n", m_score);
|
|
|
|
res += wstring(buff);
|
2005-12-26 23:52:38 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2005-12-26 22:18:21 +01:00
|
|
|
/****************************************************************/
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
/// Local Variables:
|
|
|
|
/// mode: c++
|
|
|
|
/// mode: hs-minor
|
|
|
|
/// c-basic-offset: 4
|
2006-01-01 20:49:35 +01:00
|
|
|
/// indent-tabs-mode: nil
|
2005-12-26 22:18:21 +01:00
|
|
|
/// End:
|