From dcdc81cb8e2ce41beab6042f8b5044773f5229d0 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Fri, 20 Mar 2020 18:54:27 +0100 Subject: Show explode value in @ place holder. --- diceparser.cpp | 14 +++++++++++--- highlightdice.cpp | 17 +++++++++++++---- 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& resu ExecutionNode* next= ParsingToolBox::getLeafNode(start); Result* result= next->getResult(); ExportedDiceResult nodeResult; + QSet alreadyAdded; while(nullptr != result) { if(result->hasResultOfType(Dice::RESULT_TYPE::DICE_LIST)) @@ -223,12 +224,19 @@ void DiceParser::getDiceResultFromAllInstruction(QList& 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); + } } -- cgit v1.2.3-70-g09d2