diff options
| author | 2017-02-28 18:58:12 +0100 | |
|---|---|---|
| committer | 2017-02-28 18:58:12 +0100 | |
| commit | 49e3f9a3a7acba5db5ea415e4487c3d200d26454 (patch) | |
| tree | a8d0d39c3c5a15967795e2b2597ebf44fcd009f9 | |
| parent | 527011e141ea8022a2bb41a52ef64fbb6cac0cfe (diff) | |
| download | OneRoll-49e3f9a3a7acba5db5ea415e4487c3d200d26454.tar.gz OneRoll-49e3f9a3a7acba5db5ea415e4487c3d200d26454.zip | |
-Add : compare operator to ask the if operator to compare the scalar
result.
| -rw-r--r-- | node/ifnode.cpp | 40 | ||||
| -rw-r--r-- | node/ifnode.h | 2 | ||||
| -rw-r--r-- | parsingtoolbox.cpp | 5 |
3 files changed, 27 insertions, 20 deletions
diff --git a/node/ifnode.cpp b/node/ifnode.cpp index 27b588f..91ad199 100644 --- a/node/ifnode.cpp +++ b/node/ifnode.cpp @@ -81,7 +81,7 @@ void IfNode::run(ExecutionNode *previous) } } } - else + else if((m_conditionType == OneOfThem)||(m_conditionType == AllOfThem)) { bool trueForAll=true; bool falseForAll=true; @@ -133,28 +133,30 @@ void IfNode::run(ExecutionNode *previous) } } } + } + + if(m_conditionType == OnScalar) + { + Die* dice = new Die(); + dice->setValue(value); + dice->insertRollValue(value); + dice->setMaxValue(value); + if(m_validator->hasValid(dice,true,true)) + { + nextNode=m_true; + } else { - Die* dice = new Die(); - dice->setValue(value); - dice->setMaxValue(value); - if(m_validator->hasValid(dice,true,true)) - { - nextNode=m_true; - } - else - { - nextNode=m_false; - } - if(NULL!=nextNode) + nextNode=m_false; + } + if(NULL!=nextNode) + { + if(NULL==m_nextNode) { - if(NULL==m_nextNode) - { - m_nextNode = nextNode; - } - nextNode->run(previousLoop); - previousLoop = getLeafNode(nextNode); + m_nextNode = nextNode; } + nextNode->run(previousLoop); + previousLoop = getLeafNode(nextNode); } } } diff --git a/node/ifnode.h b/node/ifnode.h index da8bb0b..7376101 100644 --- a/node/ifnode.h +++ b/node/ifnode.h @@ -34,7 +34,7 @@ public: /** * @brief The ConditionType enum */ - enum ConditionType {OnEach,OneOfThem,AllOfThem}; + enum ConditionType {OnEach,OneOfThem,AllOfThem,OnScalar}; /** * @brief IfNode */ diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp index 3d2d2c3..1e8819c 100644 --- a/parsingtoolbox.cpp +++ b/parsingtoolbox.cpp @@ -213,6 +213,11 @@ IfNode::ConditionType ParsingToolBox::readConditionType(QString& str) str=str.remove(0,1); type = IfNode::AllOfThem; } + else if(str.startsWith(':')) + { + str=str.remove(0,1); + type = IfNode::OnScalar; + } return type; } |