Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Rolisteam/DiceParser
Browse files Browse the repository at this point in the history
  • Loading branch information
Renaud G committed Apr 29, 2017
2 parents 9d4feb2 + 29c8072 commit e1b01fe
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
5 changes: 5 additions & 0 deletions diceparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,11 @@ bool DiceParser::readDice(QString& str,ExecutionNode* & node)
// qint64 face = abs(num - end);
//qDebug() << face << end;
DiceRollerNode* drNode = new DiceRollerNode(max,min);

if(hasOp)
{
drNode->setOperator(op);
}
node = drNode;
ExecutionNode* current = drNode;
while(readOption(str,current))
Expand Down
1 change: 1 addition & 0 deletions node/dicerollernode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@ Die::ArithmeticOperator DiceRollerNode::getOperator() const
void DiceRollerNode::setOperator(const Die::ArithmeticOperator &dieOperator)
{
m_operator = dieOperator;
m_diceResult->setOperator(dieOperator);
}
31 changes: 20 additions & 11 deletions node/ifnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,48 +34,57 @@ IfNode::~IfNode()
void IfNode::run(ExecutionNode *previous)
{
m_previousNode = previous;
if(NULL==previous)
if(nullptr==previous)
{
return;
}
ExecutionNode* previousLoop = previous;
ExecutionNode* nextNode = NULL;
bool runNext = (NULL==m_nextNode) ? false : true;
ExecutionNode* nextNode = nullptr;
bool runNext = (nullptr==m_nextNode) ? false : true;
Result* previousResult = previous->getResult();
m_result = previousResult;

if(NULL!=m_result)
if(nullptr!=m_result)
{
qreal value = previousResult->getResult(Result::SCALAR).toReal();

if(NULL!=m_validator)
if(nullptr!=m_validator)
{
DiceResult* previousDiceResult = dynamic_cast<DiceResult*>(previousResult);
if(NULL!=previousDiceResult)
if(nullptr!=previousDiceResult)
{
QList<Die*> diceList=previousDiceResult->getResultList();

if(m_conditionType == OnEach)
{
for(Die* dice : diceList)
{
qDebug()<< "dice value:" << dice->getValue();
if(m_validator->hasValid(dice,true,true))
{
nextNode = (NULL==m_true) ? NULL: m_true->getCopy();
qDebug()<< "true";
nextNode = (nullptr==m_true) ? nullptr: m_true->getCopy();
}
else
{
nextNode = (NULL==m_false) ? NULL: m_false->getCopy();
qDebug()<< "false";
nextNode = (nullptr==m_false) ? nullptr: m_false->getCopy();
}
if(NULL!=nextNode)
qDebug()<< "dice value:" << dice->getValue() << "next node" << nextNode << "m_true" << m_true;

if(nullptr!=nextNode)
{
if(NULL==previousLoop->getNextNode())
if(nullptr==previousLoop->getNextNode())
{
qDebug() << "iniside loop";
previousLoop->setNextNode(nextNode);
}
if(NULL==m_nextNode)
if(nullptr==m_nextNode)
{
qDebug() << "next node" ;
m_nextNode = nextNode;
}
qDebug() << "before run";
nextNode->run(previousLoop);
previousLoop = getLeafNode(nextNode);
}
Expand Down
1 change: 1 addition & 0 deletions node/splitnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void SplitNode::run(ExecutionNode* previous)
for(qint64 value : oldDie->getListValue())
{
Die* tmpdie = new Die();
tmpdie->insertRollValue(value);
tmpdie->setFaces(oldDie->getFaces());
tmpdie->setValue(value);
tmpdie->setOp(oldDie->getOp());
Expand Down

0 comments on commit e1b01fe

Please sign in to comment.