mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-11-17 07:48:27 +01:00
Display the word being played on the board
This commit is contained in:
parent
2c3cb83e0a
commit
fb8e464d7c
8 changed files with 28 additions and 23 deletions
|
@ -270,7 +270,7 @@ int Board::checkRoundAux(const Matrix<Tile> &iTilesMx,
|
|||
const Matrix<Cross> &iCrossMx,
|
||||
const Matrix<int> &iPointsMx,
|
||||
const Matrix<bool> &iJokerMx,
|
||||
Round &iRound) const
|
||||
Round &iRound, bool checkJunction) const
|
||||
{
|
||||
bool isolated = true;
|
||||
|
||||
|
@ -340,7 +340,8 @@ int Board::checkRoundAux(const Matrix<Tile> &iTilesMx,
|
|||
else
|
||||
{
|
||||
// The letter is not in the crosscheck
|
||||
return 3;
|
||||
if (checkJunction)
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -356,7 +357,7 @@ int Board::checkRoundAux(const Matrix<Tile> &iTilesMx,
|
|||
|
||||
// The word must cover at least one anchor square, except
|
||||
// for the first turn
|
||||
if (isolated && !m_isEmpty)
|
||||
if (checkJunction && isolated && !m_isEmpty)
|
||||
return 5;
|
||||
// The first word must be horizontal
|
||||
// Deactivated, as a vertical first word is allowed in free games,
|
||||
|
@ -366,7 +367,7 @@ int Board::checkRoundAux(const Matrix<Tile> &iTilesMx,
|
|||
return 6;
|
||||
#endif
|
||||
// The first word must cover the H8 square
|
||||
if (m_isEmpty
|
||||
if (checkJunction && m_isEmpty
|
||||
&& (row != 8 || col > 8 || col + iRound.getWordLen() <= 8))
|
||||
{
|
||||
return 7;
|
||||
|
@ -385,12 +386,12 @@ int Board::checkRoundAux(const Matrix<Tile> &iTilesMx,
|
|||
}
|
||||
|
||||
|
||||
int Board::checkRound(Round &iRound) const
|
||||
int Board::checkRound(Round &iRound, bool checkJunction) const
|
||||
{
|
||||
if (iRound.getCoord().getDir() == Coord::HORIZONTAL)
|
||||
{
|
||||
return checkRoundAux(m_tilesRow, m_crossRow,
|
||||
m_pointRow, m_jokerRow, iRound);
|
||||
m_pointRow, m_jokerRow, iRound, checkJunction);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -399,7 +400,7 @@ int Board::checkRound(Round &iRound) const
|
|||
iRound.accessCoord().swap();
|
||||
|
||||
int res = checkRoundAux(m_tilesCol, m_crossCol,
|
||||
m_pointCol, m_jokerCol, iRound);
|
||||
m_pointCol, m_jokerCol, iRound, checkJunction);
|
||||
|
||||
// Restore the coordinates
|
||||
iRound.accessCoord().swap();
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
|
||||
void addRound(const Dictionary &iDic, const Round &iRound);
|
||||
void removeRound(const Dictionary &iDic, const Round &iRound);
|
||||
int checkRound(Round &iRound) const;
|
||||
int checkRound(Round &iRound, bool checkJunction = true) const;
|
||||
|
||||
/**
|
||||
* Preview
|
||||
|
@ -121,7 +121,8 @@ private:
|
|||
const Matrix<Cross> &iCrossMx,
|
||||
const Matrix<int> &iPointsMx,
|
||||
const Matrix<bool> &iJokerMx,
|
||||
Round &iRound) const;
|
||||
Round &iRound,
|
||||
bool checkJunction) const;
|
||||
#ifdef DEBUG
|
||||
void checkDouble();
|
||||
#endif
|
||||
|
|
|
@ -526,7 +526,8 @@ void Game::nextPlayer()
|
|||
|
||||
int Game::checkPlayedWord(const wstring &iCoord,
|
||||
const wstring &iWord,
|
||||
Move &oMove, bool checkRack) const
|
||||
Move &oMove, bool checkRack,
|
||||
bool checkWordAndJunction) const
|
||||
{
|
||||
ASSERT(getNPlayers() != 0, "Expected at least one player");
|
||||
|
||||
|
@ -546,7 +547,7 @@ int Game::checkPlayedWord(const wstring &iCoord,
|
|||
}
|
||||
|
||||
// Check the existence of the word
|
||||
if (!getDic().searchWord(iWord))
|
||||
if (checkWordAndJunction && !getDic().searchWord(iWord))
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
@ -564,11 +565,11 @@ int Game::checkPlayedWord(const wstring &iCoord,
|
|||
|
||||
// Check the word position, compute its points,
|
||||
// and specify the origin of each letter (board or rack)
|
||||
int res = m_board.checkRound(round);
|
||||
int res = m_board.checkRound(round, checkWordAndJunction);
|
||||
if (res != 0)
|
||||
return res + 4;
|
||||
// In duplicate mode, the first word must be horizontal
|
||||
if (m_board.isVacant(8, 8) &&
|
||||
if (checkWordAndJunction && m_board.isVacant(8, 8) &&
|
||||
(getMode() == GameParams::kDUPLICATE ||
|
||||
getMode() == GameParams::kARBITRATION))
|
||||
{
|
||||
|
|
|
@ -180,7 +180,8 @@ public:
|
|||
int checkPlayedWord(const wstring &iCoord,
|
||||
const wstring &iWord,
|
||||
Move &oMove,
|
||||
bool checkRack = true) const;
|
||||
bool checkRack = true,
|
||||
bool checkWordAndJunction = true) const;
|
||||
|
||||
private:
|
||||
/// Game characteristics
|
||||
|
|
|
@ -161,7 +161,7 @@ int PublicGame::play(const wstring &iWord, const wstring &iCoord)
|
|||
|
||||
int PublicGame::checkPlayedWord(const wstring &iWord, const wstring &iCoord, Move &oMove) const
|
||||
{
|
||||
return m_game.checkPlayedWord(iCoord, iWord, oMove, true);
|
||||
return m_game.checkPlayedWord(iCoord, iWord, oMove, true, false);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -159,6 +159,7 @@ public:
|
|||
int play(const wstring &iWord, const wstring &iCoord);
|
||||
|
||||
// TODO: doc
|
||||
// Ignores the word validity and connexion with the rest
|
||||
int checkPlayedWord(const wstring &iWord, const wstring &iCoord,
|
||||
Move &oMove) const;
|
||||
|
||||
|
|
|
@ -54,11 +54,11 @@ PlayWordMediator::PlayWordMediator(QObject *parent, QLineEdit &iEditPlay,
|
|||
|
||||
// Set all the connections
|
||||
QObject::connect(&m_lineEditPlay, SIGNAL(textChanged(const QString&)),
|
||||
this, SLOT(onWordChanged(const QString&)));
|
||||
this, SLOT(onWordChanged()));
|
||||
QObject::connect(&m_lineEditPlay, SIGNAL(returnPressed()),
|
||||
this, SLOT(playWord()));
|
||||
QObject::connect(&m_lineEditCoord, SIGNAL(textChanged(const QString&)),
|
||||
this, SLOT(onCoordChanged(const QString&)));
|
||||
this, SLOT(onCoordChanged()));
|
||||
QObject::connect(&m_lineEditCoord, SIGNAL(returnPressed()),
|
||||
this, SLOT(playWord()));
|
||||
QObject::connect(&m_pushButtonPlay, SIGNAL(clicked()),
|
||||
|
@ -212,15 +212,15 @@ void PlayWordMediator::playWord()
|
|||
}
|
||||
|
||||
|
||||
void PlayWordMediator::onCoordChanged(const QString &iText)
|
||||
void PlayWordMediator::onCoordChanged()
|
||||
{
|
||||
Coord coord(wfq(iText));
|
||||
Coord coord(wfq(m_lineEditCoord.text()));
|
||||
m_playModel.setCoord(coord);
|
||||
updatePointsAndState();
|
||||
onWordChanged();
|
||||
}
|
||||
|
||||
|
||||
void PlayWordMediator::onWordChanged(const QString &iText)
|
||||
void PlayWordMediator::onWordChanged()
|
||||
{
|
||||
wstring playedWord;
|
||||
GetPlayedWord(m_lineEditPlay, m_game->getDic(), &playedWord, NULL);
|
||||
|
|
|
@ -90,8 +90,8 @@ signals:
|
|||
private slots:
|
||||
void playWord();
|
||||
void updatePointsAndState();
|
||||
void onCoordChanged(const QString &iText);
|
||||
void onWordChanged(const QString &iText);
|
||||
void onCoordChanged();
|
||||
void onWordChanged();
|
||||
void updateCoord(const Coord &iNewCoord);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue