diff options
| -rw-r--r-- | diceparser.pri | 4 | ||||
| -rw-r--r-- | node/paintnode.cpp | 23 | ||||
| -rw-r--r-- | node/paintnode.h | 1 |
3 files changed, 20 insertions, 8 deletions
diff --git a/diceparser.pri b/diceparser.pri index 768fb7b..ef975a0 100644 --- a/diceparser.pri +++ b/diceparser.pri @@ -6,6 +6,7 @@ INCLUDEPATH += $$PWD SOURCES += $$PWD/diceparser.cpp \ $$PWD/result/diceresult.cpp \ $$PWD/range.cpp \ + $$PWD/highlightdice.cpp \ $$PWD/booleancondition.cpp \ $$PWD/validator.cpp \ $$PWD/die.cpp \ @@ -23,6 +24,7 @@ HEADERS += \ $$PWD/result/diceresult.h \ $$PWD/range.h \ $$PWD/booleancondition.h \ + $$PWD/highlightdice.h \ $$PWD/validator.h \ $$PWD/die.h \ $$PWD/result/result.h \ @@ -51,6 +53,7 @@ HEADERS += \ $$PWD/node/mergenode.h \ $$PWD/node/listaliasnode.h \ $$PWD/node/ifnode.h \ + $$PWD/node/paintnode.h \ $$PWD/node/listsetrollnode.h SOURCES += \ @@ -69,6 +72,7 @@ SOURCES += \ $$PWD/node/jumpbackwardnode.cpp \ $$PWD/node/mergenode.cpp \ $$PWD/node/listaliasnode.cpp \ + $$PWD/node/paintnode.cpp \ $$PWD/node/ifnode.cpp \ $$PWD/node/listsetrollnode.cpp diff --git a/node/paintnode.cpp b/node/paintnode.cpp index 19eeb7f..ad13c52 100644 --- a/node/paintnode.cpp +++ b/node/paintnode.cpp @@ -51,18 +51,20 @@ void ColorItem::setColor(const QString &color) /////////////////////////////////// PainterNode::PainterNode() + : ExecutionNode() { - + m_result = NULL; + m_nextNode = NULL; } PainterNode::~PainterNode() { - + m_result = NULL; } -void PainterNode::run(ExecutionNode *previous) +void PainterNode::run(ExecutionNode* previous) { m_previousNode = previous; if(NULL==previous) @@ -70,28 +72,33 @@ void PainterNode::run(ExecutionNode *previous) return; } Result* previousResult = previous->getResult(); - m_result = previousResult; + //m_result = previousResult; DiceResult* previousDiceResult = dynamic_cast<DiceResult*>(previousResult); if(NULL!=previousDiceResult) { - QList<Die*> diceList=previousDiceResult->getResultList(); + QList<Die*> diceList=previousDiceResult->getResultList(); + int pastDice=0; foreach(ColorItem item, m_colors) { int current=item.colorNumber(); QList<Die*>::iterator it; - for(it = diceList.begin(); it != diceList.end() && current>0 ; ++it) + for(it = diceList.begin()+pastDice; it != diceList.end() && current>0 ; ++it) { (*it)->setColor(item.color()); --current; + ++pastDice; } } } if(NULL!=m_nextNode) { - m_nextNode->run(this); + m_nextNode->run(previous); } } - +Result* PainterNode::getResult() +{ + m_previousNode->getResult(); +} QString PainterNode::toString(bool wl) const { diff --git a/node/paintnode.h b/node/paintnode.h index e01eaee..52a9ddb 100644 --- a/node/paintnode.h +++ b/node/paintnode.h @@ -47,6 +47,7 @@ public: PainterNode(); virtual ~PainterNode(); virtual void run(ExecutionNode* previous = NULL); + Result* getResult(); virtual QString toString(bool )const; virtual qint64 getPriority() const; void insertColorItem(QString color, int value); |