00001 /***************************************************************************** 00002 * Copyright (C) 2004-2005 Eliot 00003 * Authors: Olivier Teuliere <ipkiss@via.ecp.fr> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 *****************************************************************************/ 00019 00020 #include "tile.h" 00021 #include "rack.h" 00022 #include "pldrack.h" 00023 #include "round.h" 00024 #include "results.h" 00025 #include "board.h" 00026 #include "player.h" 00027 #include "turn.h" 00028 #include "history.h" 00029 00030 #include "debug.h" 00031 00032 00033 Player::Player(int iId) 00034 { 00035 m_id = iId; 00036 m_score = 0; 00037 } 00038 00039 00040 Player::~Player() 00041 { 00042 } 00043 00044 00045 const PlayedRack & Player::getCurrentRack() const 00046 { 00047 return m_history.getCurrentRack(); 00048 } 00049 00050 00051 void Player::setCurrentRack(const PlayedRack &iPld) 00052 { 00053 m_history.setCurrentRack(iPld); 00054 } 00055 00056 00057 const PlayedRack & Player::getLastRack() const 00058 { 00059 return m_history.getPreviousTurn().getPlayedRack(); 00060 } 00061 00062 00063 const Round & Player::getLastRound() const 00064 { 00065 return m_history.getPreviousTurn().getRound(); 00066 } 00067 00068 00069 void Player::endTurn(const Round &iRound, int iTurn) 00070 { 00071 m_history.playRound(m_id,iTurn,iRound); 00072 } 00073 00074 void Player::removeLastTurn() 00075 { 00076 m_history.removeLastTurn(); 00077 } 00078 00079 const string Player::toString() const 00080 { 00081 char buff[20]; 00082 string res; 00083 00084 sprintf(buff,"Player %d\n",m_id); 00085 res = string(buff); 00086 res += m_history.toString(); 00087 res += "\n"; 00088 sprintf(buff,"score %d\n",m_score); 00089 res += string(buff); 00090 return res; 00091 } 00092 00093 /****************************************************************/ 00094 /****************************************************************/ 00095 00096 /// Local Variables: 00097 /// mode: c++ 00098 /// mode: hs-minor 00099 /// c-basic-offset: 4 00100 /// indent-tabs-mode: nil 00101 /// End: