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); $typeId = getReqVal('type_id', 0);
$talentId = getReqVal('talent_id', 0); $talentId = getReqVal('talent_id', 0);
$talentDb = GunTalent::find($typeId, $talentId); $talentDb = GunTalent::find($typeId, $talentId);
$currLv = isset($talentDb) ? $talentDb['talent_lv'] : 0;
} }
} }

View File

@ -28,31 +28,26 @@ class GunTalentGrow {
return $costList; return $costList;
} }
public static function isFullLv($meta, $talentLv) public static function getByIdLv($talentId, $talentLv)
{ {
$fullLvMeta = self::getFullLvMeta($meta); self::mustBeIdLvHash();
return $fullLvMeta && $talentLv >= $fullLvMeta['lv']; $idMeta = getXVal($idLvHash, $talentId, null);
return $idMeta ? getXVal($idMeta, $talentLv, null) : null;
} }
public static function getFullLvMeta($meta) protected static function mustBeIdLvHash()
{ {
$currMeta = $meta; if (!self::$idLvHash) {
while ($currMeta['nextid'] > 0) { self::$idLvHash = array();
$currMeta = self::get($currMeta['nextid']); foreach (self::getMetaList() as $meta) {
} $idMeta = getXVal($idLvHash, $talentId, null);
return $currMeta; if (!$idMeta) {
} $idMeta = array();
$idLvHash[$meta['id']] = $idMeta;
public static function getByLv($meta, $talentLv) }
{ $idLvHash[$meta['id']][$meta['talent_lv']] = $meta;
$currMeta = $meta;
while ($currMeta) {
if ($currMeta['lv'] == $talentLv) {
return $currMeta;
} }
$currMeta = self::get($currMeta['nextid']);
} }
return null;
} }
protected static function getMetaList() protected static function getMetaList()
@ -63,6 +58,7 @@ class GunTalentGrow {
return self::$metaList; return self::$metaList;
} }
protected static $idLvHash;
protected static $metaList; protected static $metaList;
} }