aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/diceparser.cpp
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2015-05-09 11:52:56 +0200
committerRenaud G <renaud@rolisteam.org>2015-05-09 11:52:56 +0200
commitb79df1fffd6677a584d6ad8ed44004aae0dad7b4 (patch)
tree2f9a8ceb8a8bb9272baf29e9539a8b67dcf0a1c3 /diceparser.cpp
parente844799045b0b3a4d8a968e011c96c10003d4256 (diff)
parentdba610b6f1a31f8791fbc9baa6cf360bf62c72e9 (diff)
downloadOneRoll-b79df1fffd6677a584d6ad8ed44004aae0dad7b4.tar.gz
OneRoll-b79df1fffd6677a584d6ad8ed44004aae0dad7b4.zip
Merge branch 'master' of github.com:obiwankennedy/DiceParser
Diffstat (limited to 'diceparser.cpp')
-rw-r--r--diceparser.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/diceparser.cpp b/diceparser.cpp
index ebe2e0e..1046ade 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -70,10 +70,9 @@ DiceParser::DiceParser()
m_nodeActionMap = new QMap<QString,NodeAction>();
m_nodeActionMap->insert("@",JumpBackward);
-
- m_commandList = new QStringList();
- m_commandList->append(QObject::tr("help"));
- m_commandList->append(QObject::tr("la"));
+ m_commandList = new QStringList();
+ m_commandList->append("help");
+ m_commandList->append("la");
}
DiceParser::~DiceParser()
@@ -152,12 +151,12 @@ bool DiceParser::parseLine(QString str)
delete m_start;
m_start = NULL;
}
- m_command = str;
m_start = new StartingNode();
ExecutionNode* newNode = NULL;
m_current = m_start;
str = convertAlias(str);
+ m_command = str;
bool keepParsing = readExpression(str,newNode);
if(keepParsing)
@@ -203,11 +202,8 @@ bool DiceParser::readExpression(QString& str,ExecutionNode* & node)
{
parentheseNode->setNextNode(diceNode);
}
-
return true;
}
-
-
}
}
else if(readOperand(str,operandNode))
@@ -527,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))
@@ -553,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])"));
}
}