From 86ad0a3a0d6da7574f88eb244ff55999f93299b4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 22 Dec 2021 16:58:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=88=98=E6=96=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Battle.py | 4 +- webapp/controller/BattleController.class.php | 7 ++ webapp/controller/GMController.class.php | 19 ++++ webapp/models/Hero.php | 13 +++ webapp/services/BattleDataService.php | 91 ++++++++++++++------ 5 files changed, 109 insertions(+), 25 deletions(-) diff --git a/doc/Battle.py b/doc/Battle.py index 7b0460ca..ae31d726 100644 --- a/doc/Battle.py +++ b/doc/Battle.py @@ -31,6 +31,8 @@ class Battle(object): ['map_id', 0, '地图id'], ['map_tpl_name', '', '地图模板名'], ['room_uuid', 0, '房间唯一id'], + ['room_mode', 0, '房间模式 0:吃鸡模式 1:匹配赛模式'], + ['hero_id', 0, '英雄id'], ['map_name', '', '地图名'], ['team_mode', 0, '队伍模式 0:单人 1:组队'], ['game_time', 0, '游戏时间'], @@ -56,7 +58,7 @@ class Battle(object): ['rank_score', 0, '排位积分'], #['pass_score', 0, '通行证积分'], - ['items', 0, '道具|分割'], + ['items', 0, '道具id:道具数量|'], ], 'response': [ _common.RspHead(), diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 513580c0..5a3cdfe7 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -6,6 +6,13 @@ use phpcommon\SqlHelper; class BattleController extends BaseAuthedController { + public function preBattleCheck() + { + $this->_rspData(array( + 'pre_battle_payload' => '' + )); + } + public function battleReport() { $userInfo = $this->_getOrmUserInfo(); diff --git a/webapp/controller/GMController.class.php b/webapp/controller/GMController.class.php index 17e114e4..c363b3be 100644 --- a/webapp/controller/GMController.class.php +++ b/webapp/controller/GMController.class.php @@ -32,6 +32,9 @@ class GMController extends BaseAuthedController { '.additem' => function () use($params) { $this->addItem($params); }, + '.addtili' => function () use($params) { + $this->addTili($params); + }, '.getsystime' => function () use($params) { $this->getSysTime($params); }, @@ -53,6 +56,7 @@ class GMController extends BaseAuthedController { $this->_rspData(array( 'text' => << "hero_tili + ${tili}" + )); + $propertyChgService->addHeroChg(); + $this->_rspData(array( + 'text' => '添加道具成功', + 'award' => $awardService->toDto(), + 'property_chg' => $propertyChgService->toDto(), + )); + } + private function getSysTime($params) { $sysTime = phpcommon\timestamp_to_datetime(phpcommon\getNowTime()); diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 71279806..c3427f31 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -102,4 +102,17 @@ class Hero extends BaseModel { ); } + public static function update($heroId, $fieldsKv) + { + SqlHelper::upsert + (myself()->_getSelfMysql(), + 't_hero', + array( + 'account_id' => myself()->_getAccountId(), + 'hero_id' => $heroId, + ), + $fieldsKv + ); + } + } diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 6168a722..b3d7803e 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -6,14 +6,17 @@ require_once('mt/Item.php'); require_once('mt/Equip.php'); require_once('mt/Season.php'); require_once('mt/Rank.php'); +require_once('mt/Param.php'); require_once('models/Season.php'); require_once('models/Battle.php'); +require_once('models/Bag.php'); use mt; use phpcommon\SqlHelper; use models\Season; use models\Battle; +use models\Bag; class BattleDataService extends BaseService { @@ -21,6 +24,9 @@ class BattleDataService extends BaseService { public function updateBattleData() { + if (!$this->decCost()) { + return; + } $this->currSeasonMeta = mt\Season::getCurrentSeason(); if (!$this->currSeasonMeta) { return; @@ -99,6 +105,7 @@ class BattleDataService extends BaseService { 'battle_data' => json_encode($seasonBattleData), ) ); + $this->addItems(); } private function apply(&$battleData) @@ -255,30 +262,66 @@ class BattleDataService extends BaseService { private function updateScore() { - $userInfo = myself()->_getOrmUserInfo(); - $rankScore = getReqVal('rank_score', 0); - if ($rankScore > 0) { - $newRank = $userInfo['rank']; - $newScore = $userInfo['score']; - mt\Rank::calcNewRankAndScore($userInfo['rank'], $userInfo['score'], $newRank, $newScore, $rankScore); - if ($newRank >= $userInfo['rank'] && $newScore != $userInfo['score']) { - myself()->_updateUserInfo(array( - 'rank' => $newRank, - 'score' => $newScore, - 'history_best_rank' => max($userInfo['rank'], $newRank), - 'score_modifytime' => myself()->_getNowTime(), - 'best_rank_modifytime' => $newRank > $userInfo['rank'] ? - myself()->_getNowTime() : $userInfo['best_rank_modifytime'], - )); - Season::update($this->currSeasonMeta['id'], array( - 'rank' => $newRank, - 'score' => $newScore, - 'history_best_rank' => max($userInfo['rank'], $newRank), - 'score_modifytime' => myself()->_getNowTime(), - 'score_modifytime' => myself()->_getNowTime(), - 'best_rank_modifytime' => $newRank > $userInfo['rank'] ? - myself()->_getNowTime() : $userInfo['best_rank_modifytime'], - )); + if (getReqVal('room_mode', 0) == 0) { + $userInfo = myself()->_getOrmUserInfo(); + $rankScore = getReqVal('rank_score', 0); + if ($rankScore > 0) { + $newRank = $userInfo['rank']; + $newScore = $userInfo['score']; + mt\Rank::calcNewRankAndScore($userInfo['rank'], $userInfo['score'], $newRank, $newScore, $rankScore); + if ($newRank >= $userInfo['rank'] && $newScore != $userInfo['score']) { + myself()->_updateUserInfo(array( + 'rank' => $newRank, + 'score' => $newScore, + 'history_best_rank' => max($userInfo['rank'], $newRank), + 'score_modifytime' => myself()->_getNowTime(), + 'best_rank_modifytime' => $newRank > $userInfo['rank'] ? + myself()->_getNowTime() : $userInfo['best_rank_modifytime'], + )); + Season::update($this->currSeasonMeta['id'], array( + 'rank' => $newRank, + 'score' => $newScore, + 'history_best_rank' => max($userInfo['rank'], $newRank), + 'score_modifytime' => myself()->_getNowTime(), + 'score_modifytime' => myself()->_getNowTime(), + 'best_rank_modifytime' => $newRank > $userInfo['rank'] ? + myself()->_getNowTime() : $userInfo['best_rank_modifytime'], + )); + } + } + } + } + + private function decCost() + { + $heroDb = Hero::find(getReqVal('hero_id', 0)); + if (!$heroDb) { + return false; + } + $costTili = mt\Parameter::getVal('cost_fatigue', 0); + if ($heroDB['tili'] < $costTili) { + return false; + } + Hero::update($heroDb['hero_id'], array( + 'hero_tili' => function () use($costTili) { + return "GREATEST(0, hero_tili - ${costTili})"; + } + )); + return true; + } + + private function addItems() + { + $tmpStrs1 = explode('|', getReqVal('items', '')); + foreach ($tmpStrs1 as $tmpStr) { + $tmpStrs2 = explode(':', $tmpStr); + if (count($tmpStrs2) >= 2) { + $itemId = $tmpStrs2[0]; + $itemNum = $tmpStrs2[1]; + $itemMeta = mt\Item::get($itemId); + if ($itemMeta) { + Bag::addItem($itemId, $itemNum); + } } } }