55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace mt;
|
|
|
|
require('mt/AttrHelper.sql');
|
|
|
|
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 getRandAttr($initMeta, $nextMeta, $oldAttr, &$newAttr)
|
|
{
|
|
$initAttr = mt\AttrHelper::parseAttr($initMeta['rand_attrs']);
|
|
$nextAttr = mt\AttrHelper::parseAttr($next['rand_attrs']);
|
|
if (!mt\AttrHelper::canMerge($initAttr, $nextAttr)) {
|
|
return false;
|
|
}
|
|
mt\AttrHelper::mergeAttr($oldAttr, $newAttr);
|
|
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;
|
|
|
|
}
|