diff options
| author | 2018-01-25 01:07:00 +0100 | |
|---|---|---|
| committer | 2018-01-25 01:07:00 +0100 | |
| commit | 7dc4bdca925a1999f7fcd2b052677ab1e2e43a4a (patch) | |
| tree | d2f9fd84dbf104c31b2abecbb6a25d135b86a01a /result | |
| parent | b16ce0dfa892df424c133cc5b22b3dc4760ca303 (diff) | |
| download | OneRoll-7dc4bdca925a1999f7fcd2b052677ab1e2e43a4a.tar.gz OneRoll-7dc4bdca925a1999f7fcd2b052677ab1e2e43a4a.zip | |
-Add API to know if dice is already inside the result.
Diffstat (limited to 'result')
| -rw-r--r-- | result/diceresult.cpp | 13 | ||||
| -rw-r--r-- | result/diceresult.h | 4 |
2 files changed, 12 insertions, 5 deletions
diff --git a/result/diceresult.cpp b/result/diceresult.cpp index ddedd1c..f9f8253 100644 --- a/result/diceresult.cpp +++ b/result/diceresult.cpp @@ -78,10 +78,17 @@ QVariant DiceResult::getResult(RESULT_TYPE type) return QVariant(); } -/*bool DiceResult::hasResultOfType(RESULT_TYPE type) const +bool DiceResult::contains(Die* die, const std::function<bool(const Die*,const Die*)> equal) { - return (m_resultTypes & type); -}*/ + for(auto value : m_diceValues) + { + if(equal(value,die)) + { + return true; + } + } + return false; +} qreal DiceResult::getScalarResult() { if(m_diceValues.size()==1) diff --git a/result/diceresult.h b/result/diceresult.h index 7eded95..ae16daf 100644 --- a/result/diceresult.h +++ b/result/diceresult.h @@ -76,8 +76,8 @@ public: void setHomogeneous(bool); Die::ArithmeticOperator getOperator() const; - void setOperator(const Die::ArithmeticOperator & dieOperator); - + void setOperator(const Die::ArithmeticOperator & dieOperator); + bool contains(Die *die, const std::function<bool (const Die *, const Die *)> equal); private: qreal getScalarResult(); private: |