From 9ac15bd37c160ab0b838d66d45c17a089d6a9ac1 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Mon, 27 Mar 2023 16:45:35 +0800 Subject: [PATCH] 1 --- webapp/bootstrap/constant.php | 9 ++-- .../controller/BaseAuthedController.class.php | 23 +++++++++ .../controller/ChipPageController.class.php | 17 +++++++ webapp/controller/TeamController.class.php | 51 ++++++++++--------- webapp/controller/UserController.class.php | 22 +++++++- webapp/models/ChipPage.php | 15 ++++++ webapp/models/Emoji.php | 1 + webapp/mt/LevelUp.php | 8 +++ webapp/services/TameBattleDataService.php | 1 + 9 files changed, 115 insertions(+), 32 deletions(-) diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index f5a83dff..41cbd5e2 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -18,12 +18,11 @@ define('TN_SHOP', 8003); define('TN_RECHARGE_UPGRADE_TIMES', 8004); define('TN_SHARE_GAMES', 8005); define('TN_HERO_LEVEL_UP', 8006); -define('TN_HERO_QUALITY_UP', 8007); -define('TN_HERO_MAX_LEVEL', 8008); -define('TN_HERO_MAX_QUALITY', 8009); -define('TN_GUN_MAX_QUALITY', 80009); -define('TN_RANK_STATUS', 99999); define('TN_END', 8007); +define('TN_HERO_MAX_LEVEL', 8008); +define('TN_LAST_RANKING_TIME', 8009); +define('TN_RANK_STATUS', 99999); + define('TN_DAILY_BEGIN', 9001); define('TN_DAILY_LOGINS', 9001); diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index ca0ad27d..35c34ba1 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -82,6 +82,29 @@ class BaseAuthedController extends BaseController { die(); } } + $userInfo = $this->_getOrmUserInfo(); + switch (getReqVal('c', '')){ + case 'ChipPage': { + if ($userInfo['level'] < \mt\LevelUp::USER_LEVEL_CHIP_LIMIT){ + $this->_rspErr(1,'Not agreed terms'); + die(); + } + } + break; + case 'Emoji' : { + if ($userInfo['level'] < \mt\LevelUp::USER_LEVEL_EMOJI_LIMIT){ + $this->_rspErr(1,'Not agreed terms'); + die(); + } + } + break; + case 'Parachute' : { + if ($userInfo['level'] < \mt\LevelUp::USER_LEVEL_PARACHUTE_MATCH_LIMIT){ + $this->_rspErr(1,'Not agreed terms'); + die(); + } + } + } /*if (SERVER_ENV == _ONLINE) { if (phpcommon\cmpVersion(getReqVal('_version', ''), '0.2.0') > 0) { if (!$this->isWhiteList() || myself()->_getChannel() != BC_CHANNEL) { diff --git a/webapp/controller/ChipPageController.class.php b/webapp/controller/ChipPageController.class.php index f070b215..59814190 100644 --- a/webapp/controller/ChipPageController.class.php +++ b/webapp/controller/ChipPageController.class.php @@ -37,6 +37,23 @@ class ChipPageController extends BaseAuthedController } public function addChipPage(){ + $userInfo = $this->_getOrmUserInfo(); + if (ChipPage::getCount() == 3){ + if ($userInfo['level'] < \mt\LevelUp::USER_LEVEL_CHIP_PAGE1_MATCH_LIMIT){ + $this->_rspErr(1,'Not agreed terms'); + return ; + } + } + if (ChipPage::getCount() == 4){ + if ($userInfo['level'] < \mt\LevelUp::USER_LEVEL_CHIP_PAGE2_MATCH_LIMIT){ + $this->_rspErr(1,'Not agreed terms'); + return ; + } + } + if (ChipPage::getCount() == 5){ + $this->_rspErr(1,'Maximum'); + return ; + } ChipPage::addChipPage(); $this->_rspOk(); } diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index d5776cb4..aa81910c 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -52,6 +52,10 @@ class TeamController extends BaseAuthedController { //验证pve_instance_id合法性 if ($pveInstanceId){ + if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_PVE_MATCH_LIMIT){ + $this->_rspErr(1,'Not agreed terms'); + return; + } $pveGame = \mt\PveGemini::get($pveInstanceId); if (!$pveGame){ $this->_rspErr(1, 'pve_instance_id error'); @@ -61,16 +65,12 @@ class TeamController extends BaseAuthedController { $this->_rspErr(1, "You can't challenge beyond your level"); return; } -// $temp = array(); -// Hero::getHeroList(function ($row) use ($pveGame,&$temp) { -// if ($row['quality']>=$pveGame['gemini_lv']){ -// array_push($temp,$row); -// } -// }); -// if (count($temp)<1){ -// $this->_rspErr(1, 'Lack of qualified heroes'); -// return; -// } + } + if ($matchMode == self::MATCH_MODE_RANK){ + if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){ + $this->_rspErr(1,'Not agreed terms'); + return; + } } $userDto = User::toPreset($userDb); $userDto['is_leader'] = 1; @@ -116,10 +116,18 @@ class TeamController extends BaseAuthedController { $this->_rspErr(1, 'The team has been disbanded'); return; } -// if (count($teamDb['member_list']) >= $teamDb['slot_num']) { -// $this->_rspErr(2, 'The team is full'); -// return; -// } + $userDb = $this->_getOrmUserInfo(); + if ($teamDb['match_mode'] == self::MATCH_MODE_RANK && + $userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){ + $this->_rspErr(1,'Not agreed terms'); + return; + } + if ($teamDb['match_mode'] == self::MATCH_MODE_PVE && + $userDb['level'] < \mt\LevelUp::USER_LEVEL_PVE_MATCH_LIMIT){ + $this->_rspErr(1,'Not agreed terms'); + return; + } + foreach ($teamDb['member_list'] as $member) { if ($member['account_id'] == $this->_getAccountId()) { $this->_rspData(array( @@ -136,17 +144,10 @@ class TeamController extends BaseAuthedController { $this->_rspErr(1, 'No challenge'); return; } - $pveGame = \mt\PveGemini::get($teamDb['pve_instance_id']); -// $temp = array(); -// Hero::getHeroList(function ($row) use ($pveGame,&$temp) { -// if ($row['quality']>=$pveGame['gemini_lv']){ -// array_push($temp,$row); -// } -// }); -// if (count($temp)<1){ -// $this->_rspErr(1, 'Lack of qualified heroes'); -// return; -// } + if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_PVE_MATCH_LIMIT){ + $this->_rspErr(1,'Not agreed terms'); + return; + } } $userDto = User::toPreset($userDb); diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 75b434d7..8f1d51cf 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -51,7 +51,7 @@ class UserController extends BaseAuthedController { $userInfo = $this->_getOrmUserInfo(); $this->_setV(TN_RANK_STATUS, 0, 1); } - //elo 衰减 + //elo score 衰减 $this->dampingElo($userInfo); $userInfo = $this->_getOrmUserInfo(); //跟新登录时间 @@ -762,13 +762,31 @@ class UserController extends BaseAuthedController { } private function dampingElo($userInfo){ + //每天elo衰减 $time_diff = myself()->_getNowTime()-$userInfo['last_login_time']; if ($userInfo['elo'] > 1500 && floor($time_diff/86400) > 0){ $newElo = min(round(pow(log10(floor($time_diff/86400)),1.5)*350),450); $this->_updateUserInfo(array( 'elo' => $userInfo['elo'] - $newElo )); -// $userInfo = $this->_getOrmUserInfo(); + } + //7天未打排位扣排位分 + $last_ranking_time = $this->_getV(TN_LAST_RANKING_TIME,0); + if ($last_ranking_time && floor((myself()->_getNowTime()-$last_ranking_time)/86400) >= 7){ + $userDb = $this->_getOrmUserInfo(); + $rank_key = mt\Rank::getRankById($userDb['rank'])?mt\Rank::getRankById($userDb['rank'])['rank_order2']:0; + $paramMeta = mt\Parameter::getByName('rank_pass_point'); + if ($paramMeta){ + $valArr = explode('|',$paramMeta['param_value']); + $deductScore = $valArr[$rank_key-1]; + $newRank = $userDb['rank']; + $newScore = $userDb['score'] - $deductScore; + mt\Rank::calcNewRankAndScore( $newRank, $newScore); + $this->_updateUserInfo(array( + 'rank' => $newRank, + 'score' => $newScore, + )); + } } } diff --git a/webapp/models/ChipPage.php b/webapp/models/ChipPage.php index ee0c0c5d..6aa3772b 100644 --- a/webapp/models/ChipPage.php +++ b/webapp/models/ChipPage.php @@ -222,4 +222,19 @@ class ChipPage extends BaseModel $info ); } + + public static function getCount(){ + $rows = SqlHelper::ormSelect( + myself()->_getSelfMysql(), + 't_chip_page', + array( + 'account_id'=> myself()->_getAccountId() + ) + ); + $count = 0; + if ($rows){ + $count = count($rows); + } + return $count; + } } \ No newline at end of file diff --git a/webapp/models/Emoji.php b/webapp/models/Emoji.php index 94da49c3..ab955c73 100644 --- a/webapp/models/Emoji.php +++ b/webapp/models/Emoji.php @@ -40,6 +40,7 @@ class Emoji extends BaseModel $value = explode('|',$row['value']) ; }else{ $value= self::defaultUseEmoji(); + self::updateEmoji(implode('|',$value)); } return $value; } diff --git a/webapp/mt/LevelUp.php b/webapp/mt/LevelUp.php index ac9b180b..38ee5901 100644 --- a/webapp/mt/LevelUp.php +++ b/webapp/mt/LevelUp.php @@ -6,6 +6,14 @@ namespace mt; class LevelUp { + const USER_LEVEL_CHIP_LIMIT = 2; + const USER_LEVEL_EMOJI_LIMIT = 3; + const USER_LEVEL_PVE_MATCH_LIMIT = 4; + const USER_LEVEL_RANK_MATCH_LIMIT = 6; + const USER_LEVEL_PARACHUTE_MATCH_LIMIT = 8; + const USER_LEVEL_CHIP_PAGE1_MATCH_LIMIT = 9; + const USER_LEVEL_CHIP_PAGE2_MATCH_LIMIT = 10; + public static function getExpByLv(&$lv,&$exp){ $meta = self::getMetaList(); if ($exp > 0){ diff --git a/webapp/services/TameBattleDataService.php b/webapp/services/TameBattleDataService.php index 5ee6162a..1ccc17ff 100644 --- a/webapp/services/TameBattleDataService.php +++ b/webapp/services/TameBattleDataService.php @@ -376,6 +376,7 @@ class TameBattleDataService extends BaseService { $newScore = $this->userInfo['score']; if ($pvp_mode == self::MATCH_MODE_RANK){ + myself()->_setV(TN_LAST_RANKING_TIME,0,getXVal($this->battleInfo,'game_time', 0)); $winningPro = $this->celWinningPro($this->userInfo); if ($winningPro){