mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-11-16 07:47:39 +01:00
Move::ComputeRackForMove() now returns a PlayedRack instead of a simple Rack
This commit is contained in:
parent
cc0fe39c76
commit
21ee07cc3b
6 changed files with 14 additions and 19 deletions
|
@ -44,7 +44,7 @@ GameMoveCmd::GameMoveCmd(Game &ioGame, const Move &iMove,
|
|||
void GameMoveCmd::doExecute()
|
||||
{
|
||||
// Get the original rack from the player history
|
||||
const Rack &newRack = Move::ComputeRackForMove(m_moveRack, m_move);
|
||||
const PlayedRack &newRack = Move::ComputeRackForMove(m_moveRack, m_move);
|
||||
|
||||
// History of the game
|
||||
History &history = m_game.accessHistory();
|
||||
|
|
|
@ -98,7 +98,7 @@ bool History::beforeFirstRound() const
|
|||
|
||||
void History::playMove(unsigned int iPlayer,
|
||||
const Move &iMove,
|
||||
const Rack &iNewRack)
|
||||
const PlayedRack &iNewRack)
|
||||
{
|
||||
Turn * current_turn = m_history.back();
|
||||
|
||||
|
@ -107,10 +107,8 @@ void History::playMove(unsigned int iPlayer,
|
|||
current_turn->setMove(iMove);
|
||||
|
||||
// Create a new turn
|
||||
PlayedRack pldrack;
|
||||
pldrack.setOld(iNewRack);
|
||||
Turn * next_turn = new Turn();
|
||||
next_turn->setPlayedRack(pldrack);
|
||||
next_turn->setPlayedRack(iNewRack);
|
||||
m_history.push_back(next_turn);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ using std::vector;
|
|||
class Move;
|
||||
class Turn;
|
||||
class PlayedRack;
|
||||
class Rack;
|
||||
|
||||
/**
|
||||
* History stores all the turns that have been played
|
||||
|
@ -83,13 +82,9 @@ public:
|
|||
*/
|
||||
bool beforeFirstRound() const;
|
||||
|
||||
/**
|
||||
* Update the history with the given move and complete the turn.
|
||||
* A new turn is created with the unplayed letters in the rack
|
||||
* 03 sept 2000: We have to sort the tiles according to the new rules
|
||||
*/
|
||||
/// Update the history with the given move and complete the turn.
|
||||
void playMove(unsigned int player, const Move &iMove,
|
||||
const Rack &iNewRack);
|
||||
const PlayedRack &iNewRack);
|
||||
|
||||
/// Remove last turn
|
||||
void removeLastTurn();
|
||||
|
|
|
@ -98,9 +98,11 @@ const wstring & Move::getChangedLetters() const
|
|||
}
|
||||
|
||||
|
||||
Rack Move::ComputeRackForMove(const PlayedRack &iOldRack, const Move &iMove)
|
||||
PlayedRack Move::ComputeRackForMove(const PlayedRack &iOldRack, const Move &iMove)
|
||||
{
|
||||
// Start from the given rack
|
||||
// 03 sept 2000: We have to sort the tiles according to the new rules
|
||||
// Using a Rack object will indirectly do it for us
|
||||
Rack newRack = iOldRack.getRack();
|
||||
|
||||
if (iMove.getType() == Move::VALID_ROUND)
|
||||
|
@ -128,7 +130,9 @@ Rack Move::ComputeRackForMove(const PlayedRack &iOldRack, const Move &iMove)
|
|||
}
|
||||
}
|
||||
|
||||
return newRack;
|
||||
PlayedRack newPldRack;
|
||||
newPldRack.setOld(newRack);
|
||||
return newPldRack;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "round.h"
|
||||
#include "logging.h"
|
||||
|
||||
class Rack;
|
||||
class PlayedRack;
|
||||
using std::wstring;
|
||||
|
||||
|
@ -121,8 +120,8 @@ class Move
|
|||
* given move.
|
||||
* The move is supposed to be possible for the given rack.
|
||||
*/
|
||||
static Rack ComputeRackForMove(const PlayedRack &iOldRack,
|
||||
const Move &iMove);
|
||||
static PlayedRack ComputeRackForMove(const PlayedRack &iOldRack,
|
||||
const Move &iMove);
|
||||
|
||||
/// To help debugging
|
||||
wstring toString() const;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include "player_move_cmd.h"
|
||||
#include "player.h"
|
||||
#include "rack.h"
|
||||
|
||||
|
||||
INIT_LOGGER(game, PlayerMoveCmd);
|
||||
|
@ -41,7 +40,7 @@ void PlayerMoveCmd::doExecute()
|
|||
m_originalRack = m_player.getCurrentRack();
|
||||
|
||||
// Compute the new rack
|
||||
const Rack &newRack = Move::ComputeRackForMove(m_originalRack, m_move);
|
||||
const PlayedRack &newRack = Move::ComputeRackForMove(m_originalRack, m_move);
|
||||
|
||||
// Update the score of the player
|
||||
m_player.addPoints(m_move.getScore());
|
||||
|
|
Loading…
Reference in a new issue