Rack: rename a method

This commit is contained in:
Olivier Teulière 2013-01-17 17:55:00 +01:00
parent ac3cc02be4
commit b493b3b365
6 changed files with 11 additions and 11 deletions

View file

@ -136,11 +136,11 @@ void BoardSearch::leftPart(Rack &iRack, Round &ioPartialWord,
if (iLimit > 0) 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)) for (unsigned int succ = m_dic.getSucc(n); succ; succ = m_dic.getNext(succ))
{ {
const Tile &l = Tile(m_dic.getChar(succ)); const Tile &l = Tile(m_dic.getChar(succ));
if (iRack.in(l)) if (iRack.count(l))
{ {
iRack.remove(l); iRack.remove(l);
ioPartialWord.addRightFromRack(l, false); ioPartialWord.addRightFromRack(l, false);
@ -182,13 +182,13 @@ void BoardSearch::extendRight(Rack &iRack, Round &ioPartialWord,
if (m_crossMx[iRow][iCol].isNone()) if (m_crossMx[iRow][iCol].isNone())
return; 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)) for (unsigned int succ = m_dic.getSucc(iNode); succ; succ = m_dic.getNext(succ))
{ {
const Tile &l = Tile(m_dic.getChar(succ)); const Tile &l = Tile(m_dic.getChar(succ));
if (m_crossMx[iRow][iCol].check(l)) if (m_crossMx[iRow][iCol].check(l))
{ {
if (iRack.in(l)) if (iRack.count(l))
{ {
iRack.remove(l); iRack.remove(l);
ioPartialWord.addRightFromRack(l, false); ioPartialWord.addRightFromRack(l, false);

View file

@ -270,7 +270,7 @@ int FreeGame::checkPass(const Player &iPlayer,
BOOST_FOREACH(wchar_t wch, iToChange) BOOST_FOREACH(wchar_t wch, iToChange)
{ {
// Remove the letter from the rack // Remove the letter from the rack
if (!rack.in(Tile(wch))) if (!rack.count(Tile(wch)))
{ {
return 2; return 2;
} }

View file

@ -497,7 +497,7 @@ PlayedRack Game::helperSetRackRandom(const PlayedRack &iPld,
// We need to swap the joker (it is necessarily in the // We need to swap the joker (it is necessarily in the
// new tiles, because jokerAdded is true) // new tiles, because jokerAdded is true)
Rack tmpRack = pld.getNew(); 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.remove(Tile::Joker());
tmpRack.add(replacingTile); tmpRack.add(replacingTile);
pld.setNew(tmpRack); pld.setNew(tmpRack);
@ -525,7 +525,7 @@ bool Game::rackInBag(const Rack &iRack, const Bag &iBag) const
{ {
BOOST_FOREACH(const Tile &t, getDic().getAllTiles()) BOOST_FOREACH(const Tile &t, getDic().getAllTiles())
{ {
if (iRack.in(t) > iBag.count(t)) if (iRack.count(t) > iBag.count(t))
return false; return false;
} }
return true; return true;
@ -678,7 +678,7 @@ int Game::checkPlayedWord(const wstring &iCoord,
else else
t = round.getTile(i); t = round.getTile(i);
if (!rack.in(t)) if (!rack.count(t))
{ {
return 4; return 4;
} }

View file

@ -36,7 +36,7 @@ Rack::Rack()
void Rack::remove(const Tile &t) void Rack::remove(const Tile &t)
{ {
ASSERT(in(t), ASSERT(count(t),
"The rack does not contain the letter " + lfw(t.getDisplayStr())); "The rack does not contain the letter " + lfw(t.getDisplayStr()));
m_tiles[t.toCode()]--; m_tiles[t.toCode()]--;
m_nbTiles--; m_nbTiles--;

View file

@ -44,7 +44,7 @@ public:
unsigned getNbTiles() const { return m_nbTiles; } unsigned getNbTiles() const { return m_nbTiles; }
bool isEmpty() const { return getNbTiles() == 0; } 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 add(const Tile &t) { m_tiles[t.toCode()]++; m_nbTiles++; }
void remove(const Tile &t); void remove(const Tile &t);
void clear(); void clear();

View file

@ -201,7 +201,7 @@ void BagWidget2::refresh()
BOOST_FOREACH(const Tile &tile, m_game->getDic().getAllTiles()) BOOST_FOREACH(const Tile &tile, m_game->getDic().getAllTiles())
{ {
const unsigned int nbInBag = bag.count(tile); 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"); ASSERT(nbInBag >= nbInRack, "Unexpected letters in the rack");
for (unsigned i = 0; i < nbInBag - nbInRack; ++i) for (unsigned i = 0; i < nbInBag - nbInRack; ++i)
{ {