diff options
| -rw-r--r-- | cli/main.cpp | 14 | ||||
| -rw-r--r-- | diceparser.cpp | 4 |
2 files changed, 15 insertions, 3 deletions
diff --git a/cli/main.cpp b/cli/main.cpp index 3de1d26..004e187 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -161,7 +161,7 @@ void displayMarkdown(QString scalarText, QString resultStr, QJsonArray array, bo } else if(!resultStr.isEmpty()) { - resultStr.replace("%2", diceList.trimmed()); + // resultStr.replace("%2", diceList.trimmed()); str.append(QStringLiteral("%1\n").arg(resultStr)); } } @@ -374,6 +374,15 @@ int startDiceParsing(QStringList& cmds, QString& treeFile, bool withColor, EXPOR if(sub.contains(ex)) resultWithPlaceHolder.append(sub); }); + + if(resultWithPlaceHolder.isEmpty()) + allStringlist.erase(std::remove_if(allStringlist.begin(), allStringlist.end(), + [](const QString& result) { + bool ok; + result.toInt(&ok); + return ok; + }), + allStringlist.end()); auto stringResult = resultWithPlaceHolder.isEmpty() ? allStringlist.join(" ; ") : resultWithPlaceHolder.join(" ; "); @@ -394,9 +403,10 @@ int startDiceParsing(QStringList& cmds, QString& treeFile, bool withColor, EXPOR stringResult.replace(QStringLiteral("µ%1").arg(i), (*it)); --i; } + bool isInt= true; stringResult.toInt(&isInt); - if(!isInt) + if(!isInt || !resultWithPlaceHolder.isEmpty()) resultStr= stringResult; } if(format == BOT) diff --git a/diceparser.cpp b/diceparser.cpp index 5c0590c..7adf610 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -368,11 +368,12 @@ bool DiceParser::hasResultOfType(Dice::RESULT_TYPE type, ExecutionNode* node, QV bool scalarDone= false; ExecutionNode* next= ParsingToolBox::getLeafNode(node); Result* result= next->getResult(); + int i= 0; while((result != nullptr) && (!scalarDone)) { bool lastResult= false; if(notthelast) - lastResult= (nullptr == result->getPrevious()); + lastResult= (nullptr == result->getPrevious() && i != 0); if(result->hasResultOfType(type) && !lastResult) { @@ -380,6 +381,7 @@ bool DiceParser::hasResultOfType(Dice::RESULT_TYPE type, ExecutionNode* node, QV value= result->getResult(type); } result= result->getPrevious(); + ++i; } return scalarDone; } |