1
This commit is contained in:
parent
6ef91c03c5
commit
a430a318a7
36
doc/Match.py
36
doc/Match.py
@ -1,36 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
import _common
|
|
||||||
|
|
||||||
class Match(object):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.apis = [
|
|
||||||
{
|
|
||||||
'name': 'getMatchInfo',
|
|
||||||
'desc': '获取匹配信息',
|
|
||||||
'group': 'Match',
|
|
||||||
'url': 'webapp/index.php?c=Match&a=getMatchInfo',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
['info', _common.MatchInfo(), '匹配信息'],
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'cancel',
|
|
||||||
'desc': '取消匹配',
|
|
||||||
'group': 'Match',
|
|
||||||
'url': 'webapp/index.php?c=Match&a=cancel',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
186
doc/Team.py
186
doc/Team.py
@ -1,186 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
import _common
|
|
||||||
|
|
||||||
class Team(object):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.apis = [
|
|
||||||
{
|
|
||||||
'name': 'createTeam',
|
|
||||||
'desc': '创建队伍',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=createTeam',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['node_id', 0, '节点id'],
|
|
||||||
['map_id', 0, '地图id'],
|
|
||||||
['match_mode', 0, '0: 匹配赛模式 1: 排位赛 2: pve'],
|
|
||||||
['pve_instance_id', 0, 'pve副本id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'teamInfo',
|
|
||||||
'desc': '获取队伍信息',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=teamInfo',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
['team_info', _common.TeamInfo(), '队伍信息'],
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'joinTeam',
|
|
||||||
'desc': '加入队伍',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=joinTeam',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'leaveTeam',
|
|
||||||
'desc': '离开队伍',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=leaveTeam',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},{
|
|
||||||
'name': 'breakup',
|
|
||||||
'desc': '解散队伍',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=breakup',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'kickout',
|
|
||||||
'desc': '踢人',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=kickout',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
['target_id', '', '目标account_id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'handover',
|
|
||||||
'desc': '转移队长职位',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=handover',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
['target_id', '', '目标account_id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'cancel',
|
|
||||||
'desc': '取消游戏开始',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=cancel',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'startGame',
|
|
||||||
'desc': '开始游戏',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=startGame',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},{
|
|
||||||
'name': 'doReady',
|
|
||||||
'desc': '准备/取消',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=doReady',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
['ready_state', 0, '1:准备 0:取消'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},{
|
|
||||||
'name': 'updateTeam',
|
|
||||||
'desc': '跟新队伍信息',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=updateTeam',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},{
|
|
||||||
'name': 'permission',
|
|
||||||
'desc': '邀请许可',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=permission',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
['target_id', '', '目标account_id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},{
|
|
||||||
'name': 'setCustomInfo',
|
|
||||||
'desc': '设置队伍自定义房间',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=setCustomInfo',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
['custom_room_id', '', '自定义房间的ID'],
|
|
||||||
['custom_room_state', '', '自定义房间的状态'],
|
|
||||||
['custom_room_pwd', '', '自定义房间的密码'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},
|
|
||||||
]
|
|
@ -1,264 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once('models/User.php');
|
|
||||||
require_once('models/Hero.php');
|
|
||||||
require_once('models/Gun.php');
|
|
||||||
require_once('models/ChipPage.php');
|
|
||||||
require_once('models/HeroPreset.php');
|
|
||||||
require_once('models/HeroSkin.php');
|
|
||||||
|
|
||||||
require_once('mt/PveGemini.php');
|
|
||||||
require_once('mt/Skill.php');
|
|
||||||
require_once('mt/StarLevel.php');
|
|
||||||
|
|
||||||
require_once('services/PropertyChgService.php');
|
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
|
||||||
use models\User;
|
|
||||||
use models\Hero;
|
|
||||||
use models\Gun;
|
|
||||||
use models\ChipPage;
|
|
||||||
use models\HeroPreset;
|
|
||||||
use models\HeroSkin;
|
|
||||||
|
|
||||||
class MatchController extends BaseAuthedController {
|
|
||||||
|
|
||||||
public function getMatchInfo()
|
|
||||||
{
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
$matchInfo = array(
|
|
||||||
'state' => 0,
|
|
||||||
'team_list' => array()
|
|
||||||
);
|
|
||||||
$matchOkDb = $this->readMatchOk($r, $teamUuid);
|
|
||||||
if ($matchOkDb) {
|
|
||||||
$this->refreshKeyExpire($r, MATCH_OK_KEY . $teamUuid, 1000*600);
|
|
||||||
$this->refreshKeyExpire($r, MATCH_OK_KEY . $matchOkDb['target_team'], 1000*600);
|
|
||||||
$this->refreshKeyExpire($r, TEAMID_KEY . $matchOkDb['target_team'], 1000*600);
|
|
||||||
$this->fillMatchInfo($r, $teamUuid, $matchInfo, $matchOkDb);
|
|
||||||
} else {
|
|
||||||
$this->execMatch($r, $teamUuid, $teamDb, $matchInfo);
|
|
||||||
}
|
|
||||||
$this->_rspData($matchInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function cancel()
|
|
||||||
{
|
|
||||||
$teamUuid = getReqVal('team_uuid', '');
|
|
||||||
$r = $this->_getRedis($teamUuid);
|
|
||||||
$teamDb = $this->readTeamDb($r, $teamUuid);
|
|
||||||
if (!empty($teamDb)) {
|
|
||||||
$r->del(MATCH_OK_KEY . $teamUuid);
|
|
||||||
$matchOkDb = $this->readMatchOk($r, $teamUuid);
|
|
||||||
if ($matchOkDb) {
|
|
||||||
$r->del(MATCH_OK_KEY . $matchOkDb['target_team']);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
$currMatchDb = $this->readCurrMatchTeam($r);
|
|
||||||
if (!empty($currMatchDb)) {
|
|
||||||
unset($currMatchDb[$teamUuid]);
|
|
||||||
$r->set(MATCH_CURRENT_TEAM_KEY, json_encode($currMatchDb));
|
|
||||||
$this->refreshKeyExpire($r, MATCH_CURRENT_TEAM_KEY, 1000*600);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->_rspOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function readTeamDb($r, $teamUuid)
|
|
||||||
{
|
|
||||||
$teamDbStr = $r->get(TEAMID_KEY . $teamUuid);
|
|
||||||
if (empty($teamDbStr)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$this->refreshKeyExpire($r, TEAMID_KEY . $teamUuid, 1000*600);
|
|
||||||
$teamDb = json_decode($teamDbStr, true);
|
|
||||||
return $teamDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
"": {
|
|
||||||
"team_uuid": "dafsdf"
|
|
||||||
"match_time": 231434
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
private function readCurrMatchTeam($r)
|
|
||||||
{
|
|
||||||
$teamDbStr = $r->get(MATCH_CURRENT_TEAM_KEY);
|
|
||||||
if (empty($teamDbStr)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$teamDb = json_decode($teamDbStr, true);
|
|
||||||
return $teamDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
"target_team": "dafsdf"
|
|
||||||
"match_time": 231434
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
private function readMatchOk($r, $teamUuid)
|
|
||||||
{
|
|
||||||
$teamDbStr = $r->get(MATCH_OK_KEY . $teamUuid);
|
|
||||||
if (empty($teamDbStr)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$this->refreshKeyExpire($r, MATCH_OK_KEY . $teamUuid, 1000*600);
|
|
||||||
$teamDb = json_decode($teamDbStr, true);
|
|
||||||
return $teamDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function refreshKeyExpire($r, $key, $time)
|
|
||||||
{
|
|
||||||
$r->pexpire($key, $time);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function execMatch($r, $teamUuid, $teamDb, &$matchInfo)
|
|
||||||
{
|
|
||||||
$currMatchDb = $this->readCurrMatchTeam($r);
|
|
||||||
if (empty($currMatchDb)) {
|
|
||||||
$currMatchDb = array(
|
|
||||||
$teamUuid => array(
|
|
||||||
'team_uuid' => $teamUuid,
|
|
||||||
'match_time' => $this->_getNowTime()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$r->set(MATCH_CURRENT_TEAM_KEY, json_encode($currMatchDb));
|
|
||||||
$this->refreshKeyExpire($r, MATCH_CURRENT_TEAM_KEY, 1000*600);
|
|
||||||
} else {
|
|
||||||
$delTeams = array();
|
|
||||||
$selfTeamDb = $currMatchDb[$teamUuid];
|
|
||||||
if ($selfTeamDb && myself()->_getNowTime() - $selfTeamDb['match_time'] > 7) {
|
|
||||||
$this->matchOk($r, $teamUuid, $selfTeamDb);
|
|
||||||
$this->fillMatchInfo($r, $teamUuid, $matchInfo, $this->readMatchOk($r, $teamUuid));
|
|
||||||
array_push($delTeams, $teamUuid);
|
|
||||||
} else {
|
|
||||||
foreach ($currMatchDb as $key => $val) {
|
|
||||||
$tmpTeamDb = $this->readTeamDb($r, $key);
|
|
||||||
if ($tmpTeamDb['zid'] != $teamDb['zid'] ||
|
|
||||||
$tmpTeamDb['node_id'] != $teamDb['node_id'] ||
|
|
||||||
$tmpTeamDb['map_id'] != $teamDb['map_id']) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!empty($tmpTeamDb) && $this->_getNowTime() - $val['match_time'] > 120) {
|
|
||||||
array_push($delTeams, $key);
|
|
||||||
} else {
|
|
||||||
$found = false;
|
|
||||||
if ($key == $teamUuid) {
|
|
||||||
$found = true;
|
|
||||||
} else {
|
|
||||||
foreach ($val['member_list'] as $member) {
|
|
||||||
if ($member['account_id'] == myself()->_getAccountId()) {
|
|
||||||
$found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$found) {
|
|
||||||
$this->matchOk($r, $teamUuid, $val);
|
|
||||||
$this->fillMatchInfo($r, $teamUuid, $matchInfo, $this->readMatchOk($r, $teamUuid));
|
|
||||||
array_push($delTeams, $key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}//end foreach $currMatchDb
|
|
||||||
}
|
|
||||||
if (count($delTeams) > 0) {
|
|
||||||
foreach ($delTeams as $id) {
|
|
||||||
unset($currMatchDb[$id]);
|
|
||||||
}
|
|
||||||
$r->set(MATCH_CURRENT_TEAM_KEY, json_encode($currMatchDb));
|
|
||||||
$this->refreshKeyExpire($r, MATCH_CURRENT_TEAM_KEY, 1000*600);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function matchOk($r, $teamUuid, $currMatchDb)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
$matchOkDb = array(
|
|
||||||
'target_team' => $currMatchDb['team_uuid'],
|
|
||||||
'match_time' => $this->_getNowTime()
|
|
||||||
);
|
|
||||||
$r->set(MATCH_OK_KEY . $teamUuid, json_encode($matchOkDb));
|
|
||||||
$this->refreshKeyExpire($r, MATCH_OK_KEY . $teamUuid, 1000*600);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
$matchOkDb = array(
|
|
||||||
'target_team' => $teamUuid,
|
|
||||||
'match_time' => $this->_getNowTime()
|
|
||||||
);
|
|
||||||
$r->set(MATCH_OK_KEY . $currMatchDb['team_uuid'], json_encode($matchOkDb));
|
|
||||||
$this->refreshKeyExpire($r, MATCH_OK_KEY . $currMatchDb['team_uuid'], 1000*600);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function fillMatchInfo($r, $teamUuid, &$matchInfo, $matchOkDb)
|
|
||||||
{
|
|
||||||
if (empty($matchOkDb)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
error_log(json_encode($matchOkDb));
|
|
||||||
$matchInfo['state'] = 1;
|
|
||||||
$data = array(
|
|
||||||
'zid' => '',
|
|
||||||
'node_id' => '',
|
|
||||||
'room_uuid' => '',
|
|
||||||
'start_time' => $matchOkDb['match_time'],
|
|
||||||
'team_list' => array()
|
|
||||||
);
|
|
||||||
$teamList = array();
|
|
||||||
{
|
|
||||||
$teamDb = $this->readTeamDb($r, $teamUuid);
|
|
||||||
array_push($matchInfo['team_list'], $teamDb);
|
|
||||||
$teamInfo = array(
|
|
||||||
'team_uuid' => $teamDb['team_uuid'],
|
|
||||||
'members' => array()
|
|
||||||
);
|
|
||||||
foreach ($teamDb['member_list'] as $val) {
|
|
||||||
array_push($teamInfo['members'], array(
|
|
||||||
'account_id' => $val['account_id']
|
|
||||||
));
|
|
||||||
}
|
|
||||||
array_push($teamList, $teamInfo);
|
|
||||||
$data['zid'] = $teamDb['zid'];
|
|
||||||
$data['node_id'] = $teamDb['node_id'];
|
|
||||||
$data['room_uuid'] = $teamDb['team_uuid'];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
$teamDb = $this->readTeamDb($r, $matchOkDb['target_team']);
|
|
||||||
if (!empty($teamDb) && $teamDb['team_uuid'] != $teamUuid) {
|
|
||||||
array_push($matchInfo['team_list'], $teamDb);
|
|
||||||
$teamInfo = array(
|
|
||||||
'team_uuid' => $teamDb['team_uuid'],
|
|
||||||
'members' => array()
|
|
||||||
);
|
|
||||||
foreach ($teamDb['member_list'] as $val) {
|
|
||||||
array_push($teamInfo['members'], array(
|
|
||||||
'account_id' => $val['account_id']
|
|
||||||
));
|
|
||||||
}
|
|
||||||
array_push($teamList, $teamInfo);
|
|
||||||
if (strcasecmp($teamDb['team_uuid'], $data['room_uuid']) < 0) {
|
|
||||||
$data['room_uuid'] = $teamDb['team_uuid'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$data['team_list'] = $teamList;
|
|
||||||
$payload = md5(json_encode($data) . '520d8eAbB(8cf1^#$^&!@d833a42c820432PDAFE^^)') .
|
|
||||||
":moba_room|" . json_encode($data);
|
|
||||||
$matchInfo['join_msg'] = array(
|
|
||||||
'team_uuid' => $teamUuid,
|
|
||||||
'payload' => $payload
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,533 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once('models/User.php');
|
|
||||||
require_once('models/Hero.php');
|
|
||||||
require_once('models/Gun.php');
|
|
||||||
require_once('models/ChipPage.php');
|
|
||||||
require_once('models/HeroPreset.php');
|
|
||||||
require_once('models/HeroSkin.php');
|
|
||||||
|
|
||||||
require_once('mt/PveGemini.php');
|
|
||||||
require_once('mt/Skill.php');
|
|
||||||
require_once('mt/StarLevel.php');
|
|
||||||
|
|
||||||
require_once('services/PropertyChgService.php');
|
|
||||||
|
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
|
||||||
use models\User;
|
|
||||||
use models\Hero;
|
|
||||||
use models\Gun;
|
|
||||||
use models\ChipPage;
|
|
||||||
use models\HeroPreset;
|
|
||||||
use models\HeroSkin;
|
|
||||||
|
|
||||||
class TeamController extends BaseAuthedController {
|
|
||||||
|
|
||||||
const MATCH_MODE_NORMAL = 0;
|
|
||||||
const MATCH_MODE_RANK = 1;
|
|
||||||
const MATCH_MODE_PVE = 2;
|
|
||||||
|
|
||||||
public function createTeam()
|
|
||||||
{
|
|
||||||
$mapId = getReqVal('map_id', 0);
|
|
||||||
$nodeId = getReqVal('node_id', 1);
|
|
||||||
$matchMode = getReqVal('match_mode', 0);
|
|
||||||
$pveInstanceId = getReqVal('pve_instance_id', 0);
|
|
||||||
$zid = myself()->_getZid();
|
|
||||||
$teamUuid = $nodeId . '_' .
|
|
||||||
$zid . '_' .
|
|
||||||
md5($this->_getAccountId() . $this->_getNowTime());
|
|
||||||
|
|
||||||
/*if (!in_array(array
|
|
||||||
(
|
|
||||||
self::MATCH_MODE_NORMAL,
|
|
||||||
self::MATCH_MODE_RANK,
|
|
||||||
self::MATCH_MODE_PVE,
|
|
||||||
),
|
|
||||||
$matchMode)) {
|
|
||||||
$this->_rspErr(1, 'match mode error');
|
|
||||||
return;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
$userDb = $this->_getOrmUserInfo();
|
|
||||||
error_log("CREATE TEAM : " . $userDb['account_id']);
|
|
||||||
//验证pve_instance_id合法性
|
|
||||||
if ($pveInstanceId){
|
|
||||||
// if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_PVE_MATCH_LIMIT){
|
|
||||||
if ($userDb['star_num'] < \mt\StarLevel::STAR_NUM_PVE_MATCH_LIMIT){
|
|
||||||
$this->_rspErr(1,'Not agreed terms');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$pveGame = \mt\PveGemini::get($pveInstanceId);
|
|
||||||
if (!$pveGame){
|
|
||||||
$this->_rspErr(1, 'pve_instance_id error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!in_array($pveInstanceId,\mt\PveGemini::getAbleCombatMeta($userDb['pve_instance_id']))){
|
|
||||||
$this->_rspErr(1, "You can't challenge beyond your level");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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){
|
|
||||||
$this->_rspErr(1,'Not agreed terms');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$userDto = User::toPreset($userDb);
|
|
||||||
$userDto['is_leader'] = 1;
|
|
||||||
$userDto['is_ready'] = 1;
|
|
||||||
$userDto['permission'] = 1;
|
|
||||||
$userDto['createtime'] = $userDb['createtime'];
|
|
||||||
$teamDb = array(
|
|
||||||
'map_id' => $mapId,
|
|
||||||
'node_id' => $nodeId,
|
|
||||||
'zid' => $zid,
|
|
||||||
'team_uuid' => $teamUuid,
|
|
||||||
'state' => 0,
|
|
||||||
'payload' => '',
|
|
||||||
'match_mode' => $matchMode,
|
|
||||||
'pve_instance_id' => $pveInstanceId,
|
|
||||||
'slot_num' => 1,
|
|
||||||
'member_list' => array($userDto),
|
|
||||||
'custom_room' => array(),
|
|
||||||
);
|
|
||||||
|
|
||||||
$r = $this->_getRedis($teamUuid);
|
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
|
||||||
$this->_rspData(array(
|
|
||||||
'team_uuid' => $teamUuid
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function teamInfo()
|
|
||||||
{
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
$r->pexpire(TEAMID_KEY . $teamUuid, 1000*600);
|
|
||||||
$this->_rspData(array(
|
|
||||||
'team_info' => $teamDb
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateTeam(){
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
$userDb = $this->_getOrmUserInfo();
|
|
||||||
$userDto = User::toPreset($userDb);
|
|
||||||
foreach ($teamDb['member_list'] as $key=>$member) {
|
|
||||||
if ($member['account_id'] == $this->_getAccountId()) {
|
|
||||||
$userDto['is_leader'] = $member['is_leader'];
|
|
||||||
$userDto['is_ready'] = $member['is_ready'];
|
|
||||||
$userDto['createtime'] = $member['createtime'];
|
|
||||||
$teamDb['member_list'][$key] = $userDto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
|
||||||
$this->_rspData(array(
|
|
||||||
'team_uuid' => $teamUuid
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function joinTeam()
|
|
||||||
{
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
$userDb = $this->_getOrmUserInfo();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($teamDb['member_list'] as $member) {
|
|
||||||
if ($member['account_id'] == $this->_getAccountId()) {
|
|
||||||
$this->_rspData(array(
|
|
||||||
'team_uuid' => $teamUuid
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$userDb = User::find($this->_getAccountId());
|
|
||||||
|
|
||||||
//验证pve_instance_id合法性
|
|
||||||
if ($teamDb['pve_instance_id']>0){
|
|
||||||
if (!in_array($teamDb['pve_instance_id'],\mt\PveGemini::getAbleCombatMeta($userDb['pve_instance_id']))) {
|
|
||||||
$this->_rspErr(1, 'No challenge');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_PVE_MATCH_LIMIT){
|
|
||||||
if ($userDb['star_num'] < \mt\StarLevel::STAR_NUM_PVE_MATCH_LIMIT){
|
|
||||||
$this->_rspErr(1,'Not agreed terms');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$userDto = User::toPreset($userDb);
|
|
||||||
$userDto['createtime'] = $userDb['createtime'];
|
|
||||||
array_push($teamDb['member_list'], $userDto);
|
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
|
||||||
$this->_rspData(array(
|
|
||||||
'team_uuid' => $teamUuid
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function leaveTeam()
|
|
||||||
{
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
$newMemberList = array();
|
|
||||||
$isLeader = false;
|
|
||||||
foreach ($teamDb['member_list'] as $member) {
|
|
||||||
if ($member['account_id'] == $this->_getAccountId() && $member['is_leader'] == 1){
|
|
||||||
$isLeader = true;
|
|
||||||
}
|
|
||||||
if ($member['account_id'] != $this->_getAccountId()) {
|
|
||||||
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;
|
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
|
||||||
$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', '');
|
|
||||||
$account_id = getReqVal('target_id', '');
|
|
||||||
if (! $account_id){
|
|
||||||
$this->_rspErr(1, 'target_id param error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$r = $this->_getRedis($teamUuid);
|
|
||||||
$teamDb = $this->readTeamDb($r, $teamUuid);
|
|
||||||
if (empty($teamDb)) {
|
|
||||||
$this->_rspErr(1, 'The team has been disbanded');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$temp = array_map(function ($val){
|
|
||||||
return $val['account_id'];
|
|
||||||
},$teamDb['member_list']);
|
|
||||||
if(! in_array($account_id,$temp)){
|
|
||||||
$this->_rspErr(1, 'The team do not have users');
|
|
||||||
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->_rspOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function closeSlot()
|
|
||||||
{
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($teamDb['slot_num'] <= 1){
|
|
||||||
$this->_rspErr(1, 'Minimum size of team');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (count($teamDb['member_list'])== 4){
|
|
||||||
$this->_rspErr(1, "Can't shut down");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$teamDb['slot_num']-=1;
|
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
|
||||||
$this->_rspOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function openSlot()
|
|
||||||
{
|
|
||||||
$teamUuid = getReqVal('team_uuid', '');
|
|
||||||
$slotNum = getReqVal('slot_num', 1);
|
|
||||||
$r = $this->_getRedis($teamUuid);
|
|
||||||
$teamDb = $this->readTeamDb($r, $teamUuid);
|
|
||||||
if (empty($teamDb)) {
|
|
||||||
$this->_rspOk();
|
|
||||||
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 (count($teamDb['member_list'])>$slotNum){
|
|
||||||
$this->_rspErr(1, 'slot_num Insufficient ');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$teamDb['slot_num'] = $slotNum;
|
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
|
||||||
$this->_rspOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handover()
|
|
||||||
{
|
|
||||||
$teamUuid = getReqVal('team_uuid', '');
|
|
||||||
$account_id = getReqVal('target_id', '');
|
|
||||||
if (! $account_id){
|
|
||||||
$this->_rspErr(1, 'target_id param error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$r = $this->_getRedis($teamUuid);
|
|
||||||
$teamDb = $this->readTeamDb($r, $teamUuid);
|
|
||||||
if (empty($teamDb)) {
|
|
||||||
$this->_rspErr(1, 'The team has been disbanded');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$temp = array_map(function ($val){
|
|
||||||
return $val['account_id'];
|
|
||||||
},$teamDb['member_list']);
|
|
||||||
if(! in_array($account_id,$temp)){
|
|
||||||
$this->_rspErr(1, 'The team do not have users');
|
|
||||||
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->_rspOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function cancel()
|
|
||||||
{
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$teamDb['state'] = 0;
|
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
|
||||||
$this->_rspOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function startGame()
|
|
||||||
{
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$teamDb['state'] = 1;
|
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
|
||||||
$this->_rspOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function doReady(){
|
|
||||||
$teamUuid = getReqVal('team_uuid', '');
|
|
||||||
$readyState = getReqVal('ready_state', 0); //1:准备 0:取消
|
|
||||||
if(!in_array($readyState,array(0,1))){
|
|
||||||
$this->_rspErr(1, 'ready_state param error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$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, 'Captain no operation');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($member['account_id'] == $this->_getAccountId()){
|
|
||||||
$member['is_ready'] = $readyState?:0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
$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,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCustomInfo(){
|
|
||||||
$custom_room_state = getReqVal('custom_room_state', '');
|
|
||||||
$custom_room_id = getReqVal('custom_room_id', '');
|
|
||||||
$custom_room_pwd = getReqVal('custom_room_pwd', '');
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
$teamDb['custom_room'] = array(
|
|
||||||
'custom_room_id' => $custom_room_id,
|
|
||||||
'custom_room_state' => $custom_room_state,
|
|
||||||
'custom_room_pwd' => $custom_room_pwd,
|
|
||||||
);
|
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
|
||||||
$this->_rspData(array(
|
|
||||||
'team_uuid' => $teamUuid
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private function readTeamDb($r, $teamUuid)
|
|
||||||
{
|
|
||||||
$teamDbStr = $r->get(TEAMID_KEY . $teamUuid);
|
|
||||||
if (empty($teamDbStr)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$teamDb = json_decode($teamDbStr, true);
|
|
||||||
return $teamDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function saveTeamDb($r, $teamUuid, $teamDb)
|
|
||||||
{
|
|
||||||
$r->set(TEAMID_KEY . $teamUuid, json_encode($teamDb));
|
|
||||||
$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