kecske123

Untitled

Mar 13th, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.89 KB | None | 0 0
  1. class HPPlayerSpell
  2. {
  3.     const SpellDB = [
  4.         'conjunctivitis' => [
  5.             'rand1' => 15, 'rand2' => 38,
  6.             'text' => color("0,13", "%caster% has shot a jet of ").color("13,0", "blinding light at %target% ").color("0,13", "causing %value% damage!"),
  7.             'modifiers' => [
  8.                 'HPPlayerSpell::ModMonsterHitDmg' => ['death_eater', 30, 60]
  9.             ]
  10.         ]
  11.     ];
  12.    
  13.     public static function CalculateSpellValue($spell, $caster, $target, $special, &$success, &$text)
  14.     {
  15.         $spell = strtolower($spell);
  16.         if (!self::Castable($spell, $caster, $target, $special, $text))
  17.         {
  18.             $success = false;
  19.             return 0;
  20.         }
  21.         $spellentry = self::SpellDB[$spell];
  22.         $value = Veletlenszam($spellentry['rand1'], $spellentry['rand2']);
  23.         foreach ($spellentry['modifiers'] as $modifier => $modifierparams)
  24.         {
  25.             $modifier($caster, $target, $special, $spellentry, $value, $modifierparams);
  26.         }
  27.         self::ModWandDamage($caster, $target, $special, $value);
  28.        
  29.         $text = str_replace(['caster', 'target', 'value'], [self::GetPlayerName($caster), self::GetPlayerName($target), $value], $spellentry['text']);
  30.         return $value;
  31.     }
  32.    
  33.     public static function Castable($spell, $caster, $target, $special, &$reason)
  34.     {
  35.         if (!isset(self::SpellDB[$spell]))
  36.         {
  37.             $reason = "Spell not found in Spell DB";
  38.             return false;
  39.         }
  40.        
  41.         if (isset(self::SpellDB[$spell]['checks']))
  42.         {
  43.             foreach (self::SpellDB[$spell]['checks'] as $check)
  44.             {
  45.                 if (!$check($caster, $target, $special, $reason))
  46.                     return false;
  47.             }
  48.         }
  49.        
  50.         return true;
  51.     }
  52.    
  53.     public static function ModMonsterHitDmg($caster, $target, $special, &$spellentry, &$spellvalue, $params)
  54.     {
  55.         if ($params[0] == $target)
  56.             $spellvalue = Veletlenszam($params[1], $params[2]);
  57.     }
  58.    
  59.     public static function ModWandDamage($caster, $target, $special, &$spellentry, &$spellvalue, $params = [])
  60.     {
  61.         $spellvalue += UserStore::Call('GetEntry', $caster, "hpduel/wand", 0);
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment