diff options
| author | 2022-04-29 10:48:09 +0200 | |
|---|---|---|
| committer | 2022-04-29 10:48:09 +0200 | |
| commit | 07c5f6ec23fcf9237a24e71adcfacabce677f818 (patch) | |
| tree | 588e8c5f82b9163181fad3581f610e6f1d88cba4 /node/explodedicenode.cpp | |
| parent | a9153f1615a842cfb9e9bcda4d9071e202618569 (diff) | |
| download | OneRoll-07c5f6ec23fcf9237a24e71adcfacabce677f818.tar.gz OneRoll-07c5f6ec23fcf9237a24e71adcfacabce677f818.zip | |
Change file organization.
Diffstat (limited to 'node/explodedicenode.cpp')
| -rw-r--r-- | node/explodedicenode.cpp | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/node/explodedicenode.cpp b/node/explodedicenode.cpp deleted file mode 100644 index 1546883..0000000 --- a/node/explodedicenode.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include "explodedicenode.h" -#include "validatorlist.h" - -ExplodeDiceNode::ExplodeDiceNode() : m_diceResult(new DiceResult()) -{ - m_result= m_diceResult; -} -void ExplodeDiceNode::run(ExecutionNode* previous) -{ - m_previousNode= previous; - if((nullptr != previous) && (nullptr != previous->getResult())) - { - DiceResult* previous_result= dynamic_cast<DiceResult*>(previous->getResult()); - m_result->setPrevious(previous_result); - if(nullptr != previous_result) - { - Die* exampleDie; - for(auto& die : previous_result->getResultList()) - { - Die* tmpdie= new Die(*die); - m_diceResult->insertResult(tmpdie); - die->displayed(); - exampleDie= tmpdie; - } - - // QList<Die*> list= m_diceResult->getResultList(); - - bool hasExploded= false; - std::function<void(Die*, qint64)> f= [&hasExploded, this](Die* die, qint64) { - if(Dice::CONDITION_STATE::ALWAYSTRUE - == m_validatorList->isValidRangeSize( - std::make_pair<qint64, qint64>(die->getBase(), die->getMaxValue()))) - { - m_errors.insert(Dice::ERROR_CODE::ENDLESS_LOOP_ERROR, - QObject::tr("Condition (%1) cause an endless loop with this dice: %2") - .arg(toString(true)) - .arg(QStringLiteral("d[%1,%2]") - .arg(static_cast<int>(die->getBase())) - .arg(static_cast<int>(die->getMaxValue())))); - } - hasExploded= true; - die->roll(true); - }; - do - { - hasExploded= false; - m_validatorList->validResult(m_diceResult, false, false, f); - } while(hasExploded); - - /*for(auto& die : list) - { - if(Dice::CONDITION_STATE::ALWAYSTRUE - == m_validatorList->isValidRangeSize( - std::make_pair<qint64, qint64>(die->getBase(), die->getMaxValue()))) - { - - continue; - } - - while(m_validatorList->hasValid(die, false)) - { - die->roll(true); - } - }*/ - - if(nullptr != m_nextNode) - { - m_nextNode->run(this); - } - } - } -} -ExplodeDiceNode::~ExplodeDiceNode() -{ - if(nullptr != m_validatorList) - { - delete m_validatorList; - } -} -void ExplodeDiceNode::setValidatorList(ValidatorList* val) -{ - m_validatorList= val; -} -QString ExplodeDiceNode::toString(bool withlabel) const -{ - if(withlabel) - { - return QString("%1 [label=\"ExplodeDiceNode %2\"]").arg(m_id, m_validatorList->toString()); - } - else - { - return m_id; - } -} -qint64 ExplodeDiceNode::getPriority() const -{ - qint64 priority= 0; - if(nullptr != m_previousNode) - { - priority= m_previousNode->getPriority(); - } - return priority; -} - -ExecutionNode* ExplodeDiceNode::getCopy() const -{ - ExplodeDiceNode* node= new ExplodeDiceNode(); - if(nullptr != m_validatorList) - { - node->setValidatorList(m_validatorList->getCopy()); - } - if(nullptr != m_nextNode) - { - node->setNextNode(m_nextNode->getCopy()); - } - return node; -} |