Esempio n. 1
0
 private static function ParseDescription($SpellData, $DescriptionString)
 {
     $DescriptionString = strtr($DescriptionString, array("\r" => '', "\n" => '<br />'));
     $DescriptionString = self::replaceBrackets($DescriptionString);
     $Modifiers = array('+', '-', '/', '*', '^');
     $SubSpells = array();
     $ModifierWasFound = false;
     $DurationChanged = false;
     $UsedModifier = "";
     foreach ($Modifiers as $Modifier) {
         if (strstr(substr($DescriptionString, strpos($DescriptionString, '$')), $Modifier)) {
             $Explode = explode($Modifier, substr($DescriptionString, strpos($DescriptionString, '$')));
             $SpellID = $Explode[0];
             $UsedModifier = $Modifier;
             if (strstr($Explode[1], ';')) {
                 @($SecondExplode = explode(';', $Explode[1]));
                 $ExplodedWith = ';';
             } else {
                 @($SecondExplode = explode(' ', $Explode[1]));
                 $ExplodedWith = ' ';
             }
             $Duration = $SecondExplode[0];
             $SubSpells[] = @array(str_replace('.', '', $SecondExplode[1]));
             $ModifierWasFound = true;
         }
     }
     preg_match_all('!\\$\\w+\\D\\d?!', $DescriptionString, $SubSpells);
     if (empty($SubSpells[0])) {
         preg_match_all('!\\$\\D\\d?!', $DescriptionString, $SubSpells);
     }
     $SubSpells = call_user_func_array('array_merge', $SubSpells);
     $SubSpellsData = Spells::ParseSubSpells($SubSpells);
     if (isset($Duration)) {
         $OldDuration = "";
         if (strstr($Duration, '$')) {
             $DurationChanged = true;
             $OldDuration = $Duration;
             $Data = self::ParseSubSpells([$Duration])[0];
             $ParseResult = Spells::ArgumentParser($SpellData, $Data['SpellID'], $Data['Argument'], $Data['ArgumentValue']) . ' ';
             $Duration = $ParseResult;
             $Unset = Text::Search($SubSpellsData, ['SpellID' => $Data['SpellID'], 'Argument' => $Data['Argument']])[0];
             unset($SubSpellsData[$Unset]);
         }
     }
     foreach ($SubSpellsData as $SubSpell) {
         if ($ModifierWasFound == false) {
             $ParseResult = Spells::ArgumentParser($SpellData, $SubSpell['SpellID'], $SubSpell['Argument'], $SubSpell['ArgumentValue']) . ' ';
             $Replacement = '$' . $SubSpell['SpellID'] . $SubSpell['Argument'] . $SubSpell['ArgumentValue'];
             $DescriptionString = str_replace($Replacement, $ParseResult, $DescriptionString);
         } else {
             $ParseResult = Spells::ArgumentParser($SpellData, $SubSpell['SpellID'], $SubSpell['Argument'], $SubSpell['ArgumentValue'], $UsedModifier . $Duration);
             if ($DurationChanged) {
                 if (strstr($SubSpell['SpellID'], '*') || strstr($SubSpell['Argument'], '*') || strstr($SubSpell['ArgumentValue'], '*')) {
                     $Replacement = '$' . $SubSpell['SpellID'] . $SubSpell['Argument'] . $SubSpell['ArgumentValue'] . $OldDuration;
                 } else {
                     $Replacement = '$' . $SubSpell['SpellID'] . $SubSpell['Argument'] . $SubSpell['ArgumentValue'];
                 }
             } else {
                 $Replacement = '$' . $UsedModifier . $Duration . $ExplodedWith . $SecondExplode[1];
             }
             $DescriptionString = str_replace($Replacement, $ParseResult, $DescriptionString);
         }
     }
     return $DescriptionString;
 }
Esempio n. 2
0
 private static function ParseDescription($SpellData, $DescriptionString)
 {
     $DescriptionString = strtr($DescriptionString, array("\r" => '', "\n" => '<br />'));
     $Modifiers = array('+', '-', '/', '*', '^');
     $SubSpells = array();
     $ModifierWasFound = false;
     foreach ($Modifiers as $Modifier) {
         if (strstr($DescriptionString, $Modifier)) {
             $Explode = explode($Modifier, substr($DescriptionString, strpos($DescriptionString, '$')));
             $SpellID = $Explode[0];
             $UsedModifier = $Modifier;
             @($SecondExplode = explode(';', $Explode[1]));
             $Duration = $SecondExplode[0];
             $ExplodedWith = ';';
             $SubSpells[] = @array(str_replace('.', '', $SecondExplode[1]));
             $ModifierWasFound = true;
         }
     }
     if ($ModifierWasFound == false) {
         preg_match_all('!\\$\\d+\\D\\d?!', $DescriptionString, $SubSpells);
         if (empty($SubSpells[0])) {
             preg_match_all('!\\$\\D\\d?!', $DescriptionString, $SubSpells);
         }
     }
     $SubSpells = call_user_func_array('array_merge', $SubSpells);
     $SubSpellsData = Spells::ParseSubSpells($SubSpells);
     foreach ($SubSpellsData as $SubSpell) {
         if ($ModifierWasFound == false) {
             $ParseResult = Spells::ArgumentParser($SpellData, $SubSpell['SpellID'], $SubSpell['Argument'], $SubSpell['ArgumentValue']);
             $Replacement = '$' . $SubSpell['SpellID'] . $SubSpell['Argument'] . $SubSpell['ArgumentValue'];
             $DescriptionString = str_replace($Replacement, $ParseResult, $DescriptionString);
         } else {
             $ParseResult = Spells::ArgumentParser($SpellData, $SubSpell['SpellID'], $SubSpell['Argument'], $SubSpell['ArgumentValue'], $UsedModifier . $Duration);
             $Replacement = '$' . $UsedModifier . $Duration . $ExplodedWith . $SecondExplode[1];
             $DescriptionString = str_replace($Replacement, $ParseResult, $DescriptionString);
         }
     }
     return $DescriptionString;
 }