diff --git a/game/ai_percent.cpp b/game/ai_percent.cpp index 098152e..2b9ac23 100644 --- a/game/ai_percent.cpp +++ b/game/ai_percent.cpp @@ -65,7 +65,7 @@ void AIPercent::compute(const Dictionary &iDic, const Board &iBoard, bool iFirst Move AIPercent::getMove() const { - if (m_results->size() == 0) + if (m_results->isEmpty()) { // If there is no result, pass the turn. // FIXME: in duplicate mode, we should return a move of type NO_MOVE diff --git a/game/duplicate.cpp b/game/duplicate.cpp index 33e0e64..94a5f4e 100644 --- a/game/duplicate.cpp +++ b/game/duplicate.cpp @@ -280,7 +280,7 @@ void Duplicate::endTurn() const Rack &rack = m_players[REF_PLAYER_ID]->getLastRack().getRack(); results.search(getDic(), getBoard(), rack, getHistory().beforeFirstRound()); - if (results.size() == 0) + if (results.isEmpty()) { // This would be very bad luck that no move is possible... // It's probably not even possible, but let's be safe. diff --git a/game/game.cpp b/game/game.cpp index fae5969..0d8c25d 100644 --- a/game/game.cpp +++ b/game/game.cpp @@ -453,7 +453,7 @@ PlayedRack Game::helperSetRackRandom(const PlayedRack &iPld, BestResults res; res.search(getDic(), getBoard(), rack, getHistory().beforeFirstRound()); - if (res.size()) + if (!res.isEmpty()) { PlayedRack pldCopy = pld; diff --git a/game/results.h b/game/results.h index b5e697e..e763953 100644 --- a/game/results.h +++ b/game/results.h @@ -52,6 +52,7 @@ public: virtual ~Results() {} unsigned int size() const { return m_rounds.size(); } const Round & get(unsigned int) const; + bool isEmpty() const { return m_rounds.empty(); } /** * Perform a search on the board. Every time a word is found, diff --git a/game/topping.cpp b/game/topping.cpp index 9e56ef0..dc7571e 100644 --- a/game/topping.cpp +++ b/game/topping.cpp @@ -216,7 +216,7 @@ Move Topping::getTopMove() const BestResults results; results.search(getDic(), getBoard(), getHistory().getCurrentRack().getRack(), getHistory().beforeFirstRound()); - ASSERT(results.size() != 0, "No top move found"); + ASSERT(!results.isEmpty(), "No top move found"); return Move(results.get(0)); } diff --git a/qt/arbit_assignments.cpp b/qt/arbit_assignments.cpp index 4bfa40c..750d4c7 100644 --- a/qt/arbit_assignments.cpp +++ b/qt/arbit_assignments.cpp @@ -472,7 +472,7 @@ void ArbitAssignments::setMasterMove() results.search(m_game->getDic(), m_game->getBoard(), m_game->getCurrentRack().getRack(), m_game->getHistory().beforeFirstRound()); - ASSERT(results.size() != 0, "No possible valid move"); + ASSERT(!results.isEmpty(), "No possible valid move"); int bestScore = results.get(0).getPoints(); if (bestScore > move.getScore()) { @@ -530,7 +530,7 @@ void ArbitAssignments::setDefaultMasterMove() m_game->getCurrentRack().getRack(), m_game->getHistory().beforeFirstRound()); // XXX: End of game - if (results.size() == 0) + if (results.isEmpty()) return; unsigned currIndex = 0; diff --git a/qt/arbitration_widget.cpp b/qt/arbitration_widget.cpp index 2a27046..0b94007 100644 --- a/qt/arbitration_widget.cpp +++ b/qt/arbitration_widget.cpp @@ -721,7 +721,7 @@ int ArbitrationWidget::getBestScore() const results.search(m_game->getDic(), m_game->getBoard(), m_game->getCurrentRack().getRack(), m_game->getHistory().beforeFirstRound()); - ASSERT(results.size() != 0, "No possible valid move"); + ASSERT(!results.isEmpty(), "No possible valid move"); return results.get(0).getPoints(); } diff --git a/qt/training_widget.cpp b/qt/training_widget.cpp index 1865ada..1edb1e9 100644 --- a/qt/training_widget.cpp +++ b/qt/training_widget.cpp @@ -192,7 +192,7 @@ void TrainingWidget::updateModel() const Results &results = m_game->trainingGetResults(); // Find the highest score int bestScore = -1; - if (results.size() != 0) + if (!results.isEmpty()) bestScore = results.get(0).getPoints(); for (unsigned int i = 0; i < results.size(); ++i) { diff --git a/utils/ncurses.cpp b/utils/ncurses.cpp index c24902a..1976242 100644 --- a/utils/ncurses.cpp +++ b/utils/ncurses.cpp @@ -339,7 +339,7 @@ void CursesIntf::drawScoresRacks(WINDOW *win, int y, int x) const // Display a message when the search is complete if (m_game->getMode() == PublicGame::kTRAINING && - m_game->trainingGetResults().size()) + !m_game->trainingGetResults().isEmpty()) { mvwprintw(win, y + 2*yOff - 1, x + 2, _("Search complete")); }