getConstants())){ return true; } else{ return false; } } /** * Forms an image URL. * * It will intentionally fail when used for a non constant class. * * @param string $type Image type. valid values are: * ICON, LOGO, CURRENCY, UNIT, * AREA, SKILL, ESSENCE, RUNE, * GRIND, ELEMENT, SKILL_GUILD, DECORATION, * SOURCE, SKILL_LEADER, INVENTORY, EFFECT, * BUILDING * @param string|int $name Filename, with no path or extension. It can also * skip the padding. An id can be used. * @return string URL if found. If not, the URL to an 'unknown' icon. */ public static function img($type, $name){ $pad = 1; $url = URL::IMG["UNKNOWN"]; while ($pad < 10){ if (isset(PATH::IMG[$type]) && file_exists(PATH::IMG[$type] . str_pad($name, $pad, '0', STR_PAD_LEFT) . ".png")){ $url = URL::IMG[$type] . str_pad($name, $pad, '0', STR_PAD_LEFT) . ".png"; break; } $pad ++; } return $url; } /** * Calculates the effective damage. * * @param int $atk Attack stat. * @param int $crr Critical rate stat. * @param int $crd Critical damage stat. * @return int Damage stat. */ public static function calculate_dmg($atk, $crr, $crd){ if (! is_numeric($atk) || ! is_numeric($crr) || ! is_numeric($crd)){ return 0; } if ($crr > 100){ $crr = 100; } $edmg = ceil(($atk * (100 - $crr) / 100) + (($atk + ($atk * $crd / 100)) * $crr / 100)); return $edmg; } /** * Calculates the effective HP of a unit. * @param int $hp HP stat * @param int $def Defense stat. * @return int Effective HP. */ public static function calculate_ehp($hp, $def){ $ehp = ceil(((($def * 3.5) + 1140) * $hp) / 1000); return $ehp; } } ?>