Hints: add missing logging

This commit is contained in:
Olivier Teulière 2013-03-30 19:23:59 +01:00
parent 7c7e26cc16
commit d897b05c52
2 changed files with 21 additions and 0 deletions

View file

@ -37,6 +37,13 @@
INIT_LOGGER(game, AbstractHint); INIT_LOGGER(game, AbstractHint);
INIT_LOGGER(game, ScoreHint);
INIT_LOGGER(game, OrientationHint);
INIT_LOGGER(game, PositionHint);
INIT_LOGGER(game, LengthHint);
INIT_LOGGER(game, BoardLettersHint);
INIT_LOGGER(game, WordLettersHint);
INIT_LOGGER(game, FirstLetterHint);
AbstractHint::AbstractHint(const string &iName, const string &iDescription, int iCost) AbstractHint::AbstractHint(const string &iName, const string &iDescription, int iCost)
@ -55,6 +62,7 @@ ScoreHint::ScoreHint()
string ScoreHint::giveHint(const Move &iMove) const string ScoreHint::giveHint(const Move &iMove) const
{ {
LOG_DEBUG("Getting hint for move: " << lfw(iMove.toString()));
return str(boost::format(_("Score: %1%")) % iMove.getScore()); return str(boost::format(_("Score: %1%")) % iMove.getScore());
} }
@ -69,6 +77,7 @@ OrientationHint::OrientationHint()
string OrientationHint::giveHint(const Move &iMove) const string OrientationHint::giveHint(const Move &iMove) const
{ {
LOG_DEBUG("Getting hint for move: " << lfw(iMove.toString()));
ASSERT(iMove.isValid(), "Hints only make sense for valid moves"); ASSERT(iMove.isValid(), "Hints only make sense for valid moves");
const Coord &coord = iMove.getRound().getCoord(); const Coord &coord = iMove.getRound().getCoord();
boost::format fmt(_("Orientation: %1%")); boost::format fmt(_("Orientation: %1%"));
@ -90,6 +99,7 @@ PositionHint::PositionHint()
string PositionHint::giveHint(const Move &iMove) const string PositionHint::giveHint(const Move &iMove) const
{ {
LOG_DEBUG("Getting hint for move: " << lfw(iMove.toString()));
ASSERT(iMove.isValid(), "Hints only make sense for valid moves"); ASSERT(iMove.isValid(), "Hints only make sense for valid moves");
return str(boost::format(_("Position: %1%")) return str(boost::format(_("Position: %1%"))
% lfw(iMove.getRound().getCoord().toString())); % lfw(iMove.getRound().getCoord().toString()));
@ -106,6 +116,7 @@ LengthHint::LengthHint()
string LengthHint::giveHint(const Move &iMove) const string LengthHint::giveHint(const Move &iMove) const
{ {
LOG_DEBUG("Getting hint for move: " << lfw(iMove.toString()));
ASSERT(iMove.isValid(), "Hints only make sense for valid moves"); ASSERT(iMove.isValid(), "Hints only make sense for valid moves");
return str(boost::format(_("Length: %1% letters")) return str(boost::format(_("Length: %1% letters"))
% iMove.getRound().getWordLen()); % iMove.getRound().getWordLen());
@ -122,6 +133,7 @@ BoardLettersHint::BoardLettersHint()
string BoardLettersHint::giveHint(const Move &iMove) const string BoardLettersHint::giveHint(const Move &iMove) const
{ {
LOG_DEBUG("Getting hint for move: " << lfw(iMove.toString()));
ASSERT(iMove.isValid(), "Hints only make sense for valid moves"); ASSERT(iMove.isValid(), "Hints only make sense for valid moves");
// Retrieve the letters coming from the board // Retrieve the letters coming from the board
wstring fromBoard; wstring fromBoard;
@ -146,6 +158,7 @@ WordLettersHint::WordLettersHint()
string WordLettersHint::giveHint(const Move &iMove) const string WordLettersHint::giveHint(const Move &iMove) const
{ {
LOG_DEBUG("Getting hint for move: " << lfw(iMove.toString()));
ASSERT(iMove.isValid(), "Hints only make sense for valid moves"); ASSERT(iMove.isValid(), "Hints only make sense for valid moves");
vector<Tile> tiles = iMove.getRound().getTiles(); vector<Tile> tiles = iMove.getRound().getTiles();
// Sort the letters (we cannot sort directly the wstring from // Sort the letters (we cannot sort directly the wstring from
@ -174,6 +187,7 @@ FirstLetterHint::FirstLetterHint()
string FirstLetterHint::giveHint(const Move &iMove) const string FirstLetterHint::giveHint(const Move &iMove) const
{ {
LOG_DEBUG("Getting hint for move: " << lfw(iMove.toString()));
ASSERT(iMove.isValid(), "Hints only make sense for valid moves"); ASSERT(iMove.isValid(), "Hints only make sense for valid moves");
return str(boost::format(_("First letter: %1%")) return str(boost::format(_("First letter: %1%"))
% lfw(iMove.getRound().getTile(0).toChar())); % lfw(iMove.getRound().getTile(0).toChar()));

View file

@ -69,6 +69,7 @@ private:
*/ */
class ScoreHint : public AbstractHint class ScoreHint : public AbstractHint
{ {
DEFINE_LOGGER();
public: public:
ScoreHint(); ScoreHint();
virtual string giveHint(const Move &iMove) const; virtual string giveHint(const Move &iMove) const;
@ -80,6 +81,7 @@ public:
*/ */
class OrientationHint : public AbstractHint class OrientationHint : public AbstractHint
{ {
DEFINE_LOGGER();
public: public:
OrientationHint(); OrientationHint();
virtual string giveHint(const Move &iMove) const; virtual string giveHint(const Move &iMove) const;
@ -91,6 +93,7 @@ public:
*/ */
class PositionHint : public AbstractHint class PositionHint : public AbstractHint
{ {
DEFINE_LOGGER();
public: public:
PositionHint(); PositionHint();
virtual string giveHint(const Move &iMove) const; virtual string giveHint(const Move &iMove) const;
@ -102,6 +105,7 @@ public:
*/ */
class LengthHint : public AbstractHint class LengthHint : public AbstractHint
{ {
DEFINE_LOGGER();
public: public:
LengthHint(); LengthHint();
virtual string giveHint(const Move &iMove) const; virtual string giveHint(const Move &iMove) const;
@ -113,6 +117,7 @@ public:
*/ */
class BoardLettersHint : public AbstractHint class BoardLettersHint : public AbstractHint
{ {
DEFINE_LOGGER();
public: public:
BoardLettersHint(); BoardLettersHint();
virtual string giveHint(const Move &iMove) const; virtual string giveHint(const Move &iMove) const;
@ -124,6 +129,7 @@ public:
*/ */
class WordLettersHint : public AbstractHint class WordLettersHint : public AbstractHint
{ {
DEFINE_LOGGER();
public: public:
WordLettersHint(); WordLettersHint();
virtual string giveHint(const Move &iMove) const; virtual string giveHint(const Move &iMove) const;
@ -135,6 +141,7 @@ public:
*/ */
class FirstLetterHint : public AbstractHint class FirstLetterHint : public AbstractHint
{ {
DEFINE_LOGGER();
public: public:
FirstLetterHint(); FirstLetterHint();
virtual string giveHint(const Move &iMove) const; virtual string giveHint(const Move &iMove) const;