aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--diceparser.cpp14
-rw-r--r--highlightdice.cpp17
2 files changed, 24 insertions, 7 deletions
diff --git a/diceparser.cpp b/diceparser.cpp
index e78700b..aeb367e 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -212,6 +212,7 @@ void DiceParser::getDiceResultFromAllInstruction(QList<ExportedDiceResult>& resu
ExecutionNode* next= ParsingToolBox::getLeafNode(start);
Result* result= next->getResult();
ExportedDiceResult nodeResult;
+ QSet<QString> alreadyAdded;
while(nullptr != result)
{
if(result->hasResultOfType(Dice::RESULT_TYPE::DICE_LIST))
@@ -223,12 +224,19 @@ void DiceParser::getDiceResultFromAllInstruction(QList<ExportedDiceResult>& resu
for(auto& die : diceResult->getResultList())
{
faces= die->getFaces();
- // qDebug() << "face" << faces;
+ // qDebug() << "face" << faces << die->getValue() <<
+ // die->getListValue()
+ // << next->toString(true);
HighLightDice hlDice(die->getListValue(), die->isHighlighted(), die->getColor(),
die->hasBeenDisplayed(), die->getFaces());
- list.append(hlDice);
+ if(!alreadyAdded.contains(die->getUuid()))
+ {
+ list.append(hlDice);
+ alreadyAdded.insert(die->getUuid());
+ }
}
- nodeResult.insert(faces, list);
+ if(!list.isEmpty())
+ nodeResult.insert(faces, list);
}
result= result->getPrevious();
}
diff --git a/highlightdice.cpp b/highlightdice.cpp
index 58d9eec..d180a8d 100644
--- a/highlightdice.cpp
+++ b/highlightdice.cpp
@@ -78,8 +78,17 @@ void HighLightDice::setFaces(const quint64& faces)
QString HighLightDice::getResultString() const
{
- QStringList list;
- std::transform(std::begin(m_result), std::end(m_result), std::back_inserter(list),
- [](qint64 value) { return QString::number(value); });
- return list.join(",");
+ if(m_result.size() == 1)
+ {
+ return QString::number(m_result.first());
+ }
+ else
+ {
+ QStringList list;
+ std::transform(std::begin(m_result), std::end(m_result), std::back_inserter(list),
+ [](qint64 value) { return QString::number(value); });
+
+ auto totalScore= std::accumulate(std::begin(m_result), std::end(m_result), 0);
+ return QStringLiteral("%2 [%1]").arg(list.join(",")).arg(totalScore);
+ }
}