This commit is contained in:
aozhiwei 2021-12-14 17:04:45 +08:00
parent a067f08f62
commit fc0d165440
4 changed files with 107 additions and 63 deletions

View File

@ -38,6 +38,7 @@ class Battle(object):
['use_skill_times', 0, '使用技能次数'], ['use_skill_times', 0, '使用技能次数'],
['ride_car_move_distance', 0, '驾驶或乘坐载具累计移动X米'], ['ride_car_move_distance', 0, '驾驶或乘坐载具累计移动X米'],
['ride_car_kills', 0, '驾驶或乘坐载具累计击杀X个敌人'], ['ride_car_kills', 0, '驾驶或乘坐载具累计击杀X个敌人'],
['max_hero_skill_lv', 0, '单局内英雄技能升级到X级'],
['rank_score', 0, '排位积分'], ['rank_score', 0, '排位积分'],
['pass_score', 0, '通行证积分'], ['pass_score', 0, '通行证积分'],

View File

@ -1,7 +1,6 @@
<?php <?php
require_once('models/User.php'); require_once('models/User.php');
require_once('models/Hero.php');
require_once('mt/Parameter.php'); require_once('mt/Parameter.php');
require_once('mt/Drop.php'); require_once('mt/Drop.php');
@ -9,8 +8,6 @@ require_once('mt/EquipUpgrade.php');
require_once('mt/Season.php'); require_once('mt/Season.php');
require_once('mt/RankReward.php'); require_once('mt/RankReward.php');
require_once('mt/Equip.php'); require_once('mt/Equip.php');
require_once('mt/Hero.php');
require_once('mt/Robot.php');
require_once('services/PropertyChgService.php'); require_once('services/PropertyChgService.php');
require_once('services/SeasonService.php'); require_once('services/SeasonService.php');
@ -18,7 +15,6 @@ require_once('services/BattleDataService.php');
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
use models\User; use models\User;
use models\Hero;
class BattleController extends BaseAuthedController { class BattleController extends BaseAuthedController {
@ -36,61 +32,6 @@ class BattleController extends BaseAuthedController {
private function updateUserBaseInfo($userInfo) private function updateUserBaseInfo($userInfo)
{ {
$fieldsKv = array(
'total_battle_times' => function () {
return 'total_battle_times + 1';
},
);
if (getReqVal('rank', 0) == 1) {
$fieldsKv['total_win_times'] = function () {
return 'total_win_times + 1';
};
}
$kills = getReqVal('kills', 0);
if ($kills > 0) {
$fieldsKv['total_kills_times'] = function () {
return "total_kills_times + ${kills}";
};
$fieldsKv['max_kills_times'] = function () {
return "GREATEST(max_kills_times, ${kills})";
};
}
$damageOut = getReqVal('damage_out', 0);
if ($damageOut > 0) {
$fieldsKv['total_damage_out'] = function () {
return "total_damage_out + ${damageOut}";
};
$fieldsKv['max_damage_out'] = function () {
return "GREATEST(max_damage_out, ${damageOut})";
};
}
$damageIn = getReqVal('damage_in', 0);
if ($damageIn > 0) {
$fieldsKv['total_damage_in'] = function () {
return "total_damage_in + ${damageIn}";
};
}
$recoverHp = getReqVal('recover_hp', 0);
if ($recoverHp > 0) {
$fieldsKv['total_recover_hp'] = function () {
return "total_recover_hp + ${recoverHp}";
};
$fieldsKv['max_recover_hp'] = function () {
return "GREATEST(max_recover_hp, ${recoverHp})";
};
}
$aliveTime = getReqVal('alive_time', 0);
if ($aliveTime > 0) {
$fieldsKv['total_alive_time'] = function () {
return "total_alive_time + ${aliveTime}";
};
$fieldsKv['max_alive_time'] = function () {
return "GREATEST(max_alive_time, ${aliveTime})";
};
}
if (count($fieldsKv) > 0) {
$this->_updateUserInfo($fieldsKv);
}
} }
private function updateMission($userInfo) private function updateMission($userInfo)

View File

@ -16,6 +16,7 @@ namespace services;
"total_damage_out":0, "total_damage_out":0,
"max_damage_out": 0, "max_damage_out": 0,
"total_damage_in": 0, "total_damage_in": 0,
"max_damage_in": 0,
"total_recover_hp": 0, "total_recover_hp": 0,
"max_recover_hp": 0, "max_recover_hp": 0,
"total_alive_time": 0, "total_alive_time": 0,
@ -29,7 +30,7 @@ namespace services;
"use_skill_times": 0, "use_skill_times": 0,
"ride_car_move_distance": 0, "ride_car_move_distance": 0,
"ride_car_kills": 0, "ride_car_kills": 0,
"to_teammate_like_times": 0, "max_hero_skill_lv": 0,
"weapon_type_data": { "weapon_type_data": {
"${equip_type}_${equip_subtype}": "${equip_type}_${equip_subtype}":
{ {
@ -44,6 +45,13 @@ namespace services;
"use_times": 1, "use_times": 1,
} }
}, },
"hero_data": {
"${hero_id}":
{
"skinll_lv": 1,
"weapon_lv": 1,
}
},
"createtime": 0, "createtime": 0,
"modifytime": 0, "modifytime": 0,
} }
@ -60,4 +68,83 @@ namespace services;
class BattleDataService extends BaseService { class BattleDataService extends BaseService {
private $seasonDb = array();
private $hisBattleData = array();
public function updateBattleData()
{
}
private function apply(&$battleData)
{
$this->incValue($battleData, 'total_battle_times', 1);
if (getReqVal('team_mode', 0) == 0) {
$this->incValue($battleData, 'total_single_battle_times', 1);
$this->minValue($battleData, 'single_battle_rank', getReqVal('ranked', 0));
} else {
$this->minValue($battleData, 'team_battle_rank', getReqVal('ranked', 0));
$this->incValue($battleData, 'total_team_battle_times', 1);
}
if (getReqVal('ranked', 0) == 1) {
$this->incValue($battleData, 'total_win_times', 1);
}
$kills = getReqVal('kills', 0);
if ($kills > 0) {
$this->incValue($battleData, 'total_kills_times', $kills);
$this->maxValue($battleData, 'max_kills_times', $kills);
}
$damageOut = getReqVal('damage_out', 0);
if ($damageOut > 0) {
$this->incValue($battleData, 'total_damage_out', $damageOut);
$this->maxValue($battleData, 'max_damage_out', $damageOut);
}
$damageIn = getReqVal('damage_in', 0);
if ($damageIn > 0) {
$this->incValue($battleData, 'total_damage_in', $damageIn);
$this->maxValue($battleData, 'max_damage_in', $damageIn);
}
$recoverHp = getReqVal('recover_hp', 0);
if ($recoverHp > 0) {
$this->incValue($battleData, 'total_recover_hp', $recoverHp);
$this->maxValue($battleData, 'max_recover_hp', $recoverHp);
}
$aliveTime = getReqVal('alive_time', 0);
if ($aliveTime > 0) {
$this->incValue($battleData, 'total_alive_time', $aliveTime);
$this->maxValue($battleData, 'max_alive_time', $aliveTime);
}
$this->incValue($battleData, 'rescue_teammate_times', getReqVal('rescue_teammate_times', 0));
$this->incValue($battleData, 'diving_times', getReqVal('diving_times', 0));
$this->incValue($battleData, 'open_airdrop_times', getReqVal('open_airdrop_times', 0));
$this->incValue($battleData, 'use_medicine_times', getReqVal('use_medicine_times', 0));
$this->incValue($battleData, 'destory_car_times', getReqVal('destory_car_times', 0));
$this->incValue($battleData, 'use_camouflage_times', getReqVal('use_camouflage_times', 0));
$this->incValue($battleData, 'use_skill_times', getReqVal('use_skill_times', 0));
$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));
if (!isset($battleData['createtime'])) {
$battleData['createtime'] = myself()->_getNowTime();
}
$battleData['modifytime'] = myself()->_getNowTime();
}
private function incValue(&$battleData, $key, $val)
{
if ($val > 0) {
$battleData[$key] = getXVal($battleData, $key, 0) + $val;
}
}
private function minValue(&$battleData, $key, $val)
{
$battleData[$key] = min(getXVal($battleData, $key, 0), $val);
}
private function maxValue(&$battleData, $key, $val)
{
$battleData[$key] = max(getXVal($battleData, $key, 0), $val);
}
} }

