From 9f0aa042b4a78f27dd7d8cd8ea812d00562ff8fc Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 1 Sep 2022 19:36:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9E=AA=E6=A2=B0equip?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E5=9F=BA=E7=A1=80=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/bootstrap/constant.php | 1 + webapp/controller/ChipController.class.php | 17 +++++--- webapp/models/Gun.php | 4 +- webapp/mt/Equip.php | 50 ++++++++++++++++++++++ webapp/mt/Hero.php | 34 ++++++++------- 5 files changed, 83 insertions(+), 23 deletions(-) diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index 9a5033ef..61507881 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -70,6 +70,7 @@ const kHAT_Critical = 42; const kHAT_CriDamage = 43; const kHAT_Dodge = 44; const kHAT_Ruduce = 45; +const kHAT_BrainLifePct = 47; const kHAT_ABS_VAL = 1; const kHAT_RATE_VAL = 2; diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index c53a4e55..f03eba56 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -5,7 +5,6 @@ require_once('models/Hero.php'); require_once('models/Gun.php'); require_once('models/User.php'); require_once('mt/ChipAttr.php'); -require_once('mt/AttrHelper.php'); require_once('services/FormulaService.php'); @@ -491,7 +490,6 @@ class ChipController extends BaseAuthedController // Chip::update($chip['token_id'],['strength'=>$tili]); // } // $this->_rspOk(); - print_r(Chip::getChipByIdx(10052)) ; } @@ -637,7 +635,8 @@ class ChipController extends BaseAuthedController } private function _inLayNewAttrGun($gun_id){ - $gun = Gun::find($gun_id); + $gunDb = Gun::find($gun_id); + $gun = Gun::toDto($gunDb); $chipAttr = []; if (! $gun['chip_ids'] ){ return $gun; @@ -657,9 +656,15 @@ class ChipController extends BaseAuthedController } } } - $gun_attr = emptyReplace(json_decode($gun['rand_attr'], true), array()); - \mt\AttrHelper::mergeAttr($gun_attr,$chipAttr); - $gun['rand_attr'] = $gun_attr; + $item = []; + foreach ($chipAttr as $k=>$v){ + if (!isset($item[$v['attr_id']])){ + $item[$v['attr_id']] = $v; + }else{ + $item[$v['attr_id']]['val']+= $v['val']; + } + } + $gun['attr_chip'] = $item;//芯片属性 return $gun; } diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 1afd598c..38db6b01 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -142,8 +142,8 @@ class Gun extends BaseModel { $itemMeta = mt\Item::get($row['gun_id']); $baseAttr=[]; if ($itemMeta) { - $baseAttr = mt\Item::getBaseAttrs($itemMeta); -// mt\AttrHelper::mergeAttr($attr, $baseAttr); + $baseAttr = mt\Equip::getGunBaseAttrs($itemMeta['relationship']); +// $baseAttr = mt\Item::getBaseAttrs($itemMeta); } $todayGetGold = $row['today_get_gold']; $lastGetGoldTime = $row['last_get_gold_time']; diff --git a/webapp/mt/Equip.php b/webapp/mt/Equip.php index ae9bd2ad..a2d67cbf 100644 --- a/webapp/mt/Equip.php +++ b/webapp/mt/Equip.php @@ -11,6 +11,56 @@ class Equip { return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null; } + public static function getGunBaseAttrs($id){ + $mate = self::get($id); + $attr = array(); + if ($mate){ + $fields = [ + [//攻击力-固定值 + 'attr_id' => kHAT_Atk, + 'type' => kHAT_ABS_VAL, + 'field_name' => 'atk' + ],[//暴击率-百分比 + 'attr_id' => kHAT_Critical, + 'type' => kHAT_RATE_VAL, + 'field_name' => 'critical' + ],[//暴击伤害-百分比 + 'attr_id' => kHAT_CriDamage, + 'type' => kHAT_RATE_VAL, + 'field_name' => 'cri_damage' + ],[//射速-固定值 + 'attr_id' => kHAT_FireRate, + 'type' => kHAT_ABS_VAL, + 'field_name' => 'fire_rate' + ],[//弹夹-固定值 + 'attr_id' => kHAT_Volume, + 'type' => kHAT_ABS_VAL, + 'field_name' => 'clip_volume' + ],[//换弹-固定值 + 'attr_id' => kHAT_ReloadTime, + 'type' => kHAT_ABS_VAL, + 'field_name' => 'reload_time' + ],[//射程-固定值 + 'attr_id' => kHAT_ShotRange, + 'type' => kHAT_ABS_VAL, + 'field_name' => 'range' + ],[//攻击吸血-百分比 + 'attr_id' => kHAT_BrainLifePct, + 'type' => kHAT_RATE_VAL, + 'field_name' => 'brain_life_pct' + ], + ]; + foreach ($fields as $field) { + array_push($attr, array( + 'attr_id' => $field['attr_id'], + 'type' => $field['type'], + 'val' => $mate[$field['field_name']] + )); + } + } + return $attr; + } + public static function getOldEquip($id) { $meta = self::get($id); diff --git a/webapp/mt/Hero.php b/webapp/mt/Hero.php index c595fe80..a919f6db 100644 --- a/webapp/mt/Hero.php +++ b/webapp/mt/Hero.php @@ -20,45 +20,49 @@ class Hero { public static function getHeroAttr($meta) { $fields = array( - array( + array(//生命值-固定值 'attr_id' => kHAT_Hp, + 'type' => kHAT_ABS_VAL, 'field_name' => 'hp' ), - array( + array(//攻击力-固定值 'attr_id' => kHAT_Atk, + 'type' => kHAT_ABS_VAL, 'field_name' => 'damage' ), - array( + array(//防御-固定值 'attr_id' => kHAT_Def, + 'type' => kHAT_ABS_VAL, 'field_name' => 'defence' ), - array( + array(//移动速度-固定值 'attr_id' => kHAT_Speed, + 'type' => kHAT_ABS_VAL, 'field_name' => 'move_speed5' - ),array( + ),array(//暴击率-百分比 'attr_id' => kHAT_Critical, + 'type' => kHAT_RATE_VAL, 'field_name' => 'crit_atk' - ),array( + ),array(//暴击伤害-百分比 'attr_id' => kHAT_CriDamage, + 'type' => kHAT_RATE_VAL, 'field_name' => 'crit_atk_damage' - ),array( + ),array(//闪避-百分比 'attr_id' => kHAT_Dodge, + 'type' => kHAT_RATE_VAL, 'field_name' => 'miss' - ),array( + ),array(//闪避减伤-百分比 'attr_id' => kHAT_Ruduce, + 'type' => kHAT_RATE_VAL, 'field_name' => 'miss_damage_ruduce' - ), -// array( -// 'attr_id' => kHAT_View, -// 'field_name' => '' -// ), + ) ); $attr = array(); foreach ($fields as $field) { array_push($attr, array( 'attr_id' => $field['attr_id'], - 'type' => kHAT_ABS_VAL, - 'val' => (int)$meta[$field['field_name']] + 'type' => $field['type'], + 'val' => $meta[$field['field_name']] )); } return $attr;