Changeset 242 for trunk/Phergie/Plugin/Dice.php
- Timestamp:
- 04/14/08 23:59:18 (7 months ago)
- Files:
-
- trunk/Phergie/Plugin/Dice.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Plugin/Dice.php
r234 r242 60 60 $expr = substr($expr, $ptr); 61 61 $ptr = 0; 62 // Opening parenthesis63 } 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 parenthesis72 } 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;80 62 // Parse error if we've consumed the entire equation without finding anything valid 81 63 } elseif ($ptr >= strlen($expr)) { … … 117 99 $bonus = 0; 118 100 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); 120 102 $bonus = $this->processExpression($expression); 121 103 if (is_null($bonus)) { 122 return ($recursive ? 0: 'Error while processing the dice expression.');104 return ($recursive ? null : 'Error while processing the dice expression.'); 123 105 } 124 106 }