aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cli
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2018-11-11 17:38:53 +0100
committerRenaud G <renaud@rolisteam.org>2018-11-11 17:38:53 +0100
commit750cc31e9157bf92f54a66b8a076e5287c4cef3a (patch)
tree8931522a6b82cf82f997029ef76608243a27e904 /cli
parentbd4a0c837bd5e3b4dbf9d3dcef892850d04ec6ac (diff)
parent1d8bd391b1df4fd2f2f274828db14c9ce695eb8b (diff)
downloadOneRoll-750cc31e9157bf92f54a66b8a076e5287c4cef3a.tar.gz
OneRoll-750cc31e9157bf92f54a66b8a076e5287c4cef3a.zip
Merge branch 'diceResult'
Diffstat (limited to 'cli')
-rw-r--r--cli/main.cpp44
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;
}