diff options
| author | 2018-12-08 21:14:43 +0100 | |
|---|---|---|
| committer | 2018-12-08 21:14:43 +0100 | |
| commit | bb47c33763d250cc424216a1dd0fedefa80532a3 (patch) | |
| tree | 3e60a84a8cd963d828299d49256ed6cd7c1bdd6f /cli | |
| parent | b28b096d2fe3ddfed099ee8cc33c8caa504d7c83 (diff) | |
| parent | 48de810db56b728726ec8b499b9a12c687b53795 (diff) | |
| download | OneRoll-bb47c33763d250cc424216a1dd0fedefa80532a3.tar.gz OneRoll-bb47c33763d250cc424216a1dd0fedefa80532a3.zip | |
Merge branch 'master' of github.com:Rolisteam/DiceParser
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/main.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cli/main.cpp b/cli/main.cpp index dee3d05..7cf2b7b 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -232,8 +232,10 @@ int startDiceParsing(QStringList& cmds,QString& treeFile,bool withColor, EXPORTF { parser.start(); QList<ExportedDiceResult> list; + QList<ExportedDiceResult> listFull; bool homogeneous = true; parser.getLastDiceResult(list,homogeneous); + parser.getDiceResultFromAllInstruction(listFull); bool allSameFaceCount, allSameColor; auto array = DisplayToolBox::diceToJson(list,allSameFaceCount,allSameColor); QString resultStr; @@ -242,6 +244,7 @@ int startDiceParsing(QStringList& cmds,QString& treeFile,bool withColor, EXPORTF QString comment = parser.getComment(); QString error = parser.humanReadableError(); QStringList strLst; + QStringList listOfDiceResult; if(parser.hasIntegerResultNotInFirst()) { @@ -262,13 +265,48 @@ int startDiceParsing(QStringList& cmds,QString& treeFile,bool withColor, EXPORTF } scalarText = QString("%1").arg(strLst.join(',')); } + if(!list.isEmpty()) + { + qDebug() << "list is not empty" << list.size(); + for(auto map : list) + { + qDebug() << "loop map"<< map.size(); + for(auto key : map.keys()) + { + qDebug() << "key: "<<key; + auto dice = map[key]; + QString stringVal; + for(auto val : dice) + { + qint64 total=0; + QStringList dicelist; + for(auto score: val.getResult()) + { + total += score; + dicelist << QString::number(score); + } + if(val.getResult().size() > 1) + { + stringVal=QString("%1 [%2]").arg(total).arg(dicelist.join(',')); + listOfDiceResult << stringVal; + } + else + { + listOfDiceResult << QString::number(total); + } + } + } + } + } + qDebug() << listOfDiceResult; if(parser.hasStringResult()) { bool ok; QStringList allStringlist = parser.getAllStringResult(ok); QString stringResult = allStringlist.join(" ; "); stringResult.replace("%1",scalarText); + resultStr.replace("%2",diceList.trimmed()); stringResult.replace("%3",lastScalarText); int i = strLst.size(); @@ -277,6 +315,12 @@ int startDiceParsing(QStringList& cmds,QString& treeFile,bool withColor, EXPORTF stringResult.replace(QStringLiteral("$%1").arg(i),(*it)); --i; } + i = listFull.size(); + for(auto it = strLst.rbegin(); it != strLst.rend() ; ++it) + { + stringResult.replace(QStringLiteral("µ%1").arg(i),(*it)); + --i; + } resultStr = stringResult; } |