game2005api/webapp/mt/GunTalentLv.php
2021-11-18 19:13:34 +08:00

69 lines
1.5 KiB
PHP

<?php
namespace mt;
use phpcommon;
class GunTalentLv {
public static function get($id)
{
return self::getMetaList()[$id];
}
public static function getCostList($meta)
{
$costList = array();
$strArr = explode("|", $meta["cost"]);
foreach ($strArr as $str) {
$strArr2 = explode(":", $str);
array_push(
$costList,
array(
'item_id' => (int)$strArr2[0],
'item_num' => (int)$strArr2[1],
)
);
}
return $costList;
}
public static function isFullLv($meta, $talentLv)
{
$fullLvMeta = self::getFullLvMeta($meta);
return $fullLvMeta && $talentLv >= $fullLvMeta['lv'];
}
public static function getFullLvMeta($meta)
{
$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;
}
$currMeta = self::get($currMeta['nextid']);
}
return null;
}
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('guntalentlv@guntalentlv.php');
}
return self::$metaList;
}
protected static $metaList;
}