65 lines
1.6 KiB
PHP
65 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace mt;
|
|
|
|
use phpcommon;
|
|
|
|
class GunTalentGrow {
|
|
|
|
public static function get($id)
|
|
{
|
|
return getXVal(self::getMetaList(), $id, null);
|
|
}
|
|
|
|
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 getByIdLv($talentId, $talentLv)
|
|
{
|
|
self::mustBeIdLvHash();
|
|
$idMeta = getXVal(self::$idLvHash, $talentId, null);
|
|
return $idMeta ? getXVal($idMeta, $talentLv, null) : null;
|
|
}
|
|
|
|
protected static function mustBeIdLvHash()
|
|
{
|
|
if (!self::$idLvHash) {
|
|
self::$idLvHash = array();
|
|
foreach (self::getMetaList() as $meta) {
|
|
$idMeta = getXVal(self::$idLvHash, (int)$meta['talent_id'], null);
|
|
if (!$idMeta) {
|
|
$idMeta = array();
|
|
self::$idLvHash[(int)$meta['talent_id']] = $idMeta;
|
|
}
|
|
self::$idLvHash[(int)$meta['talent_id']][(int)$meta['talent_lv']] = $meta;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected static function getMetaList()
|
|
{
|
|
if (!self::$metaList) {
|
|
self::$metaList = getMetaTable('gunTalentGrow@gunTalentGrow.php');
|
|
}
|
|
return self::$metaList;
|
|
}
|
|
|
|
protected static $idLvHash;
|
|
protected static $metaList;
|
|
|
|
}
|