From f52ccf60c563e70d73a8f109bf6f312e84619918 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Mon, 11 Sep 2023 15:52:41 +0800 Subject: [PATCH 1/3] 1 --- webapp/controller/TeamController.class.php | 169 ++++++--------------- 1 file changed, 45 insertions(+), 124 deletions(-) diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index 0cb3c110..e88db4e2 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -78,6 +78,7 @@ class TeamController extends BaseAuthedController { $userDto = User::toPreset($userDb); $userDto['is_leader'] = 1; $userDto['is_ready'] = 1; + $userDto['permission'] = 1; $userDto['createtime'] = $userDb['createtime']; $teamDb = array( 'team_uuid' => $teamUuid, @@ -215,6 +216,25 @@ class TeamController extends BaseAuthedController { $this->_rspOk(); } + public function breakup(){ + $teamUuid = getReqVal('team_uuid', ''); + $r = $this->_getRedis($teamUuid); + $teamDb = $this->readTeamDb($r, $teamUuid); + if (empty($teamDb)) { + $this->_rspErr(1, 'The team has been disbanded'); + return; + } + foreach ($teamDb['member_list'] as &$member) { + if ($member['account_id'] == $this->_getAccountId() && $member['is_leader'] != 1){ + $this->_rspErr(1, 'You are not the captain.'); + return; + } + } + $this->delTeamDb($r, $teamUuid); + $this->_rspOk(); + } + + public function kickout() { $teamUuid = getReqVal('team_uuid', ''); @@ -427,130 +447,6 @@ class TeamController extends BaseAuthedController { $this->_rspOk(); } - public function setHero(){ - $teamUuid = getReqVal('team_uuid', ''); - $heroUid = getReqVal('hero_uid', ''); - $heroDb = Hero::find($heroUid); - if (! $heroDb){ - $this->_rspErr(1, 'hero_uid param error'); - return; - } - $r = $this->_getRedis($teamUuid); - $teamDb = $this->readTeamDb($r, $teamUuid); - if (empty($teamDb)) { - $this->_rspErr(1, 'The team has been disbanded'); - return; - } - $this->_updateUserInfo(array( - 'hero_id' => $heroUid - )); - $newUserInfo = User::toPreset($this->_getOrmUserInfo()); - foreach ($teamDb['member_list'] as &$member) { - if ($member['account_id'] == $this->_getAccountId()){ - $newUserInfo['is_leader'] = $member['is_leader']; - $newUserInfo['is_ready'] = $member['is_ready']; - $member = $newUserInfo; - } - - } - $this->saveTeamDb($r, $teamUuid, $teamDb); - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addUserChg(); - $this->_rspData(array( - 'property_chg' => $propertyChgService->toDto() - )); - } - - public function setPreset(){ - $teamUuid = getReqVal('team_uuid', ''); - $heroId = getReqVal('hero_uid',0); - $chipPageId = getReqVal('chip_page',0); - $weaponUid1 = getReqVal('weapon_uid1',0); - $weaponUid2 = getReqVal('weapon_uid2',0); - $skillId = getReqVal('skill_id',0); - $r = $this->_getRedis($teamUuid); - $teamDb = $this->readTeamDb($r, $teamUuid); - if (empty($teamDb)) { - $this->_rspErr(1, 'The team has been disbanded'); - return; - } - $heroDb = Hero::find($heroId); - if (! $heroDb){ - $this->_rspErr(1, "You don't have the hero yet"); - return; - } - $chipPageDb = ChipPage::find($chipPageId); - if (! $chipPageDb){ - $this->_rspErr(1, "You don't have the chip page"); - return; - } - if ($weaponUid1){ - $gunDb1 = Gun::find($weaponUid1); - if (!$gunDb1){ - $this->_rspErr(1, "You don't have the gun1 yet"); - return; - } - } - if ($weaponUid2){ - $gunDb2 = Gun::find($weaponUid2); - if (!$gunDb2){ - $this->_rspErr(1, "You don't have the gun2 yet"); - return; - } - } - $skillMeta = mt\Skill::get($skillId); - if (! $skillMeta){ - $this->_rspErr(1,'skill_id parameter error'); - return ; - } - HeroPreset::upsertPreset($heroId,$skillId,$chipPageId,$weaponUid1,$weaponUid2); - $newUserInfo = User::toPreset($this->_getOrmUserInfo()); - foreach ($teamDb['member_list'] as &$member) { - if ($member['account_id'] == $this->_getAccountId()){ - $newUserInfo['is_leader'] = $member['is_leader']; - $newUserInfo['is_ready'] = $member['is_ready']; - $member = $newUserInfo; - } - - } - $this->saveTeamDb($r, $teamUuid, $teamDb); - $this->_rspOk(); - } - - public function setHeroSkin(){ - $teamUuid = getReqVal('team_uuid', ''); - $heroUniId = getReqVal('hero_uid', 0); - $skinId = getReqVal('skin_id', 0); - $r = $this->_getRedis($teamUuid); - $teamDb = $this->readTeamDb($r, $teamUuid); - if (empty($teamDb)) { - $this->_rspErr(1, 'The team has been disbanded'); - return; - } - $heroDb = Hero::find($heroUniId); - $heroSkinDb = HeroSkin::find($skinId); - if (!$heroDb) { - $this->_rspErr(1, "You don't have the hero yet"); - return; - } - if (!$heroSkinDb) { - $this->_rspErr(2, "You don't have the skin yet"); - return; - } - HeroSkin::takeonSkin( $skinId,$heroDb['hero_id']); - $newUserInfo = User::toPreset($this->_getOrmUserInfo()); - foreach ($teamDb['member_list'] as &$member) { - if ($member['account_id'] == $this->_getAccountId()){ - $newUserInfo['is_leader'] = $member['is_leader']; - $newUserInfo['is_ready'] = $member['is_ready']; - $member = $newUserInfo; - } - - } - $this->saveTeamDb($r, $teamUuid, $teamDb); - $this->_rspOk(); - } - public function getPveFragmentNumOrDay(){ $todayPveGetHeroFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_HERO_FRAGMENT_NUM, 0); $todayPveGetGunFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_GUN_FRAGMENT_NUM, 0); @@ -560,6 +456,31 @@ class TeamController extends BaseAuthedController { )); } + public function permission(){ + $teamUuid = getReqVal('team_uuid', ''); + $accountId = getReqVal('target_id', ''); + $r = $this->_getRedis($teamUuid); + $teamDb = $this->readTeamDb($r, $teamUuid); + if (empty($teamDb)) { + $this->_rspErr(1, 'The team has been disbanded'); + return; + } + foreach ($teamDb['member_list'] as &$member) { + if ($member['account_id'] == $this->_getAccountId() && $member['is_leader'] != 1){ + $this->_rspErr(1, 'You are not the captain.'); + return; + } + if ($member['account_id'] == $accountId){ + $member['permission'] = 1; + } + + } + $this->saveTeamDb($r, $teamUuid, $teamDb); + $this->_rspData(array( + 'team_uuid' => $teamUuid + )); + } + private function readTeamDb($r, $teamUuid) { From 92f096f4903a24d38e4a17619d2bf5553618cc1d Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Wed, 13 Sep 2023 13:17:15 +0800 Subject: [PATCH 2/3] 1 --- webapp/models/User.php | 6 +++--- webapp/services/NumberService.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp/models/User.php b/webapp/models/User.php index d71302e1..856f6309 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -292,9 +292,9 @@ class User extends BaseModel { 'account_id' => $row['account_id'], 'address' => $row['address'], 'name' => $row['name'], -// 'sex' => $row['sex'], -// 'head_id' => $row['head_id'], -// 'head_frame' => $row['head_frame'], + 'sex' => $row['sex'], + 'head_id' => $row['head_id'], + 'head_frame' => $row['head_frame'], 'level' => $row['level'], 'exp' => $row['exp'], 'rank' => $row['rank'], diff --git a/webapp/services/NumberService.php b/webapp/services/NumberService.php index e2db629e..b82cce28 100644 --- a/webapp/services/NumberService.php +++ b/webapp/services/NumberService.php @@ -9,7 +9,7 @@ class NumberService extends BaseService public static function ceilEx($number , $decimals) { $intPart = intval($number); $floatPart = $number - $intPart; - $finallyFloatPart = ceil($floatPart * pow(10,$decimals)) / pow(10,$decimals); + $finallyFloatPart = ceil(strval($floatPart * pow(10,$decimals))) / pow(10,$decimals); return $intPart + $finallyFloatPart; } } \ No newline at end of file From 7fbd7707ef549ad2326050ace6779c59e3f314a4 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Wed, 13 Sep 2023 18:50:18 +0800 Subject: [PATCH 3/3] 1 --- webapp/models/User.php | 3 ++- webapp/services/TameBattleDataService.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/webapp/models/User.php b/webapp/models/User.php index 856f6309..fc8dfe1d 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -220,7 +220,8 @@ class User extends BaseModel { 'current_star_num' => $current_star_num, 'next_star_num' => $next_star_num, // 'status_bar' => self::_getState(), - 'honor_info' => $honorInfo + 'honor_info' => $honorInfo, + 'last_login_time' => $row['last_login_time'], ); } diff --git a/webapp/services/TameBattleDataService.php b/webapp/services/TameBattleDataService.php index 894bf6ea..ec61296c 100644 --- a/webapp/services/TameBattleDataService.php +++ b/webapp/services/TameBattleDataService.php @@ -866,8 +866,8 @@ class TameBattleDataService extends BaseService { 'rank' => $newRank, 'score' => $newScore, 'elo' => $newElo, - 'history_best_rank' => max($this->userInfo['rank'], $newRank), - 'history_best_score' => max($this->userInfo['score'], $newScore), + 'history_best_rank' => max($this->userInfo['history_best_rank'], $newRank), + 'history_best_score' => max($this->userInfo['history_best_score'], $newScore), 'score_modifytime' => myself()->_getNowTime(), 'best_rank_modifytime' => $newRank > $this->userInfo['rank'] ? myself()->_getNowTime() : $this->userInfo['best_rank_modifytime'],