This commit is contained in:
hujiabin 2022-08-30 11:04:32 +08:00
parent 1ddb13b8fb
commit a34b5da0af

View File

@ -48,8 +48,13 @@ class HeroController extends BaseAuthedController {
$this->_rspErr(1, 'Please enter instructions'); $this->_rspErr(1, 'Please enter instructions');
return; return;
} }
$heroDb = Hero::find($unique_id);
if (! $heroDb){
$this->_rspErr(1, "You don't have the hero yet");
return;
}
$chipAttr = []; $chipAttr = [];
$hero = Hero::toDto(Hero::find($unique_id)); $hero = Hero::toDto($heroDb);
$chipIdsArr = explode('|',$hero['chip_ids']); $chipIdsArr = explode('|',$hero['chip_ids']);
foreach ($chipIdsArr as $val){ foreach ($chipIdsArr as $val){
$chip = Chip::toDto(Chip::getChipByIdx($val)); $chip = Chip::toDto(Chip::getChipByIdx($val));
@ -65,14 +70,21 @@ class HeroController extends BaseAuthedController {
$item[$v['attr_id']]['val']+= $v['val']; $item[$v['attr_id']]['val']+= $v['val'];
} }
} }
$hero['rand_attr'] = $item; $hero['rand_attr'] = $item;//芯片属性
if ($hero['attr']){ if ($hero['attr']){
$hero_attr = emptyReplace(json_decode($hero['attr'], true), array()); $hero_attr = emptyReplace(json_decode($hero['attr'], true), array());
}else{ }else{
$hero_attr = []; $hero_attr = [];
} }
\mt\AttrHelper::mergeAttr($hero_attr,$chipAttr); \mt\AttrHelper::mergeAttr($hero_attr,$chipAttr);
$hero['attr'] = $hero_attr; $base_attr = [
['attr_id'=>1,'type'=>1,'val'=>$hero['hp']],
['attr_id'=>5,'type'=>1,'val'=>$hero['speed']],
['attr_id'=>3,'type'=>1,'val'=>$hero['atk']],
['attr_id'=>4,'type'=>1,'val'=>$hero['def']],
];
\mt\AttrHelper::mergeAttr($hero_attr,$base_attr);
$hero['attr'] = $hero_attr;//英雄总属性
$chipCore = []; $chipCore = [];
if (count($chipIdsArr) == 4){ if (count($chipIdsArr) == 4){
$min = 15; $min = 15;