View File

@ -189,14 +189,13 @@ class MissionService extends BaseService {
{ {
//单局内英雄技能升级到X级 //单局内英雄技能升级到X级
$missionDto['current'] = $this->getBattleData($missionDb, $missionMeta, $missionDto['current'] = $this->getBattleData($missionDb, $missionMeta,
'max_single_battle_hero_lv'); 'max_hero_skill_lv');
} }
break; break;
case mt\Task::BATTLE_IN_GUN_LV_COND: case mt\Task::BATTLE_IN_GUN_LV_COND:
{ {
//单局内英雄专属枪械升到X级 cond_param1=英雄id //单局内英雄专属枪械升到X级 cond_param1=英雄id
$missionDto['current'] = $this->getBattleData($missionDb, $missionMeta, $missionDto['current'] = $this->getHeroLv($missionDb, $missionMeta);
'max_single_battle_hero_weapon_lv' . $missionMeta['param1']);
} }
break; break;
case mt\Task::TOTAL_MEDICINE_TIMES_COND: case mt\Task::TOTAL_MEDICINE_TIMES_COND:
@ -462,6 +461,22 @@ class MissionService extends BaseService {
return $val; return $val;
} }
private function getHeroLv($missionDb, $missionMeta)
{
//'max_single_battle_hero_weapon_lv' . $missionMeta['param1']
$val = 0;
$battleData = $this->internalGetBattleData($missionMeta);
$heroData = getXVal($battleData, 'hero_data', null);
if ($weaponData) {
$key = $missionMeta['param1'];
$data = getXVal($heroData, $key, null);
if ($data) {
$val = getXVal($data, 'hero_lv', 0);
}
}
return $val;
}
private function getMissionV($missionMeta, $dailyX, $weeklyX, $hisX, $y) private function getMissionV($missionMeta, $dailyX, $weeklyX, $hisX, $y)
{ {
if ($missionMeta['type'] == mt\Task::DAILY_MISSON_TYPE) { if ($missionMeta['type'] == mt\Task::DAILY_MISSON_TYPE) {