From ddce998cad192ab71d3f48575a29bae66bd061d0 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Mon, 13 Mar 2017 16:58:26 +0100 Subject: [PATCH] Spells/Tooltips * fixed parser for lastValue/gender-switch (previous pattern matched against that too) * also its a stupid idea to replace a var with itself --- includes/types/spell.class.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/includes/types/spell.class.php b/includes/types/spell.class.php index 0889e7d2..0f187d13 100644 --- a/includes/types/spell.class.php +++ b/includes/types/spell.class.php @@ -823,21 +823,21 @@ class SpellList extends BaseType 'switch' => null ); + // last value or gender -switch $[lg]ifText:elseText; + if (preg_match('/^([lg])([^:]*:[^;]*);/i', $varString, $m)) + { + $len = strlen($m[0]); + $varParts['var'] = $m[1]; + $varParts['switch'] = explode(':', $m[2]); + } // basic variable ref (most common case) $(refSpell)?(var)(effIdx)? - if (preg_match('/^(\d*)([a-z])([123]?)\b/i', $varString, $m)) + else if (preg_match('/^(\d*)([a-z])([123]?)\b/i', $varString, $m)) { $len = strlen($m[0]); $varParts['lookup'] = $m[1]; $varParts['var'] = $m[2]; $varParts['effIdx'] = $m[3]; } - // last value or gender -switch $[lg]ifText:elseText; - else if (preg_match('/^([lg])([^:]*:[^;]*);/i', $varString, $m)) - { - $len = strlen($m[0]); - $varParts['var'] = $m[1]; - $varParts['switch'] = explode(':', $m[2]); - } // variable ref /w formula $( (op) (oparg); )? (refSpell) ( (var) (effIdx) ) OR $(refSpell) ( (op) (oparg); )? ( (var) (effIdx) ) else if (preg_match('/^(([\+\-\*\/])(\d+);)?(\d*)(([\+\-\*\/])(\d+);)?([a-z])([123]?)\b/i', $varString, $m)) { @@ -857,11 +857,11 @@ class SpellList extends BaseType // description-, buff-parsing component // returns [min, max, minFulltext, maxFulltext, ratingId] - private function resolveVariableString($var, &$usesScalingRating) + private function resolveVariableString($varParts, &$usesScalingRating) { $signs = ['+', '-', '/', '*', '%', '^']; - foreach ($var as $k => $v) + foreach ($varParts as $k => $v) $$k = $v; $result = [null];