aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--cli/main.cpp40
-rw-r--r--diceparser.cpp14
2 files changed, 52 insertions, 2 deletions
diff --git a/cli/main.cpp b/cli/main.cpp
index dee3d05..30b05a3 100644
--- a/cli/main.cpp
+++ b/cli/main.cpp
@@ -242,6 +242,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,7 +263,41 @@ 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;
@@ -277,6 +312,11 @@ int startDiceParsing(QStringList& cmds,QString& treeFile,bool withColor, EXPORTF
stringResult.replace(QStringLiteral("$%1").arg(i),(*it));
--i;
}
+ for(auto it = strLst.rbegin(); it != strLst.rend() ; ++it)
+ {
+ stringResult.replace(QStringLiteral("µ%1").arg(i),(*it));
+ --i;
+ }
resultStr = stringResult;
}
diff --git a/diceparser.cpp b/diceparser.cpp
index 41a91e5..0d41f4d 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -494,19 +494,23 @@ QStringList DiceParser::getAllDiceResult(bool& hasAlias)
}
void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList,bool& homogeneous)
{
+ int i = 0;
for(auto start : m_startNodes)
{
ExportedDiceResult diceValues;
ExecutionNode* next = getLeafNode(start);
Result* result=next->getResult();
-
+ qDebug() << "tour:"<<i++;
while(nullptr!=result)
{
+ qDebug()<< "result is not null"<<i;
if(result->hasResultOfType(Result::DICE_LIST))
{
+ qDebug() << "has diceresult"<<i;
DiceResult* diceResult = dynamic_cast<DiceResult*>(result);
if(nullptr!=diceResult)
{
+ qDebug() << "cast diceresult";
if(homogeneous)
{
@@ -516,8 +520,9 @@ void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList,boo
ListDiceResult listpair;
for(Die* die : diceResult->getResultList())
{
- if(!die->hasBeenDisplayed())
+ // if(!die->hasBeenDisplayed())
{
+ qDebug() << "dice has NOT been displayed";
QList<qint64> valuesResult;
valuesResult.append(die->getValue());
die->displayed();
@@ -533,9 +538,14 @@ void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList,boo
//QPair<QList<quint64>,bool> pair(valuesResult,die->isHighlighted());
listpair.append(hlDice);
}
+ // else
+ {
+ qDebug() << "dice has been displayed";
+ }
}
if(!listpair.isEmpty())
{
+ qDebug() << "list pair not empty ";
if(!diceValues.contains(face))
{
diceValues.insert(face,listpair);