102 lines
3.0 KiB
PHP
102 lines
3.0 KiB
PHP
<?php
|
|
|
|
require_once('models/User.php');
|
|
require_once('models/Hero.php');
|
|
|
|
require_once('mt/Parameter.php');
|
|
require_once('mt/Drop.php');
|
|
require_once('mt/EquipUpgrade.php');
|
|
require_once('mt/Season.php');
|
|
require_once('mt/RankReward.php');
|
|
require_once('mt/Equip.php');
|
|
require_once('mt/Hero.php');
|
|
require_once('mt/Robot.php');
|
|
|
|
require_once('services/PropertyChgService.php');
|
|
require_once('services/SeasonService.php');
|
|
require_once('services/BattleDataService.php');
|
|
|
|
use phpcommon\SqlHelper;
|
|
use models\User;
|
|
use models\Hero;
|
|
|
|
class BattleController extends BaseAuthedController {
|
|
|
|
public function battleReport()
|
|
{
|
|
$userInfo = $this->_getOrmUserInfo();
|
|
if (!$userInfo) {
|
|
$this->_rspErr(1, '没有这个玩家1');
|
|
return;
|
|
}
|
|
$this->updateUserBaseInfo($userInfo);
|
|
$this->updateMission($userInfo);
|
|
$this->_rspOk();
|
|
}
|
|
|
|
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)
|
|
{
|
|
|
|
}
|
|
|
|
}
|