diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index 6c7557c2..0cb3c110 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -35,8 +35,8 @@ class TeamController extends BaseAuthedController { $pveInstanceId = getReqVal('pve_instance_id', 0); $zid = myself()->_getZid(); $teamUuid = $nodeId . '_' . - $zid . '_' . - md5($this->_getAccountId() . $this->_getNowTime()); + $zid . '_' . + md5($this->_getAccountId() . $this->_getNowTime()); /*if (!in_array(array ( @@ -70,7 +70,7 @@ class TeamController extends BaseAuthedController { } if ($matchMode == self::MATCH_MODE_RANK){ // if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){ - if ($userDb['star_num'] < \mt\StarLevel::STAR_NUM_RANK_MATCH_LIMIT){ + if ($userDb['star_num'] < \mt\StarLevel::STAR_NUM_RANK_MATCH_LIMIT){ $this->_rspErr(1,'Not agreed terms'); return; } @@ -78,7 +78,6 @@ 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, @@ -148,8 +147,8 @@ class TeamController extends BaseAuthedController { if ($teamDb['match_mode'] == self::MATCH_MODE_RANK && // $userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){ $userDb['star_num'] < \mt\StarLevel::STAR_NUM_RANK_MATCH_LIMIT){ - $this->_rspErr(1,'Not agreed terms'); - return; + $this->_rspErr(1,'Not agreed terms'); + return; } foreach ($teamDb['member_list'] as $member) { @@ -216,25 +215,6 @@ 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', ''); @@ -447,37 +427,136 @@ class TeamController extends BaseAuthedController { $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); - $this->_rspData(array( - 'heroNum'=>$todayPveGetHeroFragmentNum, - 'gunNum'=>$todayPveGetGunFragmentNum, - )); - } - - public function permission(){ + public function setHero(){ $teamUuid = getReqVal('team_uuid', ''); - $accountId = getReqVal('target_id', ''); + $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() && $member['is_leader'] != 1){ - $this->_rspErr(1, 'You are not the captain.'); - return; - } - if ($member['account_id'] == $accountId){ - $member['permission'] = 1; + 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( - 'team_uuid' => $teamUuid + '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); + $this->_rspData(array( + 'heroNum'=>$todayPveGetHeroFragmentNum, + 'gunNum'=>$todayPveGetGunFragmentNum, )); }