1
This commit is contained in:
commit
73df2acb08
@ -86,6 +86,7 @@ class Team(object):
|
|||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
['team_uuid', '', '队伍唯一id'],
|
['team_uuid', '', '队伍唯一id'],
|
||||||
|
['slot_id', '', '队伍卡槽id 共计:1 2 3 4'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
|
@ -33,8 +33,7 @@ class TeamController extends BaseAuthedController {
|
|||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// $userDb = $this->_getOrmUserInfo();
|
$userDb = $this->_getOrmUserInfo();
|
||||||
$userDb = User::find('6513_2006_HaABddcrIdHDoj0qg73FFwvyrYkqOsQd');
|
|
||||||
|
|
||||||
//验证pve_instance_id合法性
|
//验证pve_instance_id合法性
|
||||||
if ($pveInstanceId){
|
if ($pveInstanceId){
|
||||||
@ -104,6 +103,7 @@ class TeamController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$userDb = User::find($this->_getAccountId());
|
$userDb = User::find($this->_getAccountId());
|
||||||
|
|
||||||
//验证pve_instance_id合法性
|
//验证pve_instance_id合法性
|
||||||
if ($teamDb['pve_instance_id']>0){
|
if ($teamDb['pve_instance_id']>0){
|
||||||
if (!in_array($teamDb['pve_instance_id'],\mt\PveGemini::getAbleCombatMeta($userDb['pve_instance_id']))) {
|
if (!in_array($teamDb['pve_instance_id'],\mt\PveGemini::getAbleCombatMeta($userDb['pve_instance_id']))) {
|
||||||
@ -127,15 +127,27 @@ class TeamController extends BaseAuthedController {
|
|||||||
$r = $this->_getRedis($teamUuid);
|
$r = $this->_getRedis($teamUuid);
|
||||||
$teamDb = $this->readTeamDb($r, $teamUuid);
|
$teamDb = $this->readTeamDb($r, $teamUuid);
|
||||||
if (empty($teamDb)) {
|
if (empty($teamDb)) {
|
||||||
$this->_rspOk();
|
$this->_rspErr(1, 'The team has been disbanded');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$newMemberList = array();
|
$newMemberList = array();
|
||||||
|
$isLeader = false;
|
||||||
foreach ($teamDb['member_list'] as $member) {
|
foreach ($teamDb['member_list'] as $member) {
|
||||||
|
if ($member['account_id'] == $this->_getAccountId() && $member['is_leader'] == 1){
|
||||||
|
$isLeader = true;
|
||||||
|
}
|
||||||
if ($member['account_id'] != $this->_getAccountId()) {
|
if ($member['account_id'] != $this->_getAccountId()) {
|
||||||
array_push($newMemberList, $member);
|
array_push($newMemberList, $member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (count($newMemberList)<1){
|
||||||
|
$this->delTeamDb($r, $teamUuid);
|
||||||
|
$this->_rspOk();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($isLeader){
|
||||||
|
$newMemberList[0]['is_leader'] = 1;
|
||||||
|
}
|
||||||
$teamDb['member_list'] = $newMemberList;
|
$teamDb['member_list'] = $newMemberList;
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
@ -144,12 +156,36 @@ class TeamController extends BaseAuthedController {
|
|||||||
public function kickout()
|
public function kickout()
|
||||||
{
|
{
|
||||||
$teamUuid = getReqVal('team_uuid', '');
|
$teamUuid = getReqVal('team_uuid', '');
|
||||||
|
$account_id = getReqVal('target_id', '');
|
||||||
|
if (! $account_id){
|
||||||
|
$this->_rspErr(1, 'target_id param error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$r = $this->_getRedis($teamUuid);
|
$r = $this->_getRedis($teamUuid);
|
||||||
$teamDb = $this->readTeamDb($r, $teamUuid);
|
$teamDb = $this->readTeamDb($r, $teamUuid);
|
||||||
if (empty($teamDb)) {
|
if (empty($teamDb)) {
|
||||||
$this->_rspOk();
|
$this->_rspErr(1, 'The team has been disbanded');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(! in_array($account_id,array_column($teamDb['member_list'],'account_id'))){
|
||||||
|
$this->_rspErr(1, 'The team do not have users');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($account_id == $this->_getAccountId()){
|
||||||
|
$this->_rspErr(1, 'do not get myself out of line');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$newMemberList = array();
|
||||||
|
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'] != $account_id) {
|
||||||
|
array_push($newMemberList, $member);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$teamDb['member_list'] = $newMemberList;
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
@ -157,12 +193,38 @@ class TeamController extends BaseAuthedController {
|
|||||||
public function closeSlot()
|
public function closeSlot()
|
||||||
{
|
{
|
||||||
$teamUuid = getReqVal('team_uuid', '');
|
$teamUuid = getReqVal('team_uuid', '');
|
||||||
|
$slot_id = getReqVal('slot_id', 0);
|
||||||
|
if (! in_array($slot_id,array(1,2,3,4)) ){
|
||||||
|
$this->_rspErr(1, 'slot_id param error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$r = $this->_getRedis($teamUuid);
|
$r = $this->_getRedis($teamUuid);
|
||||||
$teamDb = $this->readTeamDb($r, $teamUuid);
|
$teamDb = $this->readTeamDb($r, $teamUuid);
|
||||||
if (empty($teamDb)) {
|
if (empty($teamDb)) {
|
||||||
$this->_rspOk();
|
$this->_rspErr(1, 'The team has been disbanded');
|
||||||
return;
|
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 ($teamDb['slot_num'] <= 1){
|
||||||
|
$this->_rspErr(1, 'Minimum size of team');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($teamDb['member_list'][$slot_id-1]['account_id'] == $this->_getAccountId()){
|
||||||
|
$this->_rspErr(1, 'do not get myself out of line');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(array_key_exists($slot_id-1,$teamDb['member_list'])){
|
||||||
|
unset($teamDb['member_list'][$slot_id-1]);
|
||||||
|
$teamDb['slot_num']-=1;
|
||||||
|
}else{
|
||||||
|
$teamDb['slot_num']-=1;
|
||||||
|
}
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
@ -176,6 +238,17 @@ class TeamController extends BaseAuthedController {
|
|||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
return;
|
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 ($teamDb['slot_num'] >= 4){
|
||||||
|
$this->_rspErr(1, 'Maximum size of team');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$teamDb['slot_num']+=1;
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
@ -183,12 +256,39 @@ class TeamController extends BaseAuthedController {
|
|||||||
public function handover()
|
public function handover()
|
||||||
{
|
{
|
||||||
$teamUuid = getReqVal('team_uuid', '');
|
$teamUuid = getReqVal('team_uuid', '');
|
||||||
|
$account_id = getReqVal('target_id', '');
|
||||||
|
if (! $account_id){
|
||||||
|
$this->_rspErr(1, 'target_id param error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$r = $this->_getRedis($teamUuid);
|
$r = $this->_getRedis($teamUuid);
|
||||||
$teamDb = $this->readTeamDb($r, $teamUuid);
|
$teamDb = $this->readTeamDb($r, $teamUuid);
|
||||||
if (empty($teamDb)) {
|
if (empty($teamDb)) {
|
||||||
$this->_rspOk();
|
$this->_rspErr(1, 'The team has been disbanded');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(! in_array($account_id,array_column($teamDb['member_list'],'account_id'))){
|
||||||
|
$this->_rspErr(1, 'The team do not have users');
|
||||||
|
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 ($account_id == $this->_getAccountId()){
|
||||||
|
$this->_rspErr(1, " You're already the captain ");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach ($teamDb['member_list'] as &$member) {
|
||||||
|
if ($member['account_id'] == $this->_getAccountId()){
|
||||||
|
$member['is_leader'] = 0;
|
||||||
|
}
|
||||||
|
if ($member['account_id'] == $account_id){
|
||||||
|
$member['is_leader'] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
@ -199,9 +299,16 @@ class TeamController extends BaseAuthedController {
|
|||||||
$r = $this->_getRedis($teamUuid);
|
$r = $this->_getRedis($teamUuid);
|
||||||
$teamDb = $this->readTeamDb($r, $teamUuid);
|
$teamDb = $this->readTeamDb($r, $teamUuid);
|
||||||
if (empty($teamDb)) {
|
if (empty($teamDb)) {
|
||||||
$this->_rspOk();
|
$this->_rspErr(1, 'The team has been disbanded');
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$teamDb['state'] = 0;
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
@ -216,6 +323,12 @@ class TeamController extends BaseAuthedController {
|
|||||||
$this->_rspErr(1, 'The team has been disbanded');
|
$this->_rspErr(1, 'The team has been disbanded');
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
$teamDb['state'] = 1;
|
$teamDb['state'] = 1;
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
@ -237,4 +350,8 @@ class TeamController extends BaseAuthedController {
|
|||||||
$r->pexpire(TEAMID_KEY . $teamUuid, 1000*600);
|
$r->pexpire(TEAMID_KEY . $teamUuid, 1000*600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function delTeamDb($r, $teamUuid){
|
||||||
|
$r->del(TEAMID_KEY . $teamUuid);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user