diff options
| author | 2014-01-10 12:56:20 +0100 | |
|---|---|---|
| committer | 2014-01-10 12:56:20 +0100 | |
| commit | 78052519fae2ef7d1c04d5f2ded4612432c68ce9 (patch) | |
| tree | fa25ac738cb06e270e56869f6218906cf534cbaa /diceparser.cpp | |
| parent | be8415d8976fee460710613bcb3403a7f2028aa9 (diff) | |
| download | OneRoll-78052519fae2ef7d1c04d5f2ded4612432c68ce9.tar.gz OneRoll-78052519fae2ef7d1c04d5f2ded4612432c68ce9.zip | |
Update diceparser.cpp
allows operation after the second.
Diffstat (limited to 'diceparser.cpp')
| -rw-r--r-- | diceparser.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/diceparser.cpp b/diceparser.cpp index d2b163d..543c824 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -11,6 +11,7 @@ #include "node/sortresult.h" #include "node/countexecutenode.h" #include "node/rerolldicenode.h" +#include "node/explosedicenode.h" DiceParser::DiceParser() { @@ -23,6 +24,7 @@ DiceParser::DiceParser() m_OptionOp->insert(QObject::tr("s"),Sort); m_OptionOp->insert(QObject::tr("c"),Count); m_OptionOp->insert(QObject::tr("r"),Reroll); + m_OptionOp->insert(QObject::tr("e"),Explosing); @@ -66,7 +68,7 @@ void DiceParser::parseLine(QString str) keepParsing =!str.isEmpty(); while(keepParsing) { - keepParsing = readOperator(str); + keepParsing = readOperator(str,m_current); //keepParsing = readOption(str); } @@ -228,7 +230,7 @@ bool DiceParser::readDiceExpression(QString& str,ExecutionNode* & node) node = numberNode; return returnVal; } -bool DiceParser::readOperator(QString& str) +bool DiceParser::readOperator(QString& str,ExecutionNode* previous) { if(str.isEmpty()) { @@ -245,7 +247,8 @@ bool DiceParser::readOperator(QString& str) { node->setInternalNode(nodeExec); - //previous->setNextNode(node); + previous->setNextNode(node); + setCurrentNode(node); return true; @@ -331,6 +334,18 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous,DiceRollerNode* } break; + case Explosing: + { + Validator* validator = readValidator(str); + if(NULL!=validator) + { + ExploseDiceNode* explosedNode = new ExploseDiceNode(); + explosedNode->setValidator(validator); + previous->setNextNode(explosedNode); + node = explosedNode; + isFine = true; + } + } } } } @@ -370,10 +385,14 @@ Validator* DiceParser::readValidator(QString& str) int value=0; if(readNumber(str,value)) { + if(str.startsWith("]")) + { + str=str.remove(0,1); BooleanCondition* condition = new BooleanCondition(); condition->setValue(value); condition->setOperator(myLogicOp); returnVal = condition; + } } } |