diff --git a/game/board_search.cpp b/game/board_search.cpp index 2d4cb19..94a6341 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.count(Tile::Joker()); + bool hasJokerInRack = iRack.contains(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.count(l)) + if (iRack.contains(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.count(Tile::Joker()); + bool hasJokerInRack = iRack.contains(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.count(l)) + if (iRack.contains(l)) { iRack.remove(l); ioPartialWord.addRightFromRack(l, false); diff --git a/game/freegame.cpp b/game/freegame.cpp index f1ebcfe..1e584f7 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.count(Tile(wch))) + if (!rack.contains(Tile(wch))) { return 2; } diff --git a/game/game.cpp b/game/game.cpp index b07b78b..28142f0 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.count(Tile::Joker()), "No joker found in the new tiles"); + ASSERT(tmpRack.contains(Tile::Joker()), "No joker found in the new tiles"); tmpRack.remove(Tile::Joker()); tmpRack.add(replacingTile); pld.setNew(tmpRack); @@ -678,7 +678,7 @@ int Game::checkPlayedWord(const wstring &iCoord, else t = round.getTile(i); - if (!rack.count(t)) + if (!rack.contains(t)) { return 4; } diff --git a/game/rack.h b/game/rack.h index 30ec8e0..e37865c 100644 --- a/game/rack.h +++ b/game/rack.h @@ -45,6 +45,8 @@ public: bool isEmpty() const { return getNbTiles() == 0; } unsigned count(const Tile &t) const { return m_tiles[t.toCode()]; } + bool contains(const Tile &t) const { return count(t); } + void add(const Tile &t) { m_tiles[t.toCode()]++; m_nbTiles++; } void remove(const Tile &t); void clear();