Assembla home | Assembla project page
 
Show
Ignore:
Timestamp:
04/14/08 23:59:18 (7 months ago)
Author:
Slynderdale
Message:

Fixed a couple tiny bugs in Dice and PHP

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/Dice.php

    r234 r242  
    6060                $expr = substr($expr, $ptr); 
    6161                $ptr = 0; 
    62             // Opening parenthesis 
    63             } elseif ($substr === '(') { 
    64                 $last = substr($out, -1); 
    65                 if (!empty($last) && !in_array($last, array('+', '-', '/', '*', '('))) { 
    66                     $out .= '*'; 
    67                 } 
    68                 $out .= $substr; 
    69                 $expr = substr($expr, $ptr); 
    70                 $ptr = 0; 
    71             // Closing parenthesis 
    72             } elseif ($substr === ')') { 
    73                 $out .= $substr; 
    74                 $next = substr($equation, 1, 1); 
    75                 if (!empty($next) && !in_array($next, array('+', '-', '/', '*', ')'))) { 
    76                     $out .= '*'; 
    77                 } 
    78                 $expr = substr($expr, $ptr); 
    79                 $ptr = 0; 
    8062            // Parse error if we've consumed the entire equation without finding anything valid 
    8163            } elseif ($ptr >= strlen($expr)) { 
     
    11799                $bonus = 0; 
    118100                if (!empty($expression) && $this->allowExpressions) { 
    119                     $expression = preg_replace('/((?:[0-9]+)?d[0-9]+(?:[+\*-][^\s]*)?)/e', '$this->processDice("\\1", true)', $expression); 
     101                    $expression = preg_replace('/((?:[0-9]+)?d[0-9]+(?:[+\*-][^\s]+)?)/e', '$this->processDice("\\1", true)', $expression); 
    120102                    $bonus = $this->processExpression($expression); 
    121103                    if (is_null($bonus)) { 
    122                         return ($recursive ? 0 : 'Error while processing the dice expression.'); 
     104                        return ($recursive ? null : 'Error while processing the dice expression.'); 
    123105                    } 
    124106                }