aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/diceparser.h
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2013-12-29 02:04:19 +0100
committerRenaud G <renaud@rolisteam.org>2013-12-29 02:04:19 +0100
commitf30020384f816b498fe1f6013758a8de37811821 (patch)
tree7388de7fe766fe2973d94a3256f8820e3c7fbcdf /diceparser.h
parent7a1784893af6fe986503dc67672135ed05816579 (diff)
downloadOneRoll-f30020384f816b498fe1f6013758a8de37811821.tar.gz
OneRoll-f30020384f816b498fe1f6013758a8de37811821.zip
Firt commit of the new dice system for rolisteam.
Diffstat (limited to 'diceparser.h')
-rw-r--r--diceparser.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/diceparser.h b/diceparser.h
new file mode 100644
index 0000000..022f95e
--- /dev/null
+++ b/diceparser.h
@@ -0,0 +1,41 @@
+#ifndef DICEPARSER_H
+#define DICEPARSER_H
+
+#include <QString>
+#include <QMap>
+#include "node/executionnode.h"
+
+class Dice;
+
+class DiceParser
+{
+
+public:
+ enum DiceOperator {D};
+ enum MathOperator {K,k,r,e};
+ DiceParser();
+ void parseLine(QString str);
+
+private:
+ bool readNumber(QString& str, int& myNumber);
+ bool readDice(QString& str,Dice&);
+ bool readDiceOperator(QString&,DiceOperator&);
+ bool readDiceExpression(QString&,ExecutionNode* & node);
+ bool readOperator(QString&);
+
+ void setCurrentNode(ExecutionNode* node);
+
+private:
+ QMap<QString,DiceOperator>* m_mapDiceOp;
+ ExecutionNode* m_start;
+ ExecutionNode* m_current;
+};
+
+class Dice
+{
+public:
+ DiceParser::DiceOperator m_diceOp;
+ int m_faces;
+};
+
+#endif // DICEPARSER_H