diff --git a/doc/Battle.py b/doc/Battle.py new file mode 100644 index 0000000..69eb1a4 --- /dev/null +++ b/doc/Battle.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- + +import _common + +class Battle(object): + + def __init__(self): + self.apis = [ + ] + self.internalApis = [ + { + 'desc': '服务器战报(客户端不用处理)battleReport', + 'group': 'User', + 'url': 'webapp/index.php?c=User&a=battleReport', + 'params': [ + _common.ReqHead(), + ['map_id', 0, '地图id'], + ['map_tpl_name', '', '地图模板名'], + ['room_uuid', 0, '房间唯一id'], + ['map_name', '', '地图名'], + ['game_time', 0, '游戏时间'], + ['hurt', 0, '收到伤害'], + ['rank', 0, '排名'], + ['kills', 0, '击杀数'], + ['harm', 0, '伤害输出'], + ['add_HP', 0, '治疗'], + ['alive_time', 0, '存活时间'], + ['team_status', 0, '是否是组队状态'], + ['snipe_kill', 0, '狙击枪击杀数'], + ['rifle_kill', 0, '步枪击杀数'], + ['pistol_kill', 0, '手枪击杀数'], + ['submachine_kill', 0, '冲锋枪击杀数'], + ['rescue_member', 0, '救起队友次数'], + ['coin_num', 0, '金币'], + ['rank_score', 0, '排位积分'], + ['pass_score', 0, '通行证积分'], + ['items', 0, '道具|分割'], + ], + 'response': [ + _common.RspHead(), + ['kill_his', 0, '历史最高击杀数'], + ['alive_time_his', 0, '历史最高存活时间'], + ['harm_his', 0, '历史最高伤害'], + ['add_HP_his', 0, '历史最高治疗'], + ] + }, + ] diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php new file mode 100644 index 0000000..19e17eb --- /dev/null +++ b/webapp/controller/BattleController.class.php @@ -0,0 +1,191 @@ +_getOrmUserInfo(); + if (!$userInfo) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家1'); + return; + } + $this->oldBattleReport($userInfo); + } + + private function oldBattleReport($userInfo) + { + $map_id = isset($_REQUEST['map_id']) ? $_REQUEST['map_id'] : 0; + $map_tpl_name = isset($_REQUEST['map_tpl_name']) ? $_REQUEST['map_tpl_name'] : ''; + $room_uuid = $_REQUEST['room_uuid']; //战斗id + $map_name = $_REQUEST['map_name']; //地图名 + $game_time = $_REQUEST['game_time']; //游戏结束时间 + $hurt = $_REQUEST['hurt']; //承受伤害 + $rank = $_REQUEST['rank']; //排名 + $kills = $_REQUEST['kills']; //击杀数 + $harm = $_REQUEST['harm']; //伤害 + $add_HP = $_REQUEST['add_HP']; //治疗量 + $alive_time = $_REQUEST['alive_time']; //存活时间 + $team_status = $_REQUEST['team_status']; //是否是组队状态 + $snipe_kill = $_REQUEST['snipe_kill']; //狙击枪击杀数 + $rifle_kill = $_REQUEST['rifle_kill']; //步枪击杀数 + $pistol_kill = $_REQUEST['pistol_kill']; //手枪击杀数 + $submachine_kill = $_REQUEST['submachine_kill'];//冲锋枪击杀数 + $rescue_member = $_REQUEST['rescue_member']; //救起队友次数 + $kill_his = $kills; + $harm_his = $harm; + $alive_time_his = $alive_time; + $add_HP_his = $add_HP; + $coin_num = $_REQUEST['coin_num']; //金币 + $integral = $_REQUEST['rank_score']; //排位积分 + $score = $_REQUEST['pass_score']; //通行证积分 + + $nowDaySeconds = $this->_getNowDaySeconds(); + if ($_REQUEST['items'] != '') { + $item_list = splitStr1($_REQUEST['items']); + $addreward = new classes\AddReward(); + $addreward->addReward((int)$item_list[0][0], (int)$item_list[0][1], $this->_getAccountId(), 0, 0); + } + { + $addreward = new classes\AddReward(); + $val = $addreward->getVipVal($this->_getAccountId(), 1); + $coin_num = floor($coin_num + $coin_num * $val / 100); + } + //更新击杀信息时间 + $k = 0; + if ($userInfo['game_times'] != 0) { + $k = $userInfo['kill_his'] / $userInfo['game_times']; + } + if (($userInfo['kill_his'] + $kills) / ($userInfo['game_times'] + 1) != $k) { + $this->_updateUserInfo(array( + 'kill_modifytime' => $this->_getNowTime(), + )); + } + //更新胜场信息时间 + if ($rank == 1) { + $this->_updateUserInfo(array( + 'win_times' => $userInfo['win_times'] + 1, + 'season_win' => $userInfo['season_win'] + 1, + 'win_modifytime' => $this->_getNowTime(), + )); + } + //更新排位积分信息时间 + if ($integral > 0) { + $update_maxscore = $integral + $userInfo['max_integral']; + $update_score = $integral + $userInfo['integral']; + $isProtect = false; + $minScore = 0; + mt\SeasonPoint::calcScore($intergral, $isProtect, $minScore); + if ($isProtect && $minScore > $updateScore) { + $update_score = $minScore; + } + $this->_updateUserInfo(array( + 'integral' => $update_score, + 'rank_modifytime' => $this->_getNowTime(), + 'max_integral' => $update_maxscore, + )); + } + //更新历史最高信息 + $kill_his = max($kill_his, $userInfo['kill_his']); + $harm_his = max($harm_his, $userInfo['harm_his']); + $sea_max_hart = max($harm, $userInfo['sea_max_hart']); + $sea_max_kill = max($kills, $userInfo['sea_max_kill']); + $alive_time_his = max($alive_time_his, $userInfo['alive_time_his']); + $add_HP_his = max($add_HP_his, $userInfo['add_HP_his']); + //添加空投箱 + $box_num = min($userInfo['box_num'] + 1, 20); + + $newhand = $userInfo['newhand']; + $newhand2 = $userInfo['newhand2']; + $game_times2 = $userInfo['game_times2']; + { + $fight_times = mt\Parameter::getByName('newhand_num1')['param_value']; + $view_times = mt\Parameter::getByName('newhand_num2')['param_value']; + $fight_times2 = mt\Parameter::getByName('cream_task_01')['param_value']; + $view_times2 = mt\Parameter::getByName('cream_task_02')['param_value']; + if ($userInfo['game_times'] + 1 == $fight_times && $userInfo['vip_score'] >= $view_times) { + $newhand = 1; + } + if ($newhand == 2) { + if ($userInfo['game_times2'] + 1 == $fight_times2 && $userInfo['view_times2'] >= $view_times2) { + $newhand2 = 1; + } + $game_times2++; + } + } + $this->_updateUserInfo(array( + 'game_times' => function () { + return 'game_times + 1'; + }, + 'kill_his' => $kill_his, + 'kills' => function () use($kills) { + return "kills + ${kills}"; + }, + 'harm_his' => $harm_his, + 'harm' => function () use($harm) { + return "harm + ${harm}"; + }, + 'add_HP' => function () use($add_HP) { + return "add_HP + ${add_HP}"; + }, + 'alive_time' => function () use($alive_time) { + return "alive_time + ${alive_time}"; + }, + 'alive_time_his' => $alive_time_his, + 'add_HP_his' => $add_HP_his, + 'coin_num' => function () use($coin_num) { + return "coin_num + ${coin_num}"; + }, + 'modify_time' => $this->_getNowTime(), + 'box_num' => $box_num, + 'score' => function () { + return 'score'; //?? + }, + 'daily_time' => function () use($nowDaySeconds) { + return 'GREATEST(daily_time, ${nowDaySeconds})'; + }, + 'season_games' => function () { + return 'season_games + 1'; + }, + 'sea_max_kill' => $sea_max_kill, + 'sea_max_hart' => $sea_max_hart, + 'sea_avg_kill' => function () use($kills) { + return "sea_avg_kill + ${kills}"; //?? + }, + 'newhand' => $newhand, + 'newhand2' => $newhand2, + 'game_times2' => $game_times2, + 'first_fight' => 1, + )); + + $addreward = new classes\Addreward(); + $vip_level = $addreward->getVipLevel($this->_getAccountId()); + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'kill_his' => $kill_his, + 'alive_time_his' => $alive_time_his, + 'harm_his' => $harm_his, + 'add_HP_his' => $add_HP_his, + )); + } + +} diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 889fe52..ad1a8e8 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -163,171 +163,4 @@ class UserController extends BaseAuthedController { )); } - public function battleReport() - { - $userInfo = $this->_getOrmUserInfo(); - if (!$userInfo) { - phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家1'); - return; - } - $this->oldBattleReport($userInfo); - } - - private function oldBattleReport($userInfo) - { - $map_id = isset($_REQUEST['map_id']) ? $_REQUEST['map_id'] : 0; - $map_tpl_name = isset($_REQUEST['map_tpl_name']) ? $_REQUEST['map_tpl_name'] : ''; - $room_uuid = $_REQUEST['room_uuid']; //战斗id - $map_name = $_REQUEST['map_name']; //地图名 - $game_time = $_REQUEST['game_time']; //游戏结束时间 - $hurt = $_REQUEST['hurt']; //承受伤害 - $rank = $_REQUEST['rank']; //排名 - $kills = $_REQUEST['kills']; //击杀数 - $harm = $_REQUEST['harm']; //伤害 - $add_HP = $_REQUEST['add_HP']; //治疗量 - $alive_time = $_REQUEST['alive_time']; //存活时间 - $team_status = $_REQUEST['team_status']; //是否是组队状态 - $snipe_kill = $_REQUEST['snipe_kill']; //狙击枪击杀数 - $rifle_kill = $_REQUEST['rifle_kill']; //步枪击杀数 - $pistol_kill = $_REQUEST['pistol_kill']; //手枪击杀数 - $submachine_kill = $_REQUEST['submachine_kill'];//冲锋枪击杀数 - $rescue_member = $_REQUEST['rescue_member']; //救起队友次数 - $kill_his = $kills; - $harm_his = $harm; - $alive_time_his = $alive_time; - $add_HP_his = $add_HP; - $coin_num = $_REQUEST['coin_num']; //金币 - $integral = $_REQUEST['rank_score']; //排位积分 - $score = $_REQUEST['pass_score']; //通行证积分 - - $nowDaySeconds = $this->_getNowDaySeconds(); - if ($_REQUEST['items'] != '') { - $item_list = splitStr1($_REQUEST['items']); - $addreward = new classes\AddReward(); - $addreward->addReward((int)$item_list[0][0], (int)$item_list[0][1], $this->_getAccountId(), 0, 0); - } - { - $addreward = new classes\AddReward(); - $val = $addreward->getVipVal($this->_getAccountId(), 1); - $coin_num = floor($coin_num + $coin_num * $val / 100); - } - //更新击杀信息时间 - $k = 0; - if ($userInfo['game_times'] != 0) { - $k = $userInfo['kill_his'] / $userInfo['game_times']; - } - if (($userInfo['kill_his'] + $kills) / ($userInfo['game_times'] + 1) != $k) { - $this->_updateUserInfo(array( - 'kill_modifytime' => $this->_getNowTime(), - )); - } - //更新胜场信息时间 - if ($rank == 1) { - $this->_updateUserInfo(array( - 'win_times' => $userInfo['win_times'] + 1, - 'season_win' => $userInfo['season_win'] + 1, - 'win_modifytime' => $this->_getNowTime(), - )); - } - //更新排位积分信息时间 - if ($integral > 0) { - $update_maxscore = $integral + $userInfo['max_integral']; - $update_score = $integral + $userInfo['integral']; - $isProtect = false; - $minScore = 0; - mt\SeasonPoint::calcScore($intergral, $isProtect, $minScore); - if ($isProtect && $minScore > $updateScore) { - $update_score = $minScore; - } - $this->_updateUserInfo(array( - 'integral' => $update_score, - 'rank_modifytime' => $this->_getNowTime(), - 'max_integral' => $update_maxscore, - )); - } - //更新历史最高信息 - $kill_his = max($kill_his, $userInfo['kill_his']); - $harm_his = max($harm_his, $userInfo['harm_his']); - $sea_max_hart = max($harm, $userInfo['sea_max_hart']); - $sea_max_kill = max($kills, $userInfo['sea_max_kill']); - $alive_time_his = max($alive_time_his, $userInfo['alive_time_his']); - $add_HP_his = max($add_HP_his, $userInfo['add_HP_his']); - //添加空投箱 - $box_num = min($userInfo['box_num'] + 1, 20); - - $newhand = $userInfo['newhand']; - $newhand2 = $userInfo['newhand2']; - $game_times2 = $userInfo['game_times2']; - { - $fight_times = mt\Parameter::getByName('newhand_num1')['param_value']; - $view_times = mt\Parameter::getByName('newhand_num2')['param_value']; - $fight_times2 = mt\Parameter::getByName('cream_task_01')['param_value']; - $view_times2 = mt\Parameter::getByName('cream_task_02')['param_value']; - if ($userInfo['game_times'] + 1 == $fight_times && $userInfo['vip_score'] >= $view_times) { - $newhand = 1; - } - if ($newhand == 2) { - if ($userInfo['game_times2'] + 1 == $fight_times2 && $userInfo['view_times2'] >= $view_times2) { - $newhand2 = 1; - } - $game_times2++; - } - } - $this->_updateUserInfo(array( - 'game_times' => function () { - return 'game_times + 1'; - }, - 'kill_his' => $kill_his, - 'kills' => function () use($kills) { - return "kills + ${kills}"; - }, - 'harm_his' => $harm_his, - 'harm' => function () use($harm) { - return "harm + ${harm}"; - }, - 'add_HP' => function () use($add_HP) { - return "add_HP + ${add_HP}"; - }, - 'alive_time' => function () use($alive_time) { - return "alive_time + ${alive_time}"; - }, - 'alive_time_his' => $alive_time_his, - 'add_HP_his' => $add_HP_his, - 'coin_num' => function () use($coin_num) { - return "coin_num + ${coin_num}"; - }, - 'modify_time' => $this->_getNowTime(), - 'box_num' => $box_num, - 'score' => function () { - return 'score'; //?? - }, - 'daily_time' => function () use($nowDaySeconds) { - return 'GREATEST(daily_time, ${nowDaySeconds})'; - }, - 'season_games' => function () { - return 'season_games + 1'; - }, - 'sea_max_kill' => $sea_max_kill, - 'sea_max_hart' => $sea_max_hart, - 'sea_avg_kill' => function () use($kills) { - return "sea_avg_kill + ${kills}"; //?? - }, - 'newhand' => $newhand, - 'newhand2' => $newhand2, - 'game_times2' => $game_times2, - 'first_fight' => 1, - )); - - $addreward = new classes\Addreward(); - $vip_level = $addreward->getVipLevel($this->_getAccountId()); - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'kill_his' => $kill_his, - 'alive_time_his' => $alive_time_his, - 'harm_his' => $harm_his, - 'add_HP_his' => $add_HP_his, - )); - } - }