diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index f18e00a..86472e2 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -53,6 +53,7 @@ class GunController extends BaseAuthedController { $typeId = getReqVal('type_id', 0); $talentId = getReqVal('talent_id', 0); $talentDb = GunTalent::find($typeId, $talentId); + $currLv = isset($talentDb) ? $talentDb['talent_lv'] : 0; } } diff --git a/webapp/mt/GunTalentGrow.php b/webapp/mt/GunTalentGrow.php index 6b58686..f9d6987 100644 --- a/webapp/mt/GunTalentGrow.php +++ b/webapp/mt/GunTalentGrow.php @@ -28,31 +28,26 @@ class GunTalentGrow { return $costList; } - public static function isFullLv($meta, $talentLv) + public static function getByIdLv($talentId, $talentLv) { - $fullLvMeta = self::getFullLvMeta($meta); - return $fullLvMeta && $talentLv >= $fullLvMeta['lv']; + self::mustBeIdLvHash(); + $idMeta = getXVal($idLvHash, $talentId, null); + return $idMeta ? getXVal($idMeta, $talentLv, null) : null; } - public static function getFullLvMeta($meta) + protected static function mustBeIdLvHash() { - $currMeta = $meta; - while ($currMeta['nextid'] > 0) { - $currMeta = self::get($currMeta['nextid']); - } - return $currMeta; - } - - public static function getByLv($meta, $talentLv) - { - $currMeta = $meta; - while ($currMeta) { - if ($currMeta['lv'] == $talentLv) { - return $currMeta; + if (!self::$idLvHash) { + self::$idLvHash = array(); + foreach (self::getMetaList() as $meta) { + $idMeta = getXVal($idLvHash, $talentId, null); + if (!$idMeta) { + $idMeta = array(); + $idLvHash[$meta['id']] = $idMeta; + } + $idLvHash[$meta['id']][$meta['talent_lv']] = $meta; } - $currMeta = self::get($currMeta['nextid']); } - return null; } protected static function getMetaList() @@ -63,6 +58,7 @@ class GunTalentGrow { return self::$metaList; } + protected static $idLvHash; protected static $metaList; }