54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace mt;
|
|
|
|
require_once('mt/StrHelper.php');
|
|
require_once('mt/AttrHelper.php');
|
|
|
|
use phpcommon;
|
|
|
|
class HeroLevel {
|
|
|
|
public static function get($id)
|
|
{
|
|
return getXVal(self::getMetaList(), $id);
|
|
}
|
|
|
|
public static function getByQualityLevel($quality, $level)
|
|
{
|
|
self::mustBeQualityLevelHash();
|
|
return getXVal(self::$qualityLevelHash, $quality . '_' . $level, null);
|
|
}
|
|
|
|
public static function addRandAttr($levelMeta, $baseAttrs, &$dbAttrs)
|
|
{
|
|
$nums = explode(':', $levelMeta['rand_attrs_num']);
|
|
$num = rand($nums[0], $nums[1]);
|
|
$cfgAttrs = StrHelper::parseList($levelMeta['rand_attrs'], array('|', ':'));
|
|
AttrHelper::addRandAttrs($cfgAttrs, $num, $baseAttrs, $dbAttrs);
|
|
return true;
|
|
}
|
|
|
|
protected static function getMetaList()
|
|
{
|
|
if (!self::$metaList) {
|
|
self::$metaList = getMetaTable('heroLevel@heroLevel.php');
|
|
}
|
|
return self::$metaList;
|
|
}
|
|
|
|
protected static function mustBeQualityLevelHash()
|
|
{
|
|
if (!self::$qualityLevelHash) {
|
|
self::$qualityLevelHash = array();
|
|
foreach (self::getMetaList() as $meta) {
|
|
self::$qualityLevelHash[$meta['quality'] . '_' . $meta['level']] = $meta;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected static $metaList;
|
|
protected static $qualityLevelHash;
|
|
|
|
}
|