This commit is contained in:
aozhiwei 2021-11-25 11:03:08 +08:00
parent 3fe90b503f
commit cb47c75760
3 changed files with 370 additions and 2 deletions

View File

@ -7,9 +7,9 @@ class User(object):
def __init__(self):
self.apis = [
{
'desc': '获取用户信息信息info',
'desc': '登录login',
'group': 'User',
'url': 'webapp/index.php?c=User&a=info',
'url': 'webapp/index.php?c=User&a=login',
'params': [
_common.ReqHead(),
],
@ -18,4 +18,67 @@ class User(object):
['info',_common.UserInfo(), '用户信息']
]
},
{
'desc': '客户端战报clientBattleReport',
'group': 'User',
'url': 'webapp/index.php?c=User&a=clientBattleReport',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
]
},
{
'desc': '获取机器人信息getRobotInfo',
'group': 'User',
'url': 'webapp/index.php?c=User&a=getRobotInfo',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
['!member_list', _common.RobotInfo(), '机器人数据'],
['!sin_member', _common.RobotMetaInfo(), '机器人列表'],
['num', 0, '货币数量'],
]
},
]
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, '历史最高治疗'],
]
},
]

View File

@ -120,6 +120,7 @@ class UserInfo(object):
['gold', 0, '金币'],
['diamond', 0, '钻石'],
['hero_id', 0, '当前使用的英雄ID'],
['first_fight', 0, '是否是第一次战斗'],
]
class RobotInfo(object):

View File

@ -0,0 +1,304 @@
<?php
require 'classes/Quest.php';
require 'classes/AddReward.php';
require_once('mt/Parameter.php');
require_once('mt/Drop.php');
require_once('mt/EquipUpgrade.php');
require_once('mt/Season.php');
require_once('mt/SeasonPoint.php');
require_once('mt/RankReward.php');
require_once('mt/Equip.php');
require_once('mt/Player.php');
require_once('mt/Robot.php');
class UserController extends BaseAuthedController {
public function login()
{
//$user_name = $_REQUEST['name'];
//$avatar_url = $_REQUEST['avatar_url'];
$user_name = '极乐玩家';
$avatar_url = '18003';
$userInfo = $this->safeGetOrmUserInfo();
if (!$userInfo) {
$this->createNewUser();
$userInfo = $this->getOrmUserInfo();
}
if ($this->loginCheck($userInfo)) {
$userInfo = $this->getOrmUserInfo();
}
$dtoUser = $this->getDtoUserInfo($userInfo);
$dtoUser['errcode'] = 0;
$dtoUser['errmsg'] = '';
$this->rspRawData($dtoUser);
}
private function loginCheck($userInfo)
{
$fieldsKv = array();
if ($userInfo['vip_score'] >= 5 && $userInfo['act_ad_status'] != 2) {
$fieldsKv['act_ad_status'] = 1;
}
if (($this->getNowDaySeconds() - phpcommon\getDaySeconds($userInfo['update_time']) > 0)) {
if ($userInfo['new_second_equip'] == 2 && $userInfo['new_first_equip'] == 1) {
$fieldsKv['new_second_equip'] = 1;
}
$fieldsKv['daily_first_login'] = 0;
$fieldsKv['free_box'] = 0;
$fieldsKv['kefu_status'] = 0;
$fieldsKv['coin_times'] = 0;
$fieldsKv['first_day_ad'] = 0;
$fieldsKv['share_video_times'] = 0;
$fieldsKv['daily_max_single'] = 0;
$fieldsKv['daily_score'] = 0;
$fieldsKv['daily_offline'] = 0;
}
if (count($fieldsKv) > 0) {
$fieldsKv['modify_time'] = $this->getNowTime();
$this->updateUserInfo($fieldsKv);
}
return count($fieldsKv) > 0;
}
private function createNewUser()
{
phpcommon\SqlHelper::upsert
($this->getSelfMysql(),
'user',
array(
'accountid' => $this->getAccountId()
),
array(
),
array(
'accountid' => $this->getAccountId(),
'user_name' => $user_name,
'avatar_url' => $avatar_url,
'coin_num' => 10000,
'season_status' => 1,
'newInfo' => '',
'new_second_equip' => 2,
'head_kuang_id' => 19003,
'sex' => 2,
'hi_id' => 18001,
'hero_id' => 30100,
'integral' => 0,
'season_time' => mt\Season::getCurrSeasonTime(),
'team_name' => '',
'create_time' => phpcommon\getNowTime(),
'modify_time' => phpcommon\getNowTime(),
'update_time' => phpcommon\getNowTime(),
)
);
{
$paramMeta = mt\Parameter::getByName('creator_hero_id');
if ($paramMeta) {
$heros = mt\Parameter::getListValue($paramMeta);
foreach ($heros as $heroId) {
$heroMeta = mt\Player::get($heroId);
if ($heroMeta) {
$this->addHero($heroMeta);
}
}
}
}
{
$this->addItem(array(
'item_id' => 16001,
'item_num' => 0,
));
}
}
public function clientBattleReport()
{
$this->updateUserInfo(array(
'first_fight' => function () {
return '1';
}
));
$this->rspOk();
}
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,
));
}
public function getRobotInfo()
{
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'member_list' => array(mt\Robot::getRandMember()),
'sin_member' => mt\Robot::getSinMembers(),
'num' => Rand(1, 100) * 0.01
));
}
}