diff options
| author | 2016-11-03 17:36:21 +0100 | |
|---|---|---|
| committer | 2016-11-03 17:36:21 +0100 | |
| commit | 9d389e561339e4fd7a68d60f593ad233e3941d13 (patch) | |
| tree | 39e98d9d3a612be9c6cf449f5a7a5dfdf4593865 /node/filternode.cpp | |
| parent | 120add8ca2f3a7e075b415a611bcd09034bd6200 (diff) | |
| download | OneRoll-9d389e561339e4fd7a68d60f593ad233e3941d13.tar.gz OneRoll-9d389e561339e4fd7a68d60f593ad233e3941d13.zip | |
-Add FilterNode to dice system.
Diffstat (limited to 'node/filternode.cpp')
| -rw-r--r-- | node/filternode.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/node/filternode.cpp b/node/filternode.cpp index 433f3c7..8fe99c3 100644 --- a/node/filternode.cpp +++ b/node/filternode.cpp @@ -1,6 +1,76 @@ #include "filternode.h" FilterNode::FilterNode() + : m_diceResult(new DiceResult()),m_eachValue(false) { + m_result = m_diceResult; +} + +FilterNode::~FilterNode() +{ + if(NULL!=m_validator) + { + delete m_validator; + } +} +void FilterNode::setValidator(Validator* validator) +{ + m_validator = validator; +} +void FilterNode::run(ExecutionNode* previous) +{ + m_previousNode = previous; + if(NULL==previous) + { + return; + } + DiceResult* previousDiceResult = static_cast<DiceResult*>(previous->getResult()); + m_result->setPrevious(previousDiceResult); + if(NULL!=previousDiceResult) + { + QList<Die*> diceList=previousDiceResult->getResultList(); + QList<Die*> diceList2; + + + for(Die* tmp : diceList) + { + if(m_validator->hasValid(tmp,m_eachValue)) + { + diceList2.append(tmp); + } + else + { + tmp->setHighlighted(false); + } + } + + m_diceResult->setResultList(diceList2); + if(NULL!=m_nextNode) + { + m_nextNode->run(this); + } + } +} + +QString FilterNode::toString(bool wl) const +{ + if(wl) + { + return QString("%1 [label=\"FilterNode\"]").arg(m_id); + } + else + { + return m_id; + } +} +qint64 FilterNode::getPriority() const +{ + qint64 priority=0; + if(NULL!=m_nextNode) + { + priority = m_nextNode->getPriority(); + } + + return priority; } |