aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--diceparser.cpp32
-rw-r--r--die.cpp9
2 files changed, 31 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()
{
diff --git a/die.cpp b/die.cpp
index dc6576e..d8be064 100644
--- a/die.cpp
+++ b/die.cpp
@@ -132,3 +132,12 @@ void Die::displayed()
{
m_displayStatus = true;
}
+void Die::setHighlighted(bool a)
+{
+ m_highlighted = a;
+}
+
+bool Die::isHighlighted()
+{
+ return m_highlighted;
+}