From ac9b9f1411b78ca796085d983afd98474b7fda03 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 13 Dec 2021 19:37:12 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 16 ++ third_party/phpcommon | 2 +- webapp/controller/BattleController.class.php | 183 +----------------- webapp/controller/RankingController.class.php | 42 +++- webapp/services/BattleDataService.php | 7 + 5 files changed, 66 insertions(+), 184 deletions(-) create mode 100644 webapp/services/BattleDataService.php diff --git a/sql/gamedb.sql b/sql/gamedb.sql index d4e56ea..f1db00f 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -249,6 +249,22 @@ CREATE TABLE `t_mission` ( ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `t_battle` +-- + +DROP TABLE IF EXISTS `t_battle`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_battle` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', + `data` mediumblob COMMENT 'data', + PRIMARY KEY (`idx`), + UNIQUE KEY `account_id` (`account_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `t_season` -- diff --git a/third_party/phpcommon b/third_party/phpcommon index 0732336..80d7222 160000 --- a/third_party/phpcommon +++ b/third_party/phpcommon @@ -1 +1 @@ -Subproject commit 07323361e8abd576aa74a7fab9d2def0d7bee089 +Subproject commit 80d7222a4a31e295fffbf09fc1880940b4eb630b diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 2c80eaf..486d354 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -14,6 +14,7 @@ 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; @@ -29,7 +30,6 @@ class BattleController extends BaseAuthedController { return; } $this->updateUserBaseInfo($userInfo); - $this->updateSeason($userInfo); $this->updateMission($userInfo); $this->_rspOk(); } @@ -93,190 +93,9 @@ class BattleController extends BaseAuthedController { } } - private function updateSeason($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})"; - }; - } - $currSeasonMeta = mt\Season::getCurrentSeason(); - if ($currSeasonMeta && count($fieldsKv) > 0) { - $seasonService = new services\SeasonService(); - if (!$seasonService->checkSeason($userInfo)) { - $userInfo = $this->_safeGetOrmUserInfo(); - } - $seasonDb = Season::find($currSeasonMeta['id']); - if (!$seasonDb) { - Season::add($currSeasonMeta['id']); - $seasonDb = Season::find($currSeasonMeta['id']); - } - Season::update($fieldsKv); - } - } - private function updateMission($userInfo) { } - private function old() - { - //更新击杀信息时间 - $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}"; //?? - }, - 'first_fight' => 1, - )); - - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - )); - } - } diff --git a/webapp/controller/RankingController.class.php b/webapp/controller/RankingController.class.php index f272449..5b6c023 100644 --- a/webapp/controller/RankingController.class.php +++ b/webapp/controller/RankingController.class.php @@ -1,14 +1,54 @@ _getOrmUserInfo(); $type = getReqVal('type', 0); + $userList = array(); + { + SqlHelper::ormSelect( + myself()->_getSelfMysql(), + 't_user', + array( + ), + function ($row) use(&$userList) { + array_push($userList, User::info($row)); + } + ); + } + $rankingList = array(); + $ranked = 1; + foreach ($userList as $user) { + array_push($rankingList, array( + 'ranked' => $ranked++, + 'account_id' => $user['account_id'], + 'name' => $user['name'], + 'name' => $user['name'], + 'sex' => $user['sex'], + 'head_id' => $user['hero_id'], + 'head_frame' => $user['head_frame'], + 'level' => $user['level'], + 'exp' => $user['exp'], + 'rank' => $user['rank'], + 'score' => $user['score'], + 'gold' => $user['gold'], + 'diamond' => $user['diamond'], + 'hero_id' => $user['hero_id'], + 'first_fight' => $user['first_fight'], + )); + } + $rankingData = array( 'type' => $type, - 'ranking_list' => array(), + 'ranking_list' => $rankingList, 'my_ranked' => array( 'ranked' => -1, 'account_id' => $this->_getAccountId(), diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php new file mode 100644 index 0000000..0364980 --- /dev/null +++ b/webapp/services/BattleDataService.php @@ -0,0 +1,7 @@ +