aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--HelpMe.md13
-rw-r--r--diceparser.h28
-rw-r--r--die.cpp1
-rw-r--r--node/countexecutenode.h2
-rw-r--r--node/dicerollernode.cpp2
-rw-r--r--node/dicerollernode.h2
-rw-r--r--node/rerolldicenode.h2
-rw-r--r--parsingtoolbox.cpp61
-rw-r--r--result/result.cpp2
9 files changed, 57 insertions, 56 deletions
diff --git a/HelpMe.md b/HelpMe.md
index 3077195..8c0dc0f 100644
--- a/HelpMe.md
+++ b/HelpMe.md
@@ -58,12 +58,6 @@ Dice explose if their value are at the die maximum, the option sorts the resulti
> klX
-The option sorts the resulting die list and select the X lowest dice.
-
-### Keep Lower dice
-
-> klX
-
Dice explose if their value are at the die maximum, the option sorts the resulting die list, the it selects the X lowest dice.
### Sorting
@@ -73,6 +67,7 @@ Dice explose if their value are at the die maximum, the option sorts the resulti
The dice list is sorted in descending order.
> 10d6sl
+
Roll 6 dice at 6 faces and then sort them ascendingly
### Counter
@@ -223,6 +218,12 @@ The Rolisteam Dice Parser allows you to use several logic operator:
* Lesser : <
* Greater : >
+## Select value from List
+
+The L operator (meaning list) can offer you the opportunity to pick up value from list.
+
+> 1L[sword,bow,knife,gun,shotgun]
+
## Examples
> 3D100
diff --git a/diceparser.h b/diceparser.h
index 59fe04f..6baef6a 100644
--- a/diceparser.h
+++ b/diceparser.h
@@ -40,20 +40,26 @@ typedef QMap<int,ListDiceResult > ExportedDiceResult;
class ExploseDiceNode;
/**
- * @page DiceParser
+ * @page DiceParser Dice Parser
+ *
+ * @section Intro Introduction
+ * Diceparser is the software component dedicated to compute dice command in rolisteam.<br/>
+ *
+ * @section grammar The Grammar
*
* The grammar is something like this:
*
- * Line =: Command | Command;Command
- * Command =: Expression | ScalarOperator Expression | ScalarOperator NodeAction Expression
- * Expression =: number | number Dice | Command
- * Dice =: DiceOperator Number(faces) | DiceOperator List
- * List =: [Word,Number,',']+
- * NodeAction =: @
- * DiceOperator =: [D,L]
- * ScalarOperator =: [x,-,*,x,/]
- * number =: [0-9]+
- * Word =: [A-z]+
+ * Line =: Command | Command;Command<br/>
+ * Command =: Expression | ScalarOperator Expression | ScalarOperator NodeAction Expression<br/>
+ * Expression =: number | number Dice | Command<br/>
+ * Dice =: DiceOperator Number(faces) | DiceOperator List<br/>
+ * List =: [Word[range|percentage],Number[range|percentage],',']+<br/>
+ * Persentage =: Number <br/>
+ * NodeAction =: @<br/>
+ * DiceOperator =: [D,L]<br/>
+ * ScalarOperator =: [x,-,*,x,/]<br/>
+ * number =: [0-9]+<br/>
+ * Word =: [A-z]+<br/>
*
*/
diff --git a/die.cpp b/die.cpp
index 7a79e88..1c52adb 100644
--- a/die.cpp
+++ b/die.cpp
@@ -43,6 +43,7 @@ Die::Die(const Die& die)
m_faces = die.m_faces;
m_highlighted = die.m_highlighted;
m_base = die.m_base;
+ m_color = die.getColor();
}
void Die::setValue(qint64 r)
diff --git a/node/countexecutenode.h b/node/countexecutenode.h
index 167ee82..15b2509 100644
--- a/node/countexecutenode.h
+++ b/node/countexecutenode.h
@@ -38,8 +38,8 @@ public:
virtual qint64 getPriority() const;
private:
- Validator* m_validator;
ScalarResult* m_scalarResult;
+ Validator* m_validator;
};
#endif // COUNTEXECUTENODE_H
diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp
index d8fe49c..e6f2950 100644
--- a/node/dicerollernode.cpp
+++ b/node/dicerollernode.cpp
@@ -46,7 +46,7 @@ void DiceRollerNode::run(ExecutionNode* previous)
}
}
-quint64 DiceRollerNode::getFaces()
+quint64 DiceRollerNode::getFaces() const
{
return m_faces;
}
diff --git a/node/dicerollernode.h b/node/dicerollernode.h
index 808676f..2de1cfe 100644
--- a/node/dicerollernode.h
+++ b/node/dicerollernode.h
@@ -27,7 +27,7 @@ public:
* @brief getFaces accessor
* @return the face count
*/
- quint64 getFaces();
+ quint64 getFaces() const;
/**
* @brief toString
diff --git a/node/rerolldicenode.h b/node/rerolldicenode.h
index f456bb3..2a98b4a 100644
--- a/node/rerolldicenode.h
+++ b/node/rerolldicenode.h
@@ -53,9 +53,9 @@ public:
virtual qint64 getPriority() const;
private:
- Validator* m_validator;
DiceResult* m_myDiceResult;
bool m_adding;
+ Validator* m_validator;
};
#endif // REROLLDICENODE_H
diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp
index 7950e4d..38221f9 100644
--- a/parsingtoolbox.cpp
+++ b/parsingtoolbox.cpp
@@ -27,8 +27,12 @@
QHash<QString,QString>* ParsingToolBox::m_variableHash = NULL;
ParsingToolBox::ParsingToolBox()
+ : m_logicOp(new QMap<QString,BooleanCondition::LogicOperator>()),
+ m_logicOperation(new QMap<QString,CompositeValidator::LogicOperation>()),
+ m_conditionOperation(new QMap<QString,OperationCondition::ConditionOperator>()),
+ m_arithmeticOperation(new QHash<QString,ScalarOperatorNode::ArithmeticOperator>())
{
- m_logicOp = new QMap<QString,BooleanCondition::LogicOperator>();
+ //m_logicOp = ;
m_logicOp->insert(">=",BooleanCondition::GreaterOrEqual);
m_logicOp->insert("<=",BooleanCondition::LesserOrEqual);
m_logicOp->insert("<",BooleanCondition::LesserThan);
@@ -36,16 +40,16 @@ ParsingToolBox::ParsingToolBox()
m_logicOp->insert(">",BooleanCondition::GreaterThan);
- m_logicOperation = new QMap<QString,CompositeValidator::LogicOperation>();
+ //m_logicOperation = ;
m_logicOperation->insert("|",CompositeValidator::OR);
m_logicOperation->insert("^",CompositeValidator::EXCLUSIVE_OR);
m_logicOperation->insert("&",CompositeValidator::AND);
- m_conditionOperation = new QMap<QString,OperationCondition::ConditionOperator>();
+ // m_conditionOperation = ;
m_conditionOperation->insert("%",OperationCondition::Modulo);
- m_arithmeticOperation = new QHash<QString,ScalarOperatorNode::ArithmeticOperator>();
+ //m_arithmeticOperation = new QHash<QString,ScalarOperatorNode::ArithmeticOperator>();
m_arithmeticOperation->insert(QStringLiteral("+"),ScalarOperatorNode::PLUS);
m_arithmeticOperation->insert(QStringLiteral("-"),ScalarOperatorNode::MINUS);
m_arithmeticOperation->insert(QStringLiteral("*"),ScalarOperatorNode::MULTIPLICATION);
@@ -425,18 +429,11 @@ bool ParsingToolBox::readDiceRange(QString& str,qint64& start, qint64& end)
str=str.remove(0,1);
return true;
}
- else
- {
- return false;
- }
}
}
- else
- {
- return false;
- }
}
}
+ return false;
}
ParsingToolBox::LIST_OPERATOR ParsingToolBox::readListOperator(QString& str)
@@ -493,7 +490,7 @@ void ParsingToolBox::readProbability(QStringList& str,QList<Range>& ranges)
int i=0;
int j=0;
//range
- foreach(QString line,str)
+ for(QString line:str)
{
int pos = line.indexOf('[');
if(-1!=pos)
@@ -511,7 +508,7 @@ void ParsingToolBox::readProbability(QStringList& str,QList<Range>& ranges)
totalDistance += end-start+1;
++i;
}
- else
+ else//pourcentage
{
Range range;
range.setStart(start);
@@ -528,29 +525,25 @@ void ParsingToolBox::readProbability(QStringList& str,QList<Range>& ranges)
}
- qint64 totalDistPourcent = totalDistance * undefDistance / (100-undefDistance);
-
- if(totalDistPourcent<undefCount)
+ if(undefDistance!=0)
{
- totalDistPourcent = undefCount;
- }
-
- for(int i = 0; i< ranges.size(); ++i)
- {
- Range tmp = ranges.at(i);
- if(!tmp.isFullyDefined())
+ qreal ratio = (qreal)100.0 / (qreal)undefDistance;
+ qint64 realStart=0;
+ for(int i = 0; i< ranges.size(); ++i)
{
- int dist = tmp.getStart();
- tmp.setStart(maxValue+1);
- maxValue+=1;
- double truc = undefDistance*1.0/dist;
-
- tmp.setEnd(maxValue+(truc*totalDistPourcent));
- maxValue = maxValue+(truc*totalDistPourcent);
- ranges[i]=tmp;
+ Range tmp = ranges.at(i);
+ if(!tmp.isFullyDefined())
+ {
+ int dist = tmp.getStart();
+ tmp.setStart(realStart+1);
+ double truc = dist*ratio;
+
+ tmp.setEnd(realStart+truc);
+ realStart = tmp.getEnd();
+ //qDebug() <<"start:"<< tmp.getStart() << "end:"<< realStart;
+ ranges[i]=tmp;
+ }
}
}
-
-
}
diff --git a/result/result.cpp b/result/result.cpp
index 3fa0aec..814ddb3 100644
--- a/result/result.cpp
+++ b/result/result.cpp
@@ -23,7 +23,7 @@
#include <QUuid>
Result::Result()
- : m_previous(NULL),m_resultTypes(NONE),m_id(QString("\"%1\"").arg(QUuid::createUuid().toString()))
+ : m_resultTypes(NONE),m_id(QString("\"%1\"").arg(QUuid::createUuid().toString())),m_previous(NULL)
{
}