From 9d389e561339e4fd7a68d60f593ad233e3941d13 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Thu, 3 Nov 2016 17:36:21 +0100 Subject: -Add FilterNode to dice system. --- node/filternode.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'node/filternode.cpp') 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(previous->getResult()); + m_result->setPrevious(previousDiceResult); + if(NULL!=previousDiceResult) + { + QList diceList=previousDiceResult->getResultList(); + QList 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; } -- cgit v1.2.3-70-g09d2