diff --git a/doc/Battle.py b/doc/Battle.py index 0d290e6..e8e73ed 100644 --- a/doc/Battle.py +++ b/doc/Battle.py @@ -39,6 +39,9 @@ class Battle(object): ['ride_car_move_distance', 0, '驾驶或乘坐载具累计移动X米'], ['ride_car_kills', 0, '驾驶或乘坐载具累计击杀X个敌人'], ['max_hero_skill_lv', 0, '单局内英雄技能升级到X级'], + ['weapons_type', '', '武器信息 weapon_id:kills:damage_out:obtain_count|'], + ['weapons_slot', '', '武器信息 weapon_id:use_times|'], + ['heros', '', '武器信息 hero_id:skill_lv:weapon_lv|'], ['rank_score', 0, '排位积分'], ['pass_score', 0, '通行证积分'], diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index ee33d82..cae5519 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -48,7 +48,7 @@ namespace services; "hero_data": { "${hero_id}": { - "skinll_lv": 1, + "skill_lv": 1, "weapon_lv": 1, } }, @@ -66,6 +66,11 @@ namespace services; } */ +require_once('mt/Item.php'); +require_once('mt/Equip.php'); + +use phpcommon\SqlHelper; + class BattleDataService extends BaseService { private $seasonDb = array(); @@ -124,12 +129,93 @@ class BattleDataService extends BaseService { $this->incValue($battleData, 'ride_car_move_distance', getReqVal('ride_car_move_distance', 0)); $this->incValue($battleData, 'ride_car_kills', getReqVal('ride_car_kills', 0)); $this->maxValue($battleData, 'max_single_battle_hero_lv', getReqVal('max_single_battle_hero_lv', 0)); + $this->procWeaponEquip($battleData); + $this->procWeaponSlot($battleData); + $this->procHeros($battleData); if (!isset($battleData['createtime'])) { $battleData['createtime'] = myself()->_getNowTime(); } $battleData['modifytime'] = myself()->_getNowTime(); } + private function procWeaponsEquip(&$battleData) + { + if (!isset($battleData['weapons_type_data'])) { + $battleData['weapons_type_data'] = array(); + } + $weaponsTypeDb = &$battleData['weapons_type_data']; + { + $tmpStrs1 = explode('|', getReqVal('weapons_type', '')); + foreach ($tmpStrs1 as $str) { + $tmpStrs2 = explode(':', $str); + if (count($tmpStrs2) >= 4) { + list($weaponId, $kills, $damageOut, $obtainCount) = $tmpStrs2; + $weaponMeta = mt\Equip::get($weaponId); + if ($weaponMeta) { + $key = $weaponMeta['equip_type'] . '_' . $weaponMeta['equip_subtype']; + if (!isset($weaponsTypeDb[$key])) { + $weaponsTypeDb[$key] = array(); + } + $this->incValue($weaponsTypeDb, 'kills', $kills); + $this->incValue($weaponsTypeDb, 'damage_out', $damage_out); + $this->incValue($weaponsTypeDb, 'obtain_count', $obtainCount); + } + } + } + } + } + + private function procWeaponsSlot(&$battleData) + { + if (!isset($battleData['weapons_slot_data'])) { + $battleData['weapons_slot_data'] = array(); + } + $weaponsSlotDb = &$battleData['weapons_slot_data']; + { + $tmpStrs1 = explode('|', getReqVal('weapons_slot', '')); + foreach ($tmpStrs1 as $str) { + $tmpStrs2 = explode(':', $str); + if (count($tmpStrs2) >= 4) { + list($weaponId, $use_times) = $tmpStrs2; + $weaponMeta = mt\Equip::get($weaponId); + if ($weaponMeta && $weaponMeta['inventory_slot'] > 0) { + $key = $weaponMeta['inventory_slot']; + if (!isset($weaponsSlotDb[$key])) { + $weaponsSlotDb[$key] = array(); + } + $this->incValue($weaponsSlotDb, 'use_times', $kills); + } + } + } + } + } + + private function procHeros(&$battleData) + { + if (!isset($battleData['hero_data'])) { + $battleData['hero_data'] = array(); + } + $heroDb = &$battleData['hero_data']; + { + $tmpStrs1 = explode('|', getReqVal('heros', '')); + foreach ($tmpStrs1 as $str) { + $tmpStrs2 = explode(':', $str); + if (count($tmpStrs2) >= 4) { + list($heroId, $skillLv, $weaponLv) = $tmpStrs2; + $heroMeta = mt\Item::get($heroId); + if ($heroMeta && $heroMeta['type'] == mt\Item::HERO_TYPE) { + $key = $heroMeta['id']; + if (!isset($heroDb[$key])) { + $heroDb[$key] = array(); + } + $this->maxValue($heroDb, 'skill_lv', $skillLv); + $this->maxValue($heroDb, 'weapon_lv', $weaponLv); + } + } + } + } + } + private function incValue(&$battleData, $key, $val) { if ($val > 0) { diff --git a/webapp/services/MissionService.php b/webapp/services/MissionService.php index 60103ab..7644d35 100644 --- a/webapp/services/MissionService.php +++ b/webapp/services/MissionService.php @@ -195,7 +195,7 @@ class MissionService extends BaseService { case mt\Task::BATTLE_IN_GUN_LV_COND: { //单局内英雄专属枪械升到X级 cond_param1=英雄id - $missionDto['current'] = $this->getHeroLv($missionDb, $missionMeta); + $missionDto['current'] = $this->getHeroSkillLv($missionDb, $missionMeta); } break; case mt\Task::TOTAL_MEDICINE_TIMES_COND: @@ -461,7 +461,7 @@ class MissionService extends BaseService { return $val; } - private function getHeroLv($missionDb, $missionMeta) + private function getHeroSkillLv($missionDb, $missionMeta) { //'max_single_battle_hero_weapon_lv' . $missionMeta['param1'] $val = 0; @@ -471,7 +471,7 @@ class MissionService extends BaseService { $key = $missionMeta['param1']; $data = getXVal($heroData, $key, null); if ($data) { - $val = getXVal($data, 'hero_lv', 0); + $val = getXVal($data, 'skill_lv', 0); } } return $val;