diff --git a/game/cmd/game_move_cmd.cpp b/game/cmd/game_move_cmd.cpp index be62836..dac100b 100644 --- a/game/cmd/game_move_cmd.cpp +++ b/game/cmd/game_move_cmd.cpp @@ -21,7 +21,6 @@ #include #include "cmd/game_move_cmd.h" -#include "player.h" #include "game_params.h" #include "game.h" #include "rack.h" @@ -31,11 +30,9 @@ INIT_LOGGER(game, GameMoveCmd); -GameMoveCmd::GameMoveCmd(Game &ioGame, const Move &iMove, - unsigned int iPlayerId) +GameMoveCmd::GameMoveCmd(Game &ioGame, const Move &iMove) : m_game(ioGame), m_move(iMove), - m_moveRack(ioGame.getHistory().getCurrentRack()), - m_playerId(iPlayerId) + m_moveRack(ioGame.getHistory().getCurrentRack()) { setAutoExecutable(false); } @@ -48,7 +45,7 @@ void GameMoveCmd::doExecute() // History of the game History &history = m_game.accessHistory(); - history.playMove(m_playerId, m_move, newRack); + history.playMove(m_move, newRack); // Points m_game.addPoints(m_move.getScore()); diff --git a/game/cmd/game_move_cmd.h b/game/cmd/game_move_cmd.h index 8137da5..13d84b4 100644 --- a/game/cmd/game_move_cmd.h +++ b/game/cmd/game_move_cmd.h @@ -46,14 +46,12 @@ class GameMoveCmd: public Command DEFINE_LOGGER(); public: - GameMoveCmd(Game &ioGame, const Move &iMove, - unsigned int iPlayerId); + GameMoveCmd(Game &ioGame, const Move &iMove); virtual wstring toString() const; // Getters const Move & getMove() const { return m_move; } - unsigned int getPlayerId() const { return m_playerId; } protected: virtual void doExecute(); @@ -64,7 +62,6 @@ class GameMoveCmd: public Command Move m_move; Round m_round; PlayedRack m_moveRack; - unsigned int m_playerId; void playRound(); void unplayRound(); diff --git a/game/cmd/player_move_cmd.cpp b/game/cmd/player_move_cmd.cpp index 918a5cd..ea9dc14 100644 --- a/game/cmd/player_move_cmd.cpp +++ b/game/cmd/player_move_cmd.cpp @@ -44,7 +44,7 @@ void PlayerMoveCmd::doExecute() const PlayedRack &newRack = Move::ComputeRackForMove(m_originalRack, m_move); // Update the history and rack of the player - m_player.accessHistory().playMove(m_player.getId(), m_move, newRack); + m_player.accessHistory().playMove(m_move, newRack); } diff --git a/game/duplicate.cpp b/game/duplicate.cpp index 94a5f4e..547a9e1 100644 --- a/game/duplicate.cpp +++ b/game/duplicate.cpp @@ -311,7 +311,7 @@ void Duplicate::endTurn() // Play the master word on the board // We assign it to player 0 arbitrarily (this is only used // to retrieve the rack, which is the same for all players...) - Command *pCmd = new GameMoveCmd(*this, m_masterMove, REF_PLAYER_ID); + Command *pCmd = new GameMoveCmd(*this, m_masterMove); accessNavigation().addAndExecute(pCmd); // Change the turn after doing all the game changes. diff --git a/game/freegame.cpp b/game/freegame.cpp index d9aa3c2..d68e0a7 100644 --- a/game/freegame.cpp +++ b/game/freegame.cpp @@ -153,7 +153,7 @@ int FreeGame::endTurn() const Move &move = getCurrentPlayer().getLastMove(); // Update the game - Command *pCmd = new GameMoveCmd(*this, move, m_currPlayer); + Command *pCmd = new GameMoveCmd(*this, move); accessNavigation().addAndExecute(pCmd); // Complete the rack for the player that just played diff --git a/game/history.cpp b/game/history.cpp index 24ab359..163688b 100644 --- a/game/history.cpp +++ b/game/history.cpp @@ -96,14 +96,12 @@ bool History::beforeFirstRound() const } -void History::playMove(unsigned int iPlayer, - const Move &iMove, +void History::playMove(const Move &iMove, const PlayedRack &iNewRack) { TurnData * current_turn = m_history.back(); // Set the number and the round - current_turn->setPlayer(iPlayer); current_turn->setMove(iMove); // Create a new turn @@ -125,11 +123,10 @@ void History::removeLastTurn() delete t; } +#ifdef BACK_REMOVE_RACK_NEW_PART // Now we have the previous played round in back() TurnData *t = m_history.back(); - t->setPlayer(0); //t->setRound(Round()); -#ifdef BACK_REMOVE_RACK_NEW_PART t->getPlayedRound().setNew(Rack()); #endif } diff --git a/game/history.h b/game/history.h index 442b9bd..5ec200c 100644 --- a/game/history.h +++ b/game/history.h @@ -83,8 +83,7 @@ public: bool beforeFirstRound() const; /// Update the history with the given move and complete the turn. - void playMove(unsigned int player, const Move &iMove, - const PlayedRack &iNewRack); + void playMove(const Move &iMove, const PlayedRack &iNewRack); /// Remove last turn void removeLastTurn(); diff --git a/game/topping.cpp b/game/topping.cpp index dc7571e..9072a59 100644 --- a/game/topping.cpp +++ b/game/topping.cpp @@ -180,7 +180,7 @@ void Topping::endTurn() { // Play the top move on the board const Move &move = getTopMove(); - Command *pCmd = new GameMoveCmd(*this, move, m_currPlayer); + Command *pCmd = new GameMoveCmd(*this, move); accessNavigation().addAndExecute(pCmd); accessNavigation().newTurn(); diff --git a/game/training.cpp b/game/training.cpp index 10f8559..b7990fc 100644 --- a/game/training.cpp +++ b/game/training.cpp @@ -145,7 +145,7 @@ void Training::endTurn() move = getMoveFromMasterGame(); else move = m_players[m_currPlayer]->getLastMove(); - Command *pCmd = new GameMoveCmd(*this, move, m_currPlayer); + Command *pCmd = new GameMoveCmd(*this, move); accessNavigation().addAndExecute(pCmd); accessNavigation().newTurn(); } diff --git a/game/turn_data.cpp b/game/turn_data.cpp index 5b22448..8000831 100644 --- a/game/turn_data.cpp +++ b/game/turn_data.cpp @@ -30,15 +30,13 @@ INIT_LOGGER(game, TurnData); // FIXME: move set to an arbitrary one (no move). It would be better to get rid of this // constructor completely TurnData::TurnData() - : m_playerId(0), m_warningsNb(0), - m_penaltyPoints(0), m_soloPoints(0), m_endGamePoints(0) + : m_warningsNb(0), m_penaltyPoints(0), m_soloPoints(0), m_endGamePoints(0) { } -TurnData::TurnData(unsigned int iPlayerId, const PlayedRack& iPldRack, - const Move& iMove) - : m_playerId(iPlayerId), m_pldrack(iPldRack), m_move(iMove), +TurnData::TurnData(const PlayedRack& iPldRack, const Move& iMove) + : m_pldrack(iPldRack), m_move(iMove), m_warningsNb(0), m_penaltyPoints(0), m_soloPoints(0), m_endGamePoints(0) { } diff --git a/game/turn_data.h b/game/turn_data.h index 89955b6..c7380cc 100644 --- a/game/turn_data.h +++ b/game/turn_data.h @@ -42,10 +42,8 @@ class TurnData DEFINE_LOGGER(); public: TurnData(); - TurnData(unsigned int iPlayerId, - const PlayedRack& iPldRack, const Move& iMove); + TurnData(const PlayedRack& iPldRack, const Move& iMove); - void setPlayer(unsigned int iPlayerId) { m_playerId = iPlayerId; } void setPlayedRack(const PlayedRack& iPldRack) { m_pldrack = iPldRack; } void setMove(const Move& iMove) { m_move = iMove; } // Setters for events (warnings, penalties, solos, end game primes) @@ -54,7 +52,6 @@ public: void addSoloPoints(int iPoints) { m_soloPoints += iPoints; } void addEndGamePoints(int iPoints) { m_endGamePoints += iPoints; } - unsigned int getPlayer() const { return m_playerId; } const PlayedRack& getPlayedRack() const { return m_pldrack; } const Move& getMove() const { return m_move; } // Getters for events (warnings, penalties, solos, end game primes) @@ -66,7 +63,6 @@ public: wstring toString() const; private: - unsigned int m_playerId; PlayedRack m_pldrack; Move m_move; int m_warningsNb; diff --git a/game/xml_reader.cpp b/game/xml_reader.cpp index b26baf8..eda876c 100644 --- a/game/xml_reader.cpp +++ b/game/xml_reader.cpp @@ -412,8 +412,7 @@ void XmlReader::endElement(const string& namespaceURI, else if (tag == "GameMove") { const Move &move = buildMove(*m_game, m_attributes, false); - Player &p = getPlayer(m_players, m_attributes["playerId"], tag); - GameMoveCmd *cmd = new GameMoveCmd(*m_game, move, p.getId()); + GameMoveCmd *cmd = new GameMoveCmd(*m_game, move); m_game->accessNavigation().addAndExecute(cmd); } diff --git a/game/xml_writer.cpp b/game/xml_writer.cpp index 1405701..c6d55dd 100644 --- a/game/xml_writer.cpp +++ b/game/xml_writer.cpp @@ -251,9 +251,8 @@ void XmlWriter::write(const Game &iGame, const string &iFileName) else if (dynamic_cast(cmd)) { const GameMoveCmd *moveCmd = static_cast(cmd); - unsigned int id = moveCmd->getPlayerId(); out << indent; - writeMove(out, moveCmd->getMove(), "GameMove", id); + writeMove(out, moveCmd->getMove(), "GameMove", -1); out << endl; } else if (dynamic_cast(cmd))