aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2015-05-06 07:42:11 +0200
committerRenaud G <renaud@rolisteam.org>2015-05-06 07:42:11 +0200
commit4c8d5865e3426092fa4c4724d22b31759aba6412 (patch)
tree6ba90c4a05fe40599a19e04b2983eac8cd082f37
parentbaeb8276c07014f875ac8a2f5d4ec6883684adb3 (diff)
downloadOneRoll-4c8d5865e3426092fa4c4724d22b31759aba6412.tar.gz
OneRoll-4c8d5865e3426092fa4c4724d22b31759aba6412.zip
add error message with zero faces dices
-rw-r--r--diceparser.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/diceparser.cpp b/diceparser.cpp
index 8f38fe7..5108a10 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -202,11 +202,8 @@ bool DiceParser::readExpression(QString& str,ExecutionNode* & node)
{
parentheseNode->setNextNode(diceNode);
}
-
return true;
}
-
-
}
}
else if(readOperand(str,operandNode))
@@ -526,9 +523,13 @@ bool DiceParser::readDice(QString& str,ExecutionNode* & node)
{
if(m_parsingToolbox->readNumber(str,num))
{
+ if(num<1)
+ {
+ m_errorMap.insert(ExecutionNode::BAD_SYNTAXE,QObject::tr("Dice with %1 face(s) does not exist. Please, put a value higher than 0").arg(num));
+ return false;
+ }
+ qDebug() << num;
DiceRollerNode* drNode = new DiceRollerNode(num);
- // dice.m_diceOp = myOperator;
- // dice.m_faces = num;
node = drNode;
ExecutionNode* current = drNode;
while(readOption(str,current))
@@ -552,7 +553,7 @@ bool DiceParser::readDice(QString& str,ExecutionNode* & node)
}
else
{
- m_errorMap.insert(ExecutionNode::BAD_SYNTAXE,QObject::tr("List is missing after the L operator. Please, add it (e.g : 1L[sword,spear,gun,arrow]"));
+ m_errorMap.insert(ExecutionNode::BAD_SYNTAXE,QObject::tr("List is missing after the L operator. Please, add it (e.g : 1L[sword,spear,gun,arrow])"));
}
}