diff options
| author | 2015-03-06 00:27:37 +0100 | |
|---|---|---|
| committer | 2015-03-06 00:27:37 +0100 | |
| commit | 24d48effb863e458c00dcb1bea1ad5aa82309599 (patch) | |
| tree | 0fdf055720469553c37329bb4cf2042d597aae1e /node | |
| parent | 3bae1f62ba10e60a8156523a5b0502cc1efafd6d (diff) | |
| download | OneRoll-24d48effb863e458c00dcb1bea1ad5aa82309599.tar.gz OneRoll-24d48effb863e458c00dcb1bea1ad5aa82309599.zip | |
-Add new node to roll die as value of list.
Diffstat (limited to 'node')
| -rw-r--r-- | node/listsetrollnode.cpp | 60 | ||||
| -rw-r--r-- | node/listsetrollnode.h | 19 |
2 files changed, 79 insertions, 0 deletions
diff --git a/node/listsetrollnode.cpp b/node/listsetrollnode.cpp index e89e139..3ab9a69 100644 --- a/node/listsetrollnode.cpp +++ b/node/listsetrollnode.cpp @@ -1,5 +1,65 @@ #include "listsetrollnode.h" +#include "die.h" ListSetRollNode::ListSetRollNode() + :m_diceResult(new DiceResult()),m_stringResult(new StringResult()) { + m_result = m_stringResult; +} + +QStringList ListSetRollNode::getList() +{ + return m_values; +} +QString ListSetRollNode::toString() const +{ + return QString("ListSetRollNode_").arg(m_values.join(',')); +} +qint64 ListSetRollNode::getPriority() const +{ + qint64 priority=4; +// if(NULL!=m_nextNode) +// { +// priority = m_nextNode->getPriority(); +// } + + + return priority; +} +void ListSetRollNode::run(ExecutionNode* previous) +{ + m_previousNode = previous; + if(NULL!=previous) + { + Result* result=previous->getResult(); + if(NULL!=result) + { + quint64 diceCount = result->getResult(Result::SCALAR).toReal(); + m_result->setPrevious(result); + QStringList rollResult; + for(quint64 i=0; i < diceCount ; ++i) + { + Die* die = new Die(); + die->setFaces(m_values.size()); + die->roll(); + m_diceResult->insertResult(die); + if(die->getValue()-1<m_values.size()) + { + rollResult << m_values[die->getValue()-1]; + } + } + m_stringResult->setText(rollResult.join(",")); + if(NULL!=m_nextNode) + { + m_nextNode->run(this); + } + } + } + + + +} +void ListSetRollNode::setListValue(QStringList lirs) +{ + m_values = lirs; } diff --git a/node/listsetrollnode.h b/node/listsetrollnode.h index 006557b..26fb378 100644 --- a/node/listsetrollnode.h +++ b/node/listsetrollnode.h @@ -1,10 +1,29 @@ #ifndef LISTSETROLLNODE_H #define LISTSETROLLNODE_H + +#include <QStringList> + +#include "executionnode.h" +#include "result/diceresult.h" +#include "result/stringresult.h" + class ListSetRollNode : public ExecutionNode { public: ListSetRollNode(); + virtual void run(ExecutionNode* previous = NULL); + virtual QString toString()const; + virtual qint64 getPriority() const; + QStringList getList(); + + void setListValue(QStringList); + +private: + QStringList m_values; + DiceResult* m_diceResult; + StringResult* m_stringResult; + }; #endif // LISTSETROLLNODE_H |