This commit is contained in:
aozhiwei 2021-11-29 16:04:45 +08:00
parent 555a63e576
commit a89b04db72
2 changed files with 16 additions and 19 deletions

View File

@ -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;
}
}

View File

@ -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;
}