hujiabin 345aa7408a 1
2023-03-07 15:39:18 +08:00

818 lines
28 KiB
PHP

<?php
namespace models;
require_once('mt/Hero.php');
require_once('mt/HeroLevelAttr.php');
require_once('mt/HeroQuality.php');
require_once('mt/HeroLevel.php');
require_once('mt/AttrHelper.php');
require_once('mt/Item.php');
require_once('mt/SkillCommon.php');
require_once('models/HeroSkin.php');
require_once('models/Chip.php');
require_once('models/User.php');
require_once('models/ChipPlugin.php');
require_once('services/NftService.php');
require_once('services/FormulaService.php');
use mt;
use phpcommon;
use phpcommon\SqlHelper;
use services\NftService;
use services\FormulaService;
use models\ChipPlugin;
class Hero extends BaseModel {
const GETED_STATE = 0;
const FREE_STATE = 1;
const NO_LOCK = 0;
const LEVEL_LOCK = 1;
const QUALITY_LOCK = 2;
const SEND_LOCK = 3;
const COST_LOCK = 4;
//需要材料所需等级
const LV_1 = 4;
const LV_2 = 9;
const LV_3 = 14;
public static function find($heroUniId)
{
return self::internalFind(myself()->_getAccountId(), $heroUniId);
}
public static function findEx($heroUniId){
$row = SqlHelper::ormSelectOne(
myself()->_getMysql(myself()->_getAccountId()),
't_hero',
array(
'idx' => $heroUniId,
)
);
if ($row) {
if ($row['account_id'] != myself()->_getAccountId()) {
$row = null;
}
}
return $row;
}
public static function findByAccountId($accountId, $heroUniId)
{
return self::internalFind($accountId, $heroUniId);
}
public static function findByTokenId($tokenId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMysql($tokenId),
't_hero',
array(
'token_id' => $tokenId,
)
);
if ($row) {
$row['hero_uniid'] = $row['idx'];
if (!NftService::isHeroOwner(myself()->_getOpenId(), $row['token_id'])) {
$row = null;
}
}
return $row;
}
public static function findByTokenId2($tokenId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMysql($tokenId),
't_hero',
array(
'token_id' => $tokenId,
)
);
return $row;
}
private static function internalFind($accountId, $heroUniId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMysql($accountId),
't_hero',
array(
'idx' => $heroUniId,
)
);
if ($row) {
$row['hero_uniid'] = $row['idx'];
if ($row['account_id'] != $accountId) {
$openId = phpcommon\extractOpenId($accountId);
if (!NftService::isHeroOwner($openId, $row['token_id'])) {
$row = null;
}
}
}
return $row;
}
public static function getValidHero($heroId)
{
$heroList = array();
Hero::getHeroList(function ($row) use($heroId, &$heroList) {
if ($row['hero_id'] == $heroId && $row['state'] == self::GETED_STATE) {
array_push($heroList, Hero::toDto($row));
}
});
return !empty($heroList) ? $heroList[0] : null;
}
public static function getRawPveCegUpLimit()
{
$cegUpLimit = 0;
self::getHeroList(function ($row) use(&$cegUpLimit) {
$heroDto = self::toDto($row);
$cegUpLimit += $heroDto['raw_pve_ceg_uplimit'];
});
return $cegUpLimit;
}
public static function getHeroList($cb)
{
SqlHelper::ormSelect(
myself()->_getSelfMysql(),
't_hero',
array(
'account_id' => myself()->_getAccountId()
),
function ($row) use($cb) {
$row['tags'] = '';
$cb($row);
}
);
foreach (NftService::getHeros(myself()->_getOpenId()) as $nftDb) {
if (! $nftDb['deleted']){
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_hero',
array(
'token_id' => $nftDb['token_id'],
)
);
//将NFT表的数据同步到中心化英雄表 (以后可能删除)
if (!$row) {
$itemMeta = mt\Item::get($nftDb['item_id']);
if ($itemMeta) {
self::addNftHero($itemMeta, $nftDb['token_id']);
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_hero',
array(
'token_id' => $nftDb['token_id'],
)
);
}
}
if ($row) {
if (!$row['activate']) {
self::activateHero($row);
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_hero',
array(
'token_id' => $nftDb['token_id'],
)
);
}
$row['tags'] = $nftDb['tags'];
$cb($row);
}
}
}
}
private static function activateHero($row){
$itemMeta = mt\Item::get($row['hero_id']);
if (!$itemMeta) {
return;
}
$randAttr = array();
$fieldsKv = array(
'hero_lv' => 1,
'quality' => 1,
'hero_tili' => FormulaService::Hero_NFT_Maximum_Physical_Strength(1,FormulaService::Hero_Advanced_Lucky_Value(1)),
'state' => self::GETED_STATE,
'skill_lv1' => 1,
'skill_lv2' => 1,
'rand_attr' => json_encode($randAttr),
'lock_type' => self::NO_LOCK,
'unlock_time' => 0,
'unlock_trade_time' => 0,
'activate' => 1,
'modifytime' => myself()->_getNowTime()
);
self::updateByTokenId($row['token_id'],$fieldsKv);
}
public static function toDto($row)
{
$attr = emptyReplace(json_decode($row['rand_attr'], true), array());
// $lockType = 0;
// $unlockTime = 0;
// if ($row['lock_type'] != 0 && $row['unlock_time'] - myself()->_getNowTime() > 0) {
// $lockType = $row['lock_type'];
// $unlockTime = $row['unlock_time'];
// }
{
$lockType = $row['lock_type'];
$unlockTime = $row['unlock_time'];
}
$levelMeta = mt\HeroLevel::getByLevel($row['hero_lv']);
$todayGetGold = $row['today_get_gold'];
$lastGetGoldTime = $row['last_get_gold_time'];
if (myself()->_getDaySeconds($lastGetGoldTime) <
myself()->_getNowDaySeconds()) {
$todayGetGold = 0;
}
// $todayPveGetCeg = $row['today_pve_get_ceg'];
// $lastPveGetCegTime = $row['last_pve_get_ceg_time'];
// if (myself()->_getDaySeconds($lastPveGetCegTime) <
// myself()->_getNowDaySeconds()) {
// $todayPveGetCeg = 0;
// }
// $todayMissionGetCeg = $row['today_mission_get_ceg'];
// $lastMissionGetCegTime = $row['last_mission_get_ceg_time'];
// if (myself()->_getDaySeconds($lastMissionGetCegTime) < myself()->_getNowDaySeconds()) {
// $todayMissionGetCeg = 0;
// }
$baseAttr=[];
$attrPro=[];
$heroMeta = mt\Hero::get($row['hero_id']);
if ($heroMeta) {
$baseAttr = mt\Hero::getHeroAttr($heroMeta);
$attrPro1=[];
if ($row['hero_lv']>1){
$attrPro1 = self::getAttrProByLevel($row,$baseAttr,$attr);
}
$attrPro2=[];
if ($row['quality']>1){
$attrPro2 = self::getAttrProByQuality($row,$baseAttr);
}
$attrPro = self::mergeAttrPro($baseAttr,$attrPro1,$attrPro2);
}
// $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']);
$dto = array(
'idx' => $row['idx'],
'token_id' => $row['token_id'],
'hero_uniid' => $row['idx'],
'hero_id' => $row['hero_id'],
'hero_lv' => $row['hero_lv'],
'hero_tili' => $row['hero_tili'],
'state' => $row['state'],
'skin_id' => $row['skin_id'],
'quality' => $row['quality'],
'skill_lv1' => $row['skill_lv1'],
'skill_lv2' => $row['skill_lv2'],
'attr_base' => $baseAttr,
'attr_pro' => $attrPro,
'try_count' => $row['try_count'],
'lock_type' => $lockType,
'unlock_time' => $unlockTime,
'unlock_lefttime' => max(0,
$unlockTime - myself()->_getNowTime()),
'current_get_gold' => $todayGetGold / 100,
'last_get_gold_time' => $lastGetGoldTime,
'gold_uplimit' => $levelMeta['gold_limit'],
// 'current_pve_get_ceg' => $todayPveGetCeg / 100,
// 'last_pve_get_ceg_time' => $lastPveGetCegTime,
// 'current_mission_get_ceg' => $todayMissionGetCeg / 100,
// 'last_mission_get_ceg_time' => $lastMissionGetCegTime,
'unlock_trade_time' => $row['unlock_trade_time'],
'advanced_count' => $row['advanced_count'],
// 'lucky' => $heroLucky,
'offer_reward_state' => 0,
'tags' => $row['tags']?:'',
);
// $dto['hero_tili_max'] = strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength($dto['quality'],$dto['lucky']),3));
// $dto['pvp_ceg_uplimit'] =strval( round(FormulaService::getHeroPvpDailyCegUpLimit($dto),2) );
// $dto['pve_ceg_uplimit'] = strval( round(FormulaService::getHeroPveDailyCegUpLimit($dto),2) );
// $dto['mission_ceg_uplimit'] = strval( round(FormulaService::getHeroMissionDailyCegUpLimit($dto),2) );
$nft_address = '';
if ($row['token_id']){
$nft_address = SERVER_ENV == _ONLINE ? '0x3EBF5196dADC8F3F09C808333f98FE8A4b7d1e62' : '0x9b1f7F645351AF3631a656421eD2e40f2802E6c0';
}
$dto['nft_address'] = $nft_address;
return $dto;
}
public static function addFreeHero($heroMeta)
{
return self::internalAddHero(
myself()->_getSelfMysql(),
$heroMeta,
myself()->_getAccountId(),
null,
self::FREE_STATE);
}
public static function addHero($heroMeta)
{
return self::internalAddHero(
myself()->_getSelfMysql(),
$heroMeta,
myself()->_getAccountId(),
null,
self::GETED_STATE);
}
public static function addNftHero($heroMeta, $tokenId)
{
return self::internalAddHero(
myself()->_getMysql($tokenId),
$heroMeta,
null,
$tokenId,
self::GETED_STATE);
}
public static function internalAddHero($conn, $heroMeta, $accountId, $tokenId,$state)
{
$skinItemMeta = \mt\Item::getMetaListByType(\mt\Item::HERO_SKIN_TYPE);
if ($skinItemMeta){
foreach ($skinItemMeta as $value){
if ($value['playerid'] == $heroMeta['id'] && $value['isdefaultskin'] ==1){
HeroSkin::addSkin($value);
}
}
}
$realHeroMeta = mt\Hero::get($heroMeta['id']);
$randAttr = array();
$fieldsKv = array(
'hero_id' => $heroMeta['id'],
'hero_lv' => 1,
'quality' => 1,
'hero_tili' => FormulaService::Hero_NFT_Maximum_Physical_Strength(1,FormulaService::Hero_Advanced_Lucky_Value(1)),
'state' => $state,
'skill_lv1' => 1,
'skill_lv2' => 1,
'rand_attr' => json_encode($randAttr),
'lock_type' => self::NO_LOCK,
'unlock_time' => 0,
'unlock_trade_time' => 0,
'activate' => 1,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
);
if ($accountId) {
$fieldsKv['account_id'] = $accountId;
}
if ($tokenId) {
$fieldsKv['token_id'] = $tokenId;
}
SqlHelper::insert(
$conn,
't_hero',
$fieldsKv
);
}
public static function addTryHero($heroMeta, $tryCount)
{
$realHeroMeta = mt\Hero::get($heroMeta['id']);
$randAttr = array();
{
$initQualityMeta = mt\HeroQuality::getByQuality(1);
if ($initQualityMeta) {
$randAttr = mt\HeroQuality::getRandAttr($initQualityMeta);
}
}
SqlHelper::upsert(
myself()->_getSelfMysql(),
't_hero',
array(
'account_id' => myself()->_getAccountId(),
'hero_id' => $heroMeta['id']
),
array(
),
array(
'account_id' => myself()->_getAccountId(),
'hero_id' => $heroMeta['id'],
'hero_lv' => 1,
'quality' => 1,
'hero_tili' => $realHeroMeta ? $realHeroMeta['tili'] : 0,
'state' => self::FREE_STATE,
'try_count' => $tryCount,
'skill_lv1' => 1,
'skill_lv2' => 1,
'rand_attr' => json_encode($randAttr),
'lock_type' => self::NO_LOCK,
'unlock_time' => 0,
'unlock_trade_time' => 0,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
public static function takeonSkin($heroUniId, $skinId)
{
self::update($heroUniId, array(
'skin_id' => $skinId,
'modifytime' => myself()->_getNowTime()
));
}
public static function upgradeSkill($heroUniId, $skillIdx,$skill_points)
{
if (!in_array($skillIdx, array(0, 1))) {
return;
}
$fieldName = 'skill_lv' . ($skillIdx + 1);
self::update($heroUniId, array(
$fieldName => function () use($fieldName) {
return "${fieldName} + 1";
},
'skill_points' => function() use ($skill_points){
return "GREATEST(0, skill_points - ${skill_points})";
},
'modifytime' => myself()->_getNowTime()
));
}
public static function update($heroUniId, $fieldsKv)
{
if (self::find($heroUniId)) {
SqlHelper::update
(myself()->_getSelfMysql(),
't_hero',
array(
'idx' => $heroUniId,
),
$fieldsKv
);
}
}
public static function updateByTokenId($tokenId, $fieldsKv)
{
if (self::findByTokenId($tokenId)) {
SqlHelper::update
(myself()->_getSelfMysql(),
't_hero',
array(
'token_id' => $tokenId,
),
$fieldsKv
);
}
}
public static function randHero(&$heroUniId, &$heroId)
{
$heroUniId = 0;
$heroId = 0;
$heroList = array();
Hero::getHeroList(function ($row) use($heroId, &$heroList) {
if ($row['state'] == self::GETED_STATE) {
array_push($heroList, Hero::toDto($row));
}
});
$key = array_rand($heroList, 1);
if (!is_null($key)) {
$heroUniId = $heroList[$key]['idx'];
$heroId = $heroList[$key]['hero_id'];
}
}
public static function addTili($heroUniId, $tili)
{
self::update($heroUniId,
array(
'hero_tili' => function () use($tili) {
return "hero_tili + ${tili}";
},
));
}
public static function gainGoldPvp($heroDto, $addGold)
{
$newGold = min($heroDto['pvp_ceg_uplimit'],
$heroDto['current_pvp_get_ceg'] + $addGold);
$finalyAddGold = max(0, $newGold - $heroDto['current_pvp_get_ceg']);
if ($finalyAddGold > 0) {
self::update($heroDto['hero_uniid'],
array(
'today_get_gold' => $newGold * 100,
'last_get_gold_time' => myself()->_getNowTime()
));
}
return $finalyAddGold;
}
public static function gainGoldPve($heroDto, $addGold)
{
$newGold = min($heroDto['pve_ceg_uplimit'],
$heroDto['current_pve_get_ceg'] + $addGold);
$finalyAddGold = max(0, $newGold - $heroDto['current_pve_get_ceg']);
if ($finalyAddGold > 0) {
self::update($heroDto['hero_uniid'],
array(
'today_pve_get_ceg' => $newGold * 100,
'last_pve_get_ceg_time' => myself()->_getNowTime()
));
}
return $finalyAddGold;
}
public static function gainGoldMission($heroDto, $addGold)
{
$newGold = min($heroDto['mission_ceg_uplimit'],
$heroDto['current_mission_get_ceg'] + $addGold);
$finalyAddGold = max(0, $newGold - $heroDto['current_mission_get_ceg']);
if ($finalyAddGold > 0) {
self::update($heroDto['hero_uniid'],
array(
'today_mission_get_ceg' => $newGold * 100,
'last_mission_get_ceg_time' => myself()->_getNowTime()
));
}
return $finalyAddGold;
}
public static function calcMissionGainGold($heroDto, $count)
{
if ($count <= 0) {
return 0;
}
$newGold = min($heroDto['mission_ceg_uplimit'],
$heroDto['current_mission_get_ceg'] +
$heroDto['mission_ceg_uplimit'] / $count);
$finalyAddGold = max(0, $newGold - $heroDto['current_mission_get_ceg']);
return $finalyAddGold;
}
public static function heroIsLocking($heroDto)
{
if ($heroDto['lock_type']) {
return true;
}
$locking = false;
$heroUniId = !empty($heroDto['hero_uniid']) ? $heroDto['hero_uniid'] : $heroDto['idx'];
{
$idx = 0;
for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) {
$upHeroUniId = myself()->_getV(TN_HERO_QUALITY_UP, $i);
if ($upHeroUniId == $heroUniId) {
$idx = $i;
$locking = true;
break;
}
}
}
if (!$locking) {
$idx = 0;
for ($i = 0; $i < kMaxHeroUpLevelNum; ++$i) {
$upHeroUniId = myself()->_getV(TN_HERO_LEVEL_UP, $i);
if ($upHeroUniId == $heroUniId) {
$idx = $i;
$locking = true;
break;
}
}
}
return $locking;
}
private static function mergeAttrPro($baseAttr,$attrPro1,$attrPro2){
$newAttr = [];
$newAttrPro = [];
if ($attrPro1 && !$attrPro2){
$newAttrPro = $attrPro1;
}
if (!$attrPro1 && $attrPro2){
$newAttrPro = $attrPro2;
}
if ($attrPro1 && $attrPro2){
foreach ($attrPro1 as $value){
foreach ($attrPro2 as $val){
if ($value['attr_id'] == $val['attr_id']){
array_push($newAttr,
[
'attr_id' => $value['attr_id'],
'type' => $value['type'],
'val' => $value['val']+$val['val'],
]);
}
}
}
if ($newAttr){
foreach ($baseAttr as $value){
foreach ($newAttr as $val){
if ($value['attr_id'] == $val['attr_id']){
array_push($newAttrPro,
[
'attr_id' => $value['attr_id'],
'type' => $value['type'],
'val' => strval($val['val']-$value['val']),
]);
}
}
}
}
}
return $newAttrPro;
}
private static function getAttrProByLevel($row,$baseAttr,$attr){
$attrPro1 = [];
$coefficient_level = mt\HeroLevelAttr::getCoefficientByLevel($row['hero_lv'],$row['hero_id']);
foreach ($baseAttr as $val){
foreach ($attr as $v){
$coef_level = mt\HeroLevelAttr::getByCoefficient($coefficient_level,$val['attr_id']);
// if ($val['attr_id'] == $v['attr_id'] && $val['attr_id'] == kHAT_Atk){ //18 //18.941564456287 //20.847692307692
// array_push($attrPro1,[
// 'attr_id' => $val['attr_id'],
// 'type'=> $val['type'],
// 'val' => strval($val['val']*$v['val']+$v['val']/$coef_level['val']*100-100/$coef_level['val']),
// ]);
// }
//&& $val['attr_id'] != kHAT_Atk
if ( $val['attr_id'] == $v['attr_id'] ){
array_push($attrPro1,[
'attr_id' => $val['attr_id'],
'type'=> $val['type'],
'val' => strval($val['val']*pow($v['val'],$coef_level['val'])),
]);
}
}
}
return $attrPro1;
}
private static function getAttrProByQuality($row,$baseAttr){
$attrPro2 = [];
$qualityMeta = mt\HeroQuality::getByQuality($row['quality']);
$coefficient_quality = mt\HeroQuality::getCoefficientByQuality($row['quality'],$row['hero_id']);
foreach ($baseAttr as $val){
$coef_quality = mt\HeroQuality::getByCoefficient($coefficient_quality,$val['attr_id']);
if ($coef_quality){
// if ($val['attr_id'] == kHAT_Atk){
// array_push($attrPro2,[
// 'attr_id' => $val['attr_id'],
// 'type'=> $val['type'],
// 'val' => strval($val['val']*$qualityMeta['promote_val']+$qualityMeta['promote_val']/$coef_quality['val']*100-100/$coef_quality['val']),
// ]);
// }
// if ($val['attr_id'] != kHAT_Atk) {
// array_push($attrPro2, [
// 'attr_id' => $val['attr_id'],
// 'type' => $val['type'],
// 'val' => strval($val['val'] * pow($qualityMeta['promote_val'], $coef_quality['val'])),
// ]);
// }
array_push($attrPro2, [
'attr_id' => $val['attr_id'],
'type' => $val['type'],
'val' => strval($val['val'] * pow($qualityMeta['promote_val'], $coef_quality['val'])),
]);
}
}
return $attrPro2;
}
public static function getFreeHero(){
$hero = array();
Hero::getHeroList(function ($row) use (&$hero) {
if (!$row['token_id']) {
$hero = $row;
}
});
return $hero;
}
public static function toDtoInfo($row){
$attr = emptyReplace(json_decode($row['rand_attr'], true), array());
$todayGetGold = $row['today_get_gold'];
$lastGetGoldTime = $row['last_get_gold_time'];
if (myself()->_getDaySeconds($lastGetGoldTime) <
myself()->_getNowDaySeconds()) {
$todayGetGold = 0;
}
$todayPveGetCeg = $row['today_pve_get_ceg'];
$lastPveGetCegTime = $row['last_pve_get_ceg_time'];
if (myself()->_getDaySeconds($lastPveGetCegTime) <
myself()->_getNowDaySeconds()) {
$todayPveGetCeg = 0;
}
$baseAttr=[];
$attrPro=[];
$hero_name = 'XXX';
$heroMeta = mt\Hero::get($row['hero_id']);
if ($heroMeta) {
$hero_name = $heroMeta['name'];
$baseAttr = mt\Hero::getHeroAttr($heroMeta);
$attrPro1=[];
if ($row['hero_lv']>1){
$attrPro1 = self::getAttrProByLevel($row,$baseAttr,$attr);
}
$attrPro2=[];
if ($row['quality']>1){
$attrPro2 = self::getAttrProByQuality($row,$baseAttr);
}
$attrPro = self::mergeAttrPro($baseAttr,$attrPro1,$attrPro2);
}
$skill_common = explode("|",$row['skill_common']);
$attr_skill = [];
foreach ($skill_common as $val){
$item = mt\SkillCommon::getAttrBySkillCommon($val);
if ($item){
array_push($attr_skill,$item);
}
}
$rand_attr = $baseAttr;
if ($attrPro){
foreach ($rand_attr as $k=>$value){
foreach ($attrPro as $val){
if ($val['attr_id'] == $value['attr_id']){
$rand_attr[$k]['val'] = $val['val'];
}
}
}
}
if ($attr_skill){
$rand_attr = self::_mergeArr(array_merge($rand_attr,$attr_skill));
}
$heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']);
$info = array(
'idx' => $row['idx'],
'token_id' => $row['token_id'],
'hero_uniid' => $row['idx'],
'hero_name' => $hero_name,
'hero_id' => $row['hero_id'],
'hero_lv' => $row['hero_lv'],
'hero_tili' => $row['hero_tili'],
'quality' => $row['quality'],
'rand_attr' => array_values($rand_attr),
// 'attr_base' => $baseAttr,
// 'attr_pro' => $attrPro,
// 'attr_skill' => $attr_skill,
'current_pvp_get_ceg' => $todayGetGold / 100,
'current_pve_get_ceg' => $todayPveGetCeg / 100,
'advanced_count' => $row['advanced_count'],
'lucky' => strval($heroLucky),
'chip_ids' => $row['chip_ids'],
'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],1)), //计算ceg上限所需参数
'skill_points' => $row['skill_points'],
'labour' => $row['labour'],
);
$info['hero_tili_max'] = strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength($info['quality'],$info['lucky']),3));
$info['pvp_ceg_uplimit'] =strval( round(FormulaService::getHeroPvpDailyCegUpLimit($info),2) );
$info['pve_ceg_uplimit'] = strval( round(FormulaService::getHeroPveDailyCegUpLimit($info),2) );
return $info;
}
private static function _mergeArr($data){
if ($data){
$result = array();
foreach ($data as $value){
$key = $value['attr_id'];
if(!isset($result[$key])){
$result[$key] = array(
'attr_id'=>$value['attr_id'],
'type'=>$value['type'],
'val'=>$value['val'],
);
}else{
$result[$key]['val'] += $value['val'];
}
}
return $result;
}
}
public static function getHeroByItemId($itemId){
$hero = array();
self::getHeroList(function ($row) use (&$hero,$itemId) {
if ($row['hero_id'] == $itemId) {
array_push($hero,$row);
}
});
return $hero;
}
}