aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/result
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2018-01-25 01:07:00 +0100
committerRenaud G <renaud@rolisteam.org>2018-01-25 01:07:00 +0100
commit7dc4bdca925a1999f7fcd2b052677ab1e2e43a4a (patch)
treed2f9fd84dbf104c31b2abecbb6a25d135b86a01a /result
parentb16ce0dfa892df424c133cc5b22b3dc4760ca303 (diff)
downloadOneRoll-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.cpp13
-rw-r--r--result/diceresult.h4
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: