aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/diceparser.cpp
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2015-03-24 21:53:40 +0100
committerRenaud G <renaud@rolisteam.org>2015-03-24 21:53:40 +0100
commit7ed106bc79c222586279d4351db1c5f005b0b1f3 (patch)
treeff0efc466457d10431a85c3f23fc1a154dcdc26c /diceparser.cpp
parent24d48effb863e458c00dcb1bea1ad5aa82309599 (diff)
downloadOneRoll-7ed106bc79c222586279d4351db1c5f005b0b1f3.tar.gz
OneRoll-7ed106bc79c222586279d4351db1c5f005b0b1f3.zip
-Add listaliasnode to list all alias.
Diffstat (limited to 'diceparser.cpp')
-rw-r--r--diceparser.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/diceparser.cpp b/diceparser.cpp
index ea6dcc9..56fa72e 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -37,6 +37,7 @@
#include "node/helpnode.h"
#include "node/jumpbackwardnode.h"
#include "node/listsetrollnode.h"
+#include "node/listaliasnode.h"
#define DEFAULT_FACES_NUMBER 10
@@ -70,8 +71,9 @@ DiceParser::DiceParser()
m_nodeActionMap->insert("@",JumpBackward);
- m_commandList = new QList<QString>();
+ m_commandList = new QStringList();
m_commandList->append("help");
+ m_commandList->append("la");
}
@@ -126,8 +128,6 @@ bool DiceParser::parseLine(QString str)
bool DiceParser::readExpression(QString& str,ExecutionNode* & node)
{
- // int myNumber = 1;
- // bool hasReadNumber=false;
ExecutionNode* operandNode=NULL;
if(m_parsingToolbox->readOpenParentheses(str))
{
@@ -196,13 +196,6 @@ bool DiceParser::readExpression(QString& str,ExecutionNode* & node)
}
bool DiceParser::readNode(QString& str,ExecutionNode* & node)
{
- /*k case JumpBackward:
- {
- JumpBackwardNode* jumpNode = new JumpBackwardNode();
- previous->setNextNode(jumpNode);
- node = jumpNode;
- isFine=true;
- }*/
QString key= str.left(1);
if(m_nodeActionMap->contains(key))
{
@@ -231,7 +224,6 @@ QString DiceParser::displayResult()
next = next->getNextNode();
++nodeCount;
}
-// qDebug() << "node count"<< nodeCount;
//////////////////////////////////
//
// Display
@@ -277,7 +269,6 @@ QString DiceParser::displayResult()
resulStr+=" [";
foreach(qint64 i, die->getListValue())
{
-
resulStr+=QString("%1 ").arg(i);
}
resulStr.remove(resulStr.size()-1,1);
@@ -345,7 +336,6 @@ bool DiceParser::readDice(QString& str,ExecutionNode* & node)
QStringList list;
if(m_parsingToolbox->readList(str,list))
{
- qDebug() << list;
ListSetRollNode* lsrNode = new ListSetRollNode();
lsrNode->setListValue(list);
node = lsrNode;
@@ -376,7 +366,14 @@ bool DiceParser::readCommand(QString& str,ExecutionNode* & node)
{
if(m_commandList->contains(str))
{
- node = new HelpNode();
+ if(str=="help")
+ {
+ node = new HelpNode();
+ }
+ else if(str=="la")
+ {
+ node = new ListAliasNode(m_aliasMap);
+ }
return true;
}
return false;