aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/diceparser.cpp
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2015-04-21 10:43:08 +0200
committerRenaud G <renaud@rolisteam.org>2015-04-21 10:43:08 +0200
commit186af57e85671f0c9c4b2b1faf0d2065f4b0f222 (patch)
tree62b57859ac88fdd38519cffea7cd89fa02ab78c8 /diceparser.cpp
parent64048b3fd2dba4220cb19946caf588f9a6f26093 (diff)
downloadOneRoll-186af57e85671f0c9c4b2b1faf0d2065f4b0f222.tar.gz
OneRoll-186af57e85671f0c9c4b2b1faf0d2065f4b0f222.zip
prepare much better way to give the result
Diffstat (limited to 'diceparser.cpp')
-rw-r--r--diceparser.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/diceparser.cpp b/diceparser.cpp
index 6933071..a2fa137 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -400,10 +400,12 @@ QString DiceParser::getStringResult()
QString DiceParser::getLastDiceResult()
{
ExecutionNode* next = getLeafNode();
- QString str;
- QTextStream stream(&str);
+ // QString str;
+ // QTextStream stream(&str);
Result* result=next->getResult();
- QString dieValue("D%1 : {%2} ");
+ QMap<int,QString> diceValues;
+ //QString dieValue("%2 (D%1)");
+ bool first=true;
while(NULL!=result)
{
if(result->hasResultOfType(Result::DICE_LIST))
@@ -423,17 +425,16 @@ QString DiceParser::getLastDiceResult()
die->displayed();
face = die->getFaces();
-
if(die->hasChildrenValue())
{
- resulStr+=" [";
+ QString childDice("");
foreach(qint64 i, die->getListValue())
{
- resulStr+=QString("%1,").arg(i);
+ childDice+=QString("%1,").arg(i);
}
- resulStr.remove(resulStr.size()-1,1);
- resulStr+="]";
+ childDice.remove(childDice.size()-1,1);
+ resulStr+=QString("[%1]").arg(childDice);
}
resulStr+=", ";
}
@@ -442,7 +443,17 @@ QString DiceParser::getLastDiceResult()
if(!resulStr.isEmpty())
{
- stream << dieValue.arg(face).arg(resulStr);
+ if(!diceValues.contains(face))
+ {
+ diceValues.insert(face,resulStr);
+ }
+ else
+ {
+ QString tmp = diceValues.value(face);
+ tmp+=resulStr;
+ diceValues.insert(face,tmp);
+ }
+ //stream << dieValue.arg(face).arg(resulStr);
}
}
}
@@ -450,7 +461,8 @@ QString DiceParser::getLastDiceResult()
result = result->getPrevious();
}
- return str.simplified();
+ //return str.simplified();
+ return diceValues;
}
QString DiceParser::getDiceCommand()
{