1
This commit is contained in:
parent
e81ecd22f3
commit
9823c9dabc
@ -462,9 +462,42 @@ class Hero extends BaseModel {
|
||||
|
||||
public static function abilityInfoAddition($baseAbility, $row){
|
||||
$attr = array();
|
||||
$chipPageDb = ChipPage::find($row['idx']);
|
||||
if ($row['quality'] > 1 && $chipPageDb) {
|
||||
$data = emptyReplace(json_decode($chipPageDb['data'], true), array());
|
||||
foreach ($data as $value) {
|
||||
$chipDb = Chip::find($value['chip_id']);
|
||||
if (!empty($chipDb)) {
|
||||
self::mergeAttr($attr, emptyReplace(json_decode($chipDb['rand_attr'], true), array()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($row['quality'] > 1 && $row['skin_id']) {
|
||||
$skinDb = HeroSkin::find($row['skin_id']);
|
||||
if (!empty($skinDb)) {
|
||||
self::mergeAttr($attr, emptyReplace(json_decode($skinDb['rand_attr'], true), array()));
|
||||
}
|
||||
}
|
||||
return self::calcAbility($row['hero_id'], $attr);
|
||||
}
|
||||
|
||||
public static function mergeAttr(&$tarAttrs, $srcAttrs)
|
||||
{
|
||||
foreach ($srcAttrs as $srcAttr) {
|
||||
$found = false;
|
||||
foreach ($tarAttrs as &$tarAttr) {
|
||||
if ($tarAttr['attr_id'] == $srcAttr['attr_id']) {
|
||||
$tarAttr['val'] += $srcAttr['val'];
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}//end for tarAttrs
|
||||
if (!$found) {
|
||||
array_push($tarAttrs, $srcAttr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function calcAbility($heroId, $attr) {
|
||||
$info = array(
|
||||
'hp' => 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user