Improved error messages when changing letters and/or passing

This commit is contained in:
Olivier Teulière 2011-01-10 22:06:10 +00:00
parent cadc14e8aa
commit 6f4c575eb6
2 changed files with 26 additions and 18 deletions

View file

@ -146,50 +146,49 @@ void PlayWordMediator::lineEditPlay_returnPressed()
else
{
// Try to be as explicit as possible concerning the error
QString msg = _q("Cannot play '%1' at position '%2':\n")
QString msg = _q("Cannot play '%1' at position '%2':\n%3")
.arg(m_lineEditPlay.text()).arg(coords);
switch (res)
{
case 1:
msg += _q("Some letters are not valid for the current dictionary");
msg = msg.arg(_q("Some letters are not valid for the current dictionary"));
break;
case 2:
msg += _q("Invalid coordinates");
msg = msg.arg(_q("Invalid coordinates"));
break;
case 3:
msg += _q("The word does not exist");
msg = msg.arg(_q("The word does not exist"));
break;
case 4:
msg += _q("The rack doesn't contain the letters needed to play this word");
msg = msg.arg(_q("The rack doesn't contain the letters needed to play this word"));
break;
case 5:
msg += _q("The word is part of a longer one");
msg = msg.arg(_q("The word is part of a longer one"));
break;
case 6:
msg += _q("The word tries to replace an existing letter");
msg = msg.arg(_q("The word tries to replace an existing letter"));
break;
case 7:
msg += _q("An orthogonal word is not valid");
msg = msg.arg(_q("An orthogonal word is not valid"));
break;
case 8:
msg += _q("The word is already present on the board at these coordinates");
msg = msg.arg(_q("The word is already present on the board at these coordinates"));
break;
case 9:
msg += _q("A word cannot be isolated (not connected to the placed words)");
msg = msg.arg(_q("A word cannot be isolated (not connected to the placed words)"));
break;
case 10:
msg += _q("The first word of the game must be horizontal");
msg = msg.arg(_q("The first word of the game must be horizontal"));
break;
case 11:
msg += _q("The first word of the game must cover the H8 square");
msg = msg.arg(_q("The first word of the game must cover the H8 square"));
break;
case 12:
msg += _q("The word is going out of the board");
msg = msg.arg(_q("The word is going out of the board"));
break;
default:
msg += _q("Incorrect or misplaced word (%1)").arg(1);
msg = msg.arg(_q("Incorrect or misplaced word"));
}
// FIXME: the error is too generic
emit notifyProblem(msg);
}
}

View file

@ -159,12 +159,21 @@ void PlayerWidget::on_lineEditChange_returnPressed()
emit gameUpdated();
else
{
// FIXME: the error is too generic
QString msg;
if (inputLetters == "")
msg = _q("Cannot pass turn (%1)").arg(res);
msg = _q("Cannot pass turn:\n%1");
else
msg = _q("Cannot change letters '%1' (%2)").arg(inputLetters).arg(res);
msg = _q("Cannot change letters '%1':\n%2").arg(inputLetters);
if (res == 1)
msg = msg.arg(_q("Changing letters is not allowed when there are less than 7 tiles left in the bag"));
else if (res == 2)
msg = msg.arg(_q("The rack of the current player does not contain all the listed letters"));
else if (res == 3)
msg = msg.arg(_q("The game is already finished!"));
else if (res == 3)
msg = msg.arg(_q("Some letters are invalid for the current dictionary"));
else
msg = msg.arg(_q("Unknwon error"));
emit notifyProblem(msg);
}
}