From bb97b0d51deaf01212caa08e504f55f4169ae80e Mon Sep 17 00:00:00 2001 From: obiwankennedy Date: Tue, 7 Jan 2014 16:38:14 +0100 Subject: Update diceparser.cpp add parse file! --- diceparser.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/diceparser.cpp b/diceparser.cpp index 81fc1e7..8e04dc2 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -63,7 +63,7 @@ void DiceParser::parseLine(QString str) while(keepParsing) { keepParsing = readOperator(str); - keepParsing = readOption(str); + //keepParsing = readOption(str); } m_start->run(); @@ -72,7 +72,45 @@ void DiceParser::parseLine(QString str) { next = next->getNextNode(); } - qDebug() << "list:" <getResult()->getResultList() << " sum:" <getResult()->getSum() << " command:" << command; + + + + + + ////////////////////////////////// + // + // Display + // + ////////////////////////////////// + + if(next->getResult()->isScalar()) + { + qDebug() << "you get " << next->getResult()->getScalar() << " and you roll:" << command; + } + else + { + DiceResult* myDiceResult = static_cast(next->getResult()); + if(NULL==myDiceResult) + { + + QString resulStr="{"; + foreach(Die die, myDiceResult->getResultList()) + { + resulStr="["; + foreach(qint64 i, die.getListValue()) + { + resulStr+=QString("%1,").arg(i); + } + resulStr+="]"; + } + resulStr.remove(resulStr.size()-1,1); + resulStr+="}"; + + + qDebug() << "you get " << resulStr << " and you roll:" << command; + } + } + //qDebug() << "list:" << << " sum:" << << " command:" << command; } bool DiceParser::readNumber(QString& str, int& myNumber) { @@ -150,6 +188,9 @@ bool DiceParser::readDiceExpression(QString& str,ExecutionNode* & node) node = numberNode; + while(readOption(str)); + + return true; } else if(hasRead) -- cgit v1.2.3-70-g09d2