From 6c0396515a8487b401e14a283fe61fb5bd134cb0 Mon Sep 17 00:00:00 2001 From: obiwankennedy Date: Wed, 22 Jan 2014 11:22:46 +0100 Subject: Update diceparser.cpp already displayed dice --- diceparser.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'diceparser.cpp') diff --git a/diceparser.cpp b/diceparser.cpp index e6b4d8f..c588dd4 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -35,11 +35,6 @@ DiceParser::DiceParser() m_aliasMap->insert("l5R","D10e10k"); m_aliasMap->insert("nwod","D10e10c[>7]"); m_aliasMap->insert("nwod","D10e10c[>7]"); - - - - - } ExecutionNode* DiceParser::getLatestNode(ExecutionNode* node) @@ -73,13 +68,13 @@ bool DiceParser::parseLine(QString str) ExecutionNode* current = getLatestNode(m_start); - qDebug() << "current" << current << " start"<< m_start << newNode; + keepParsing =!str.isEmpty(); if(keepParsing) { keepParsing = readOperator(str,current); - qDebug() << "2 current" << current << " start"<< m_start << newNode; + current = getLatestNode(current); } return true; @@ -169,35 +164,41 @@ void DiceParser::displayResult() quint64 face=0; foreach(Die* die, myDiceResult->getResultList()) { - resulStr+=QString("%1").arg(die->getValue()); - face = die->getFaces(); + if(!die->hasBeenDisplayed()) + { + resulStr+=QString("%1").arg(die->getValue()); + die->displayed(); + face = die->getFaces(); - if(die->hasChildrenValue()) - { - resulStr+=" ["; - foreach(qint64 i, die->getListValue()) + if(die->hasChildrenValue()) { + resulStr+=" ["; + foreach(qint64 i, die->getListValue()) + { - resulStr+=QString("%1 ").arg(i); + resulStr+=QString("%1 ").arg(i); + } + resulStr.remove(resulStr.size()-1,1); + resulStr+="]"; } - resulStr.remove(resulStr.size()-1,1); - resulStr+="]"; + resulStr+=", "; } - resulStr+=", "; - } resulStr.remove(resulStr.size()-2,2); - vectorDone = true; + if(!resulStr.isEmpty()) + { stream << dieValue.arg(face).arg(resulStr); + } } myResult = myResult->getPrevious(); } - qDebug() << str << "you rolled: " <