From b493b3b365805f9d5e7460332eb495e4337896d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Thu, 17 Jan 2013 17:55:00 +0100 Subject: [PATCH] Rack: rename a method --- game/board_search.cpp | 8 ++++---- game/freegame.cpp | 2 +- game/game.cpp | 6 +++--- game/rack.cpp | 2 +- game/rack.h | 2 +- qt/bag_widget.cpp | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/game/board_search.cpp b/game/board_search.cpp index 5db0be3..2d4cb19 100644 --- a/game/board_search.cpp +++ b/game/board_search.cpp @@ -136,11 +136,11 @@ void BoardSearch::leftPart(Rack &iRack, Round &ioPartialWord, if (iLimit > 0) { - bool hasJokerInRack = iRack.in(Tile::Joker()); + bool hasJokerInRack = iRack.count(Tile::Joker()); for (unsigned int succ = m_dic.getSucc(n); succ; succ = m_dic.getNext(succ)) { const Tile &l = Tile(m_dic.getChar(succ)); - if (iRack.in(l)) + if (iRack.count(l)) { iRack.remove(l); ioPartialWord.addRightFromRack(l, false); @@ -182,13 +182,13 @@ void BoardSearch::extendRight(Rack &iRack, Round &ioPartialWord, if (m_crossMx[iRow][iCol].isNone()) return; - bool hasJokerInRack = iRack.in(Tile::Joker()); + bool hasJokerInRack = iRack.count(Tile::Joker()); for (unsigned int succ = m_dic.getSucc(iNode); succ; succ = m_dic.getNext(succ)) { const Tile &l = Tile(m_dic.getChar(succ)); if (m_crossMx[iRow][iCol].check(l)) { - if (iRack.in(l)) + if (iRack.count(l)) { iRack.remove(l); ioPartialWord.addRightFromRack(l, false); diff --git a/game/freegame.cpp b/game/freegame.cpp index d68e0a7..f1ebcfe 100644 --- a/game/freegame.cpp +++ b/game/freegame.cpp @@ -270,7 +270,7 @@ int FreeGame::checkPass(const Player &iPlayer, BOOST_FOREACH(wchar_t wch, iToChange) { // Remove the letter from the rack - if (!rack.in(Tile(wch))) + if (!rack.count(Tile(wch))) { return 2; } diff --git a/game/game.cpp b/game/game.cpp index 423f45c..b07b78b 100644 --- a/game/game.cpp +++ b/game/game.cpp @@ -497,7 +497,7 @@ PlayedRack Game::helperSetRackRandom(const PlayedRack &iPld, // We need to swap the joker (it is necessarily in the // new tiles, because jokerAdded is true) Rack tmpRack = pld.getNew(); - ASSERT(tmpRack.in(Tile::Joker()), "No joker found in the new tiles"); + ASSERT(tmpRack.count(Tile::Joker()), "No joker found in the new tiles"); tmpRack.remove(Tile::Joker()); tmpRack.add(replacingTile); pld.setNew(tmpRack); @@ -525,7 +525,7 @@ bool Game::rackInBag(const Rack &iRack, const Bag &iBag) const { BOOST_FOREACH(const Tile &t, getDic().getAllTiles()) { - if (iRack.in(t) > iBag.count(t)) + if (iRack.count(t) > iBag.count(t)) return false; } return true; @@ -678,7 +678,7 @@ int Game::checkPlayedWord(const wstring &iCoord, else t = round.getTile(i); - if (!rack.in(t)) + if (!rack.count(t)) { return 4; } diff --git a/game/rack.cpp b/game/rack.cpp index 443355b..572db4a 100644 --- a/game/rack.cpp +++ b/game/rack.cpp @@ -36,7 +36,7 @@ Rack::Rack() void Rack::remove(const Tile &t) { - ASSERT(in(t), + ASSERT(count(t), "The rack does not contain the letter " + lfw(t.getDisplayStr())); m_tiles[t.toCode()]--; m_nbTiles--; diff --git a/game/rack.h b/game/rack.h index 0484d0e..30ec8e0 100644 --- a/game/rack.h +++ b/game/rack.h @@ -44,7 +44,7 @@ public: unsigned getNbTiles() const { return m_nbTiles; } bool isEmpty() const { return getNbTiles() == 0; } - unsigned in(const Tile &t) const { return m_tiles[t.toCode()]; } + unsigned count(const Tile &t) const { return m_tiles[t.toCode()]; } void add(const Tile &t) { m_tiles[t.toCode()]++; m_nbTiles++; } void remove(const Tile &t); void clear(); diff --git a/qt/bag_widget.cpp b/qt/bag_widget.cpp index 0289d15..73e6696 100644 --- a/qt/bag_widget.cpp +++ b/qt/bag_widget.cpp @@ -201,7 +201,7 @@ void BagWidget2::refresh() BOOST_FOREACH(const Tile &tile, m_game->getDic().getAllTiles()) { const unsigned int nbInBag = bag.count(tile); - const unsigned int nbInRack = rack.in(tile); + const unsigned int nbInRack = rack.count(tile); ASSERT(nbInBag >= nbInRack, "Unexpected letters in the rack"); for (unsigned i = 0; i < nbInBag - nbInRack; ++i) {