kecske123 icon

Untitled

kecske123 | PRO | 03/13/19 04:24:28 PM UTC | 0 ⭐ | 212 👁️ | Never ⏰ | []
PHP |

1.89 KB

|

None

|

0 👍

/

0 👎

class HPPlayerSpell
{
    const SpellDB = [
        'conjunctivitis' => [
            'rand1' => 15, 'rand2' => 38,
            'text' => color("0,13", "%caster% has shot a jet of ").color("13,0", "blinding light at %target% ").color("0,13", "causing %value% damage!"),
            'modifiers' => [
                'HPPlayerSpell::ModMonsterHitDmg' => ['death_eater', 30, 60]
            ]
        ]
    ];
    
    public static function CalculateSpellValue($spell, $caster, $target, $special, &$success, &$text)
    {
        $spell = strtolower($spell);
        if (!self::Castable($spell, $caster, $target, $special, $text))
        {
            $success = false;
            return 0;
        }
        $spellentry = self::SpellDB[$spell];
        $value = Veletlenszam($spellentry['rand1'], $spellentry['rand2']);
        foreach ($spellentry['modifiers'] as $modifier => $modifierparams)
        {
            $modifier($caster, $target, $special, $spellentry, $value, $modifierparams);
        }
        self::ModWandDamage($caster, $target, $special, $value);
        
        $text = str_replace(['caster', 'target', 'value'], [self::GetPlayerName($caster), self::GetPlayerName($target), $value], $spellentry['text']);
        return $value;
    }
    
    public static function Castable($spell, $caster, $target, $special, &$reason)
    {
        if (!isset(self::SpellDB[$spell]))
        {
            $reason = "Spell not found in Spell DB";
            return false;
        }
        
        if (isset(self::SpellDB[$spell]['checks']))
        {
            foreach (self::SpellDB[$spell]['checks'] as $check)
            {
                if (!$check($caster, $target, $special, $reason))
                    return false;
            }
        }
        
        return true;
    }
    
    public static function ModMonsterHitDmg($caster, $target, $special, &$spellentry, &$spellvalue, $params)
    {
        if ($params[0] == $target)
            $spellvalue = Veletlenszam($params[1], $params[2]);
    }
    
    public static function ModWandDamage($caster, $target, $special, &$spellentry, &$spellvalue, $params = [])
    {
        $spellvalue += UserStore::Call('GetEntry', $caster, "hpduel/wand", 0);
    }
}

Comments