From 4c8d5865e3426092fa4c4724d22b31759aba6412 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Wed, 6 May 2015 07:42:11 +0200 Subject: add error message with zero faces dices --- diceparser.cpp | 13 +++++++------ 1 file 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])")); } } -- cgit v1.2.3-70-g09d2