Removed experimental support of the real bag. It was not a good idea after all...

This commit is contained in:
Olivier Teulière 2008-11-23 16:58:31 +00:00
parent 675b534e77
commit 7fa8c2b58f
4 changed files with 0 additions and 94 deletions

View file

@ -234,13 +234,9 @@ int FreeGame::checkPass(const Player &iPlayer,
// It is forbidden to change letters when the bag does not contain at // It is forbidden to change letters when the bag does not contain at
// least 7 letters (this is explicitly stated in the ODS). But it is // least 7 letters (this is explicitly stated in the ODS). But it is
// still allowed to pass // still allowed to pass
#ifdef REAL_BAG_MODE
if (m_bag.getNbTiles() < 7 && !iToChange.empty())
#else
Bag bag(getDic()); Bag bag(getDic());
realBag(bag); realBag(bag);
if (bag.getNbTiles() < 7 && !iToChange.empty()) if (bag.getNbTiles() < 7 && !iToChange.empty())
#endif
{ {
return 1; return 1;
} }

View file

@ -125,42 +125,6 @@ void Game::shuffleRack()
m_players[currPlayer()]->setCurrentRack(pld); m_players[currPlayer()]->setCurrentRack(pld);
} }
#ifdef REAL_BAG_MODE
Bag Game::getBag() const
{
Bag bag = m_bag;
vector<Tile> tiles;
// The real content of the bag depends on the game mode
if (getMode() == kFREEGAME)
{
// In freegame mode, replace the letters from all the racks
BOOST_FOREACH(const Player *player, m_players)
{
player->getCurrentRack().getAllTiles(tiles);
BOOST_FOREACH(const Tile &tile, tiles)
{
bag.replaceTile(tile);
}
}
}
else
{
// In training or duplicate mode, replace the rack of the current
// player only
getPlayer(m_currPlayer).getCurrentRack().getAllTiles(tiles);
BOOST_FOREACH(const Tile &tile, tiles)
{
bag.replaceTile(tile);
}
}
return bag;
}
#else
void Game::realBag(Bag &ioBag) const void Game::realBag(Bag &ioBag) const
{ {
@ -194,7 +158,6 @@ void Game::realBag(Bag &ioBag) const
} }
} }
#endif
PlayedRack Game::helperSetRackRandom(const PlayedRack &iPld, PlayedRack Game::helperSetRackRandom(const PlayedRack &iPld,
bool iCheck, set_rack_mode mode) const bool iCheck, set_rack_mode mode) const
@ -224,12 +187,8 @@ PlayedRack Game::helperSetRackRandom(const PlayedRack &iPld,
// Create a copy of the bag in which we can do everything we want, // Create a copy of the bag in which we can do everything we want,
// and take from it the tiles of the players rack so that "bag" // and take from it the tiles of the players rack so that "bag"
// contains the right number of tiles. // contains the right number of tiles.
#ifdef REAL_BAG_MODE
Bag &bag = m_bag;
#else
Bag bag(m_dic); Bag bag(m_dic);
realBag(bag); realBag(bag);
#endif
if (mode == RACK_NEW && nold != 0) if (mode == RACK_NEW && nold != 0)
{ {
// We may have removed too many letters from the bag (i.e. the 'new' // We may have removed too many letters from the bag (i.e. the 'new'
@ -448,21 +407,12 @@ int Game::helperSetRackManual(unsigned int p, bool iCheck, const wstring &iLette
PlayedRack pld; PlayedRack pld;
pld.setManual(iLetters); pld.setManual(iLetters);
#ifdef REAL_BAG_MODE
vector<Tile> allTiles;
m_players[p]->getCurrentRack().getAllTiles(allTiles);
BOOST_FOREACH(const Tile &tile, allTiles)
{
m_bag.replaceTile(tile);
}
#else
Rack rack; Rack rack;
pld.getRack(rack); pld.getRack(rack);
if (!rackInBag(rack, m_bag)) if (!rackInBag(rack, m_bag))
{ {
return 1; return 1;
} }
#endif
if (iCheck) if (iCheck)
{ {
@ -474,26 +424,10 @@ int Game::helperSetRackManual(unsigned int p, bool iCheck, const wstring &iLette
min = 1; min = 1;
if (!pld.checkRack(min, min)) if (!pld.checkRack(min, min))
{ {
#ifdef REAL_BAG_MODE
// Changing the rack failed, so we restore the tiles we
// just removed
BOOST_FOREACH(const Tile &tile, allTiles)
{
m_bag.takeTile(tile);
}
#endif
return 2; return 2;
} }
} }
#ifdef REAL_BAG_MODE
pld.getAllTiles(allTiles);
BOOST_FOREACH(const Tile &tile, allTiles)
{
m_bag.takeTile(tile);
}
#endif
m_players[p]->setCurrentRack(pld); m_players[p]->setCurrentRack(pld);
return 0; return 0;

View file

@ -100,9 +100,6 @@ public:
const Board& getBoard() const { return m_board; } const Board& getBoard() const { return m_board; }
Board & accessBoard() { return m_board; } Board & accessBoard() { return m_board; }
/// Get the bag /// Get the bag
#ifdef REAL_BAG_MODE
Bag getBag() const;
#else
const Bag& getBag() const { return m_bag; } const Bag& getBag() const { return m_bag; }
Bag & accessBag() { return m_bag; } Bag & accessBag() { return m_bag; }
/** /**
@ -114,7 +111,6 @@ public:
* it is important to set m_currPlayer accurately before! * it is important to set m_currPlayer accurately before!
*/ */
void realBag(Bag &iBag) const; void realBag(Bag &iBag) const;
#endif
/// Get the history of the game */ /// Get the history of the game */

View file

@ -51,16 +51,6 @@ void GameMoveCmd::doExecute()
{ {
playRound(); playRound();
} }
#ifdef REAL_BAG_MODE
else if (m_move.getType() == Move::CHANGE_LETTERS)
{
// Put the changed letters back into the bag
BOOST_FOREACH(wchar_t ch, m_move.getChangedLetters())
{
m_bag.replaceTile(Tile(ch));
}
}
#endif
} }
@ -87,8 +77,6 @@ void GameMoveCmd::playRound()
// method. // method.
m_round = m_move.getRound(); m_round = m_move.getRound();
#ifdef REAL_BAG_MODE
#else
// Update the bag // Update the bag
// We remove tiles from the bag only when they are played // We remove tiles from the bag only when they are played
// on the board. When going back in the game, we must only // on the board. When going back in the game, we must only
@ -109,7 +97,6 @@ void GameMoveCmd::playRound()
} }
} }
} }
#endif
if (m_game.getVariant() == Game::kJOKER) if (m_game.getVariant() == Game::kJOKER)
{ {
@ -118,12 +105,8 @@ void GameMoveCmd::playRound()
if (m_round.isPlayedFromRack(i) && m_round.isJoker(i)) if (m_round.isPlayedFromRack(i) && m_round.isJoker(i))
{ {
// Get the real bag // Get the real bag
#ifdef REAL_BAG_MODE
Bag &bag = m_game.accessBag();
#else
Bag bag(m_game.getDic()); Bag bag(m_game.getDic());
m_game.realBag(bag); m_game.realBag(bag);
#endif
// Is the represented letter still available in the bag? // Is the represented letter still available in the bag?
// XXX: this way to get the represented letter sucks... // XXX: this way to get the represented letter sucks...
@ -155,8 +138,6 @@ void GameMoveCmd::unplayRound()
// Update the board // Update the board
m_game.accessBoard().removeRound(m_game.getDic(), m_round); m_game.accessBoard().removeRound(m_game.getDic(), m_round);
#ifdef REAL_BAG_MODE
#else
// Update the bag // Update the bag
// We remove tiles from the bag only when they are played // We remove tiles from the bag only when they are played
// on the board. When going back in the game, we must only // on the board. When going back in the game, we must only
@ -177,6 +158,5 @@ void GameMoveCmd::unplayRound()
} }
} }
} }
#endif
} }