完成battleReport重构移除getSessionId

This commit is contained in:
aozhiwei 2021-11-23 12:04:34 +08:00
parent 422a23c36f
commit ac0f310a7e
3 changed files with 140 additions and 208 deletions

View File

@ -30,11 +30,32 @@ class Role(object):
]
},
{
'desc': 'battleReport',
'desc': '服务器战报(客户端不用处理)battleReport',
'group': 'Role',
'url': 'webapp/index.php?c=Role&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(),
@ -95,17 +116,6 @@ class Role(object):
_common.RspHead(),
]
},
{
'desc': 'getSessionId',
'group': 'Role',
'url': 'webapp/index.php?c=Role&a=getSessionId',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
]
},
{
'desc': 'exchangeCoin',
'group': 'Role',

View File

@ -163,6 +163,11 @@ class RoleController extends BaseAuthedController {
public function battleReport()
{
$userInfo = $this->getOrmUserInfo();
if (!$userInfo) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家1');
return;
}
$taskObj = new NTaskController();
$taskObj->updateTaskToDB(PLAY_GAME, 1);
@ -177,15 +182,14 @@ class RoleController extends BaseAuthedController {
$helpOtherPlayer = $_REQUEST['rescue_member'];
$taskObj->updateTaskToDB(HELP_OP70008, $helpOtherPlayer);
$this->oldBattleReport();
$this->oldBattleReport($userInfo);
}
private function oldBattleReport()
private function oldBattleReport($userInfo)
{
$account_id = $_REQUEST['account_id']; //账号
$conn = $this->getMysql($account_id);
$map_id = $_REQUEST['map_id'];
$map_tpl_name = $_REQUEST['map_tpl_name'];
$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']; //游戏结束时间
@ -209,186 +213,123 @@ class RoleController extends BaseAuthedController {
$integral = $_REQUEST['rank_score']; //排位积分
$score = $_REQUEST['pass_score']; //通行证积分
$nowDaySeconds = $this->getNowDaySeconds();
if ($_REQUEST['items'] != '') {
$item_list = $this->getExplode($_REQUEST['items']);
$addreward = new classes\AddReward();
$addreward->addReward((int)$item_list[0][0], (int)$item_list[0][1], $account_id, 0, 0);
}
if (!$map_id) {
$map_id = 0;
}
if (!$map_tpl_name) {
$map_tpl_name = '';
}
{
$addreward = new classes\AddReward();
$val = $addreward->getVipVal($account_id, 1);
$coin_num = floor($coin_num + $coin_num * $val / 100);
$row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家1');
return;
}
//更新击杀信息时间
$k = 0;
if ($row['game_times'] != 0) {
$k = $row['kill_his'] / $row['game_times'];
if ($userInfo['game_times'] != 0) {
$k = $userInfo['kill_his'] / $userInfo['game_times'];
}
if (($row['kill_his'] + $kills) / ($row['game_times'] + 1) != $k) {
$killret = $conn->execScript('UPDATE user SET kill_modifytime=:kill_modifytime ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':kill_modifytime' => phpcommon\getNowTime(),
if (($userInfo['kill_his'] + $kills) / ($userInfo['game_times'] + 1) != $k) {
$this->updateUserInfo(array(
'kill_modifytime' => $this->getNowTime(),
));
if (!$killret) {
die();
return;
}
}
//更新胜场信息时间
if ($rank == 1) {
$winret = $conn->execScript('UPDATE user SET win_times=:win_times, season_win=:season_win, win_modifytime=:win_modifytime ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':win_times' => $row['win_times'] + 1,
':season_win' => $row['season_win'] + 1,
':win_modifytime' => phpcommon\getNowTime(),
$this->updateUserInfo(array(
'win_times' => $userInfo['win_times'] + 1,
'season_win' => $userInfo['season_win'] + 1,
'win_modifytime' => $this->getNowTime(),
));
if (!$winret) {
die();
return;
}
}
//更新排位积分信息时间
if ($integral != 0) {
$min_score = 0;
$update_maxscore = $row['max_integral'];
if ($integral > 0) {
$update_maxscore = $integral + $row['max_integral'];
$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;
}
$update_score = $integral + $row['integral'];
$is_pro = 0;
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
$seaPoint = mt\SeasonPoint::getOldSeasonPoint($ii);
if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max']
|| $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1) {
$is_pro = $seaPoint['is_protect'];
$min_score = $seaPoint['min'];
}
}
if ($is_pro == 1 && $min_score > $update_score) {
$update_score = $min_score;
}
$inret = $conn->execScript('UPDATE user SET integral=:integral, max_integral=:max_integral, rank_modifytime=:rank_modifytime ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':integral' => $update_score,
':rank_modifytime' => phpcommon\getNowTime(),
':max_integral' => $update_maxscore,
$this->updateUserInfo(array(
'integral' => $update_score,
'rank_modifytime' => $this->getNowTime(),
'max_integral' => $update_maxscore,
));
if (!$inret) {
die();
return;
}
}
//更新历史最高信息
if ($kill_his < $row['kill_his']) {
$kill_his = $row['kill_his'];
}
if ($harm_his < $row['harm_his']) {
$harm_his = $row['harm_his'];
}
$sea_max_hart = $harm;
if ($sea_max_hart < $row['sea_max_hart']) {
$sea_max_hart = $row['sea_max_hart'];
}
$sea_max_kill = $kills;
if ($sea_max_kill < $row['sea_max_kill']) {
$sea_max_kill = $row['sea_max_kill'];
}
if ($alive_time_his < $row['alive_time_his']) {
$alive_time_his = $row['alive_time_his'];
}
if ($add_HP_his < $row['add_HP_his']) {
$add_HP_his = $row['add_HP_his'];
}
$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 = $row['box_num'];
if ($row['box_num'] + 1 <= 20) {
$box_num = $row['box_num'] + 1;
}
$nowTime = phpcommon\getdayseconds(phpcommon\getNowTime());
$daily_time = $row['daily_time'];
if ($daily_time == 0 || ($nowTime - phpcommon\getdayseconds($daily_time) > 0)) {
$daily_time = phpcommon\getNowTime();
}
$daily_first_login = $row['daily_first_login'];
/* $switch = $this->getSwitch($account_id);
if ($switch == 1) {
$daily_first_login = $daily_first_login + 1;
}*/
$box_num = min($userInfo['box_num'] + 1, 20);
$newhand = $row['newhand'];
$newhand2 = $row['newhand2'];
$game_times2 = $row['game_times2'];
$p1 = mt\Parameter::getOldParam(NEWHAND_NUM1);
$fight_times = $p1['param_value'];
$p2 = mt\Parameter::getOldParam(NEWHAND_NUM2);
$view_times = $p2['param_value'];
$p3 = mt\Parameter::getOldParam(CREAM_TASK_01);
$fight_times2 = $p3['param_value'];
$p4 = mt\Parameter::getOldParam(CREAM_TASK_02);
$view_times2 = $p4['param_value'];
if ($row['game_times'] + 1 == $fight_times && $row['vip_score'] >= $view_times) {
$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 ($row['game_times2'] + 1 == $fight_times2 && $row['view_times2'] >= $view_times2) {
if ($userInfo['game_times2'] + 1 == $fight_times2 && $userInfo['view_times2'] >= $view_times2) {
$newhand2 = 1;
}
$game_times2++;
}
$ret = $conn->execScript('UPDATE user SET game_times=:game_times, kills=:kills, harm=:harm, add_HP=:add_HP, alive_time=:alive_time, kill_his=:kill_his, alive_time_his=:alive_time_his, harm_his=:harm_his, add_HP_his=:add_HP_his, coin_num=:coin_num, modify_time=:modify_time, first_fight=1, box_num=:box_num, score=:score, daily_time=:daily_time, season_games=:season_games, sea_max_kill=:sea_max_kill, sea_max_hart=:sea_max_hart, sea_avg_kill=:sea_avg_kill, newhand=:newhand, newhand2=:newhand2, game_times2=:game_times2 ' .
'WHERE accountid=:accountid;',
array(
':game_times' => $row['game_times'] + 1,
':kill_his' => $kill_his,
':kills' => $row['kills'] + $kills,
':harm_his' => $harm_his,
':harm' => $row['harm'] + $harm,
':add_HP' => $row['add_HP'] + $add_HP,
':alive_time' => $row['alive_time'] + $alive_time,
':alive_time_his' => $alive_time_his,
':add_HP_his' => $add_HP_his,
':accountid' => $account_id,
':coin_num' => $row['coin_num'] + $coin_num,
':modify_time' => phpcommon\getNowTime(),
':box_num' => $box_num,
':score' => $row['score'],
':daily_time' => $daily_time,
':season_games' => $row['season_games'] + 1,
':sea_max_kill' => $sea_max_kill,
':sea_max_hart' => $sea_max_hart,
':sea_avg_kill' => $row['sea_avg_kill'] + $kills,
':newhand' => $newhand,
':newhand2' => $newhand2,
':game_times2' => $game_times2,
));
if (!$ret) {
die();
return;
}
$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($account_id);
@ -599,38 +540,6 @@ class RoleController extends BaseAuthedController {
));
}
public function getSessionId()
{
$account_id = $_REQUEST['account_id'];
$registertime = $_REQUEST['registertime'];
$session_key = $_REQUEST['session_key'];
$session_id = $this->createSessionId($account_id, $registertime, $session_key);
echo json_encode(array(
'errcode' => 0,
'errmsg'=> '',
'session_id' => $session_id,
));
}
protected function createSessionId($accountid, $registertime, $session_key)
{
$nowtime = phpcommon\getNowTime();
$session_id = $nowtime
. '_'
. $registertime
. '_'
. md5($accountid . 'f3a6a9a5-217a-4079-ab99-b5d69b8212be' . $registertime . $nowtime)
. '_'
. md5('f3a6a9a5-217a-4079-ab99-b5d69b8212be'
. $accountid
. $session_key
. phpcommon\getNowTime()
. rand()
);
return $session_id;
}
public function exchangeCoin()
{
$account_id = $_REQUEST['account_id'];

View File

@ -37,6 +37,19 @@ class SeasonPoint {
return $integral;
}
public static function calcScore($integral, &$isProtect, &$minScore)
{
$isProtect = false;
$minScore = 0;
foreach (self::getMetaList() as $meta) {
if ($integral >= $meta['min'] && $integral <= $meta['max']
|| $integral >= $meta['min'] && $meta['max'] == -1) {
$isProtect = $meta['is_protect'];
$minScore = $meta['min'];
}
}
}
protected static function getMetaList()
{
if (!self::$metaList) {