1
This commit is contained in:
commit
0f947278bf
36
doc/Match.py
Normal file
36
doc/Match.py
Normal file
@ -0,0 +1,36 @@
|
||||
# -*- 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(),
|
||||
]
|
||||
}
|
||||
]
|
@ -1528,3 +1528,54 @@ class BattleTeam(object):
|
||||
['team_uuid','','队伍唯一id'],
|
||||
['!members', BattleData(), '成员数据'],
|
||||
]
|
||||
|
||||
class MatchMember(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['account_id', '', '账号id'],
|
||||
['address', '', 'openid'],
|
||||
['name', '', '用户名字'],
|
||||
['hero_uniId', 0, 'hero uniid'],
|
||||
['hero_id', 0, 'hero itemId'],
|
||||
['hero_skin', 0, '英雄皮肤 itemId'],
|
||||
['head_id', 0, '头像id'],
|
||||
['level', 0, '等级'],
|
||||
['exp', 0, '经验'],
|
||||
['rank', 0, '段位'],
|
||||
['pve_instance_id', 0, 'pve难度id'],
|
||||
['parachute', 0, '降落伞id'],
|
||||
['presetInfo', HeroPreset(), '备战信息'],
|
||||
['game_times', 0, '游戏次数'],
|
||||
['win_times', 0, '胜利次数'],
|
||||
['kills', 0, '击杀数'],
|
||||
['is_leader', 0, '是否队长'],
|
||||
['is_ready', 0, '是否准备'],
|
||||
['permission', 0, '邀请许可'],
|
||||
['createtime', 0, '账号创建时间'],
|
||||
]
|
||||
|
||||
class MatchTeam(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['team_uuid','','队伍唯一id'],
|
||||
['!members', BattleData(), '成员数据'],
|
||||
]
|
||||
|
||||
class MatchInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['state',0,'状态 0:匹配中 1:匹配成功'],
|
||||
['!team_list', MatchTeam(), '队伍列表(客户端自行判断所属哪个队伍)'],
|
||||
['join_msg', SpecJoin(), '匹配成功后改字段才有意义,传给CMJoin里的参数(team_uuid、payload)'],
|
||||
]
|
||||
|
||||
class SpecJoin(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['team_uuid', '', '自定义房间、moba房间会修改玩家原始team_uuid,所以用这个新的team_uuid替换之前CMJoin里的team_uuid'],
|
||||
['payload', '', '透传数据'],
|
||||
]
|
||||
|
140
sql/migrate/bcnftdb.sql
Normal file
140
sql/migrate/bcnftdb.sql
Normal file
@ -0,0 +1,140 @@
|
||||
-- MySQL dump 10.14 Distrib 5.5.41-MariaDB, for Linux (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: bcnft
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 5.5.41-MariaDB
|
||||
|
||||
--
|
||||
-- Table structure for table `version`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `version`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `version` (
|
||||
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`version` int(11) NOT NULL DEFAULT '0' COMMENT '版本号',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `version` (`version`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_nft`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_nft`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_nft` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`owner_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'owner_address',
|
||||
`creator_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'creator_address',
|
||||
`token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id',
|
||||
`token_type` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片 6:荣誉 7:徽章',
|
||||
`token_state` int(11) NOT NULL DEFAULT '0' COMMENT '0:正常状态 1:出售中 2:出租中',
|
||||
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
|
||||
`deleted` int(11) NOT NULL DEFAULT '0' COMMENT 'deleted',
|
||||
`confirm_count` int(11) NOT NULL DEFAULT '0' COMMENT 'confirm_count',
|
||||
`confirm_block_number` bigint NOT NULL DEFAULT '0' COMMENT 'confirm_block_number',
|
||||
`tags` varchar(60) NOT NULL DEFAULT '' COMMENT 'tags',
|
||||
`net_id` bigint NOT NULL DEFAULT '0' COMMENT 'net_id',
|
||||
`contract_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'contract_address',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `unikey` (`net_id`, `contract_address`, `token_id`),
|
||||
KEY `owner_address_token_type` (`owner_address`, `token_type`),
|
||||
KEY `owner_address_contract_address` (`owner_address`, `contract_address`),
|
||||
KEY `owner_address` (`owner_address`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_log`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_log`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_log` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`type` varchar(255) NOT NULL DEFAULT '' COMMENT '日志类型',
|
||||
`subtype` varchar(255) NOT NULL DEFAULT '' COMMENT '日志子类型',
|
||||
`param1` mediumblob COMMENT 'param1',
|
||||
`param2` mediumblob COMMENT 'param2',
|
||||
`param3` mediumblob COMMENT 'param3',
|
||||
`param4` mediumblob COMMENT 'param4',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_buy_record`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_buy_record`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_buy_record` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`blobdata` mediumblob COMMENT 'blobdata',
|
||||
`buyer_address` mediumblob COMMENT 'buyer_address',
|
||||
`order_id` varchar(60) COMMENT '订单id',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `order_id` (`order_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_nft1155`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_nft1155`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_nft1155` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`owner_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'owner_address',
|
||||
`token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id',
|
||||
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
|
||||
`balance` bigint NOT NULL DEFAULT '0' COMMENT '余额',
|
||||
`item_uniid` bigint NOT NULL DEFAULT '0' COMMENT 'item_uniid',
|
||||
`confirm_count` int(11) NOT NULL DEFAULT '0' COMMENT 'confirm_count',
|
||||
`confirm_block_number` bigint NOT NULL DEFAULT '0' COMMENT 'confirm_block_number',
|
||||
`net_id` bigint NOT NULL DEFAULT '0' COMMENT 'net_id',
|
||||
`contract_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'contract_address',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `unikey` (`owner_address`, `contract_address`, `token_id`),
|
||||
KEY `owner_address` (`owner_address`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_callback`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_callback`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_callback` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`cb_uuid` varchar(60) COMMENT '年月日时分秒_进程id_自增id',
|
||||
`params` mediumblob COMMENT '需要签名的字段(json不含签名)',
|
||||
`signature` varchar(60) COMMENT 'signature',
|
||||
`secret_key` varchar(60) COMMENT 'secret_key',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `cb_uuid` (`cb_uuid`),
|
||||
KEY `signature` (`signature`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
-- Dump completed on 2015-08-19 18:51:22
|
1696
sql/migrate/gamedb.sql
Normal file
1696
sql/migrate/gamedb.sql
Normal file
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,8 @@ define('DAILY_SELECTION_KEY', 'game2006api:daily_selection:');
|
||||
define('PLANET_BUY_KEY', 'game2006api:planet_buy:');
|
||||
|
||||
define('LAST_SESSION_KEY', 'last_session:');
|
||||
define('MATCH_CURRENT_TEAM_KEY', 'match:current_team:');
|
||||
define('MATCH_OK_KEY', 'match:ok:');
|
||||
|
||||
define('V_ITEM_GOLD', 10001); //金币
|
||||
define('V_ITEM_DIAMOND', 10014); //钻石
|
||||
|
@ -351,6 +351,110 @@ class BattleController extends BaseAuthedController {
|
||||
$customData = json_decode($customData, true);
|
||||
}
|
||||
|
||||
error_log(json_encode($customData));
|
||||
$zoneId = $customData['zone_id'];
|
||||
$nodeId = $customData['node_id'];
|
||||
$roomUuid = $customData['room_uuid'];
|
||||
$startTime = $customData['start_time'];
|
||||
|
||||
$data = array(
|
||||
'sign' => $sign,
|
||||
'zone_id' => $zoneId,
|
||||
'node_id' => $nodeId,
|
||||
'room_uuid' => $roomUuid,
|
||||
'start_time' => $startTime,
|
||||
'team_list' => array()
|
||||
);
|
||||
|
||||
$currSeason = mt\RankSeason::getCurrentSeason();
|
||||
foreach ($customData['team_list'] as $team) {
|
||||
$teamInfo = array(
|
||||
'team_uuid' => $team['team_uuid'],
|
||||
'members' => array()
|
||||
);
|
||||
foreach ($team['members'] as $member) {
|
||||
$accountId = $member['account_id'];
|
||||
$switchOk = $this->switchOnlineAccount($accountId);
|
||||
if (!$switchOk) {
|
||||
myself()->_rspErr(1, 'data error');
|
||||
return;
|
||||
}
|
||||
$info = $this->genInitBattleData();
|
||||
$userDb = User::find($accountId);
|
||||
if ($userDb) {
|
||||
$userPresetInfo = User::toPreset($userDb);
|
||||
$info['elo'] = $userDb['elo'];
|
||||
$info['rank'] = $userDb['rank'];
|
||||
$info['name'] = $userPresetInfo['name'];
|
||||
$info['level'] = $userPresetInfo['level'];
|
||||
$info['parachute'] = $userPresetInfo['parachute'];
|
||||
$info['hero_uniid'] = $userPresetInfo['hero_uniId'];
|
||||
$info['hero_id'] = $userPresetInfo['hero_id'];
|
||||
$info['hero_skin'] = $userPresetInfo['hero_skin'];
|
||||
$info['skill_id'] = $userPresetInfo['presetInfo']['skill_id'];
|
||||
$info['weapon_uuid1'] = $userPresetInfo['presetInfo']['weapon_uid1'];
|
||||
$info['weapon_uuid2'] = $userPresetInfo['presetInfo']['weapon_uid2'];
|
||||
$chipPageDb = ChipPage::find($userPresetInfo['presetInfo']['chip_page']);
|
||||
$info['chip_page'] = ChipPage::toDtoBattle($chipPageDb);
|
||||
$info['honor_info'] = $userPresetInfo['honor_info'];
|
||||
$battleDb = Battle::find($accountId);
|
||||
if ($battleDb){
|
||||
$battleData = json_decode($battleDb['battle_data'], true);
|
||||
$seasonBattleData = isset($battleData) ? getXVal($battleData, 'data', array()) : array();
|
||||
$info['battle_times'] = getXVal($seasonBattleData, 'total_battle_times', 0);
|
||||
}
|
||||
|
||||
$heroDb = Hero::findByAccountId($accountId,$info['hero_uniid']);
|
||||
if ($heroDb) {
|
||||
$info['is_valid_battle'] = 1;
|
||||
$info['hero_dto'] = Hero::toDto($heroDb);
|
||||
} else {
|
||||
$info['errcode'] = 51;
|
||||
$info['errmsg'] = 'paramater error';
|
||||
}
|
||||
|
||||
{
|
||||
$itemDb = Bag::findEx($accountId, V_ITEM_REVIVE_COIN);
|
||||
$info['revive_coin'] = $itemDb && $itemDb['item_num'] > 0 ? $itemDb['item_num'] : 0;
|
||||
}
|
||||
|
||||
{
|
||||
$info['match_mode'] = 0;
|
||||
if ($currSeason){
|
||||
$info['match_mode'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
array_push($teamInfo['members'], $info);
|
||||
}
|
||||
array_push($data['team_list'], $teamInfo);
|
||||
}
|
||||
error_log(json_encode($data));
|
||||
myself()->_rspData($data);
|
||||
}
|
||||
|
||||
public function getMobaBattleData()
|
||||
{
|
||||
$sign = '';
|
||||
$customData = array();
|
||||
{
|
||||
$rawData = file_get_contents('php://input');
|
||||
error_log($rawData);
|
||||
$headStr = strstr($rawData, '|', true);
|
||||
$sign = strstr($headStr, ':', true);
|
||||
$customData = strstr($rawData, '|');
|
||||
$customData = substr($customData, 1);
|
||||
error_log(json_encode(array(
|
||||
'sign' => $sign,
|
||||
'customData' => $customData
|
||||
)));
|
||||
if (md5($customData . HALL_KEY) != $sign) {
|
||||
myself()->_rspErr(1, 'sign error');
|
||||
return;
|
||||
}
|
||||
$customData = json_decode($customData, true);
|
||||
}
|
||||
|
||||
$zoneId = $customData['zone_id'];
|
||||
$nodeId = $customData['node_id'];
|
||||
$roomUuid = $customData['room_uuid'];
|
||||
|
264
webapp/controller/MatchController.class.php
Normal file
264
webapp/controller/MatchController.class.php
Normal file
@ -0,0 +1,264 @@
|
||||
<?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
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -62,6 +62,10 @@ class NftController extends BaseAuthedController
|
||||
array_push($listInfo,$info);
|
||||
}
|
||||
break;
|
||||
case Nft::EXPLORER_TYPE : {
|
||||
array_push($listInfo,$info);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,22 +116,22 @@ class UserController extends BaseAuthedController {
|
||||
}
|
||||
}
|
||||
|
||||
if (SERVER_ENV == _TEST) {
|
||||
if (defined('PRESENT_FREE_ITEM')) {
|
||||
|
||||
array_push($addItems,
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => 500000
|
||||
));
|
||||
$itemIds = array(30100,30200,30300,30400,30500,30600,30700,30800,30900,31000,40702,40902,40102);
|
||||
foreach ($itemIds as $row){
|
||||
array_push($addItems,
|
||||
array(
|
||||
'item_id' => $row,
|
||||
'item_num' => 1
|
||||
));
|
||||
}
|
||||
}
|
||||
array_push($addItems,
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => 500000
|
||||
));
|
||||
$itemIds = array(30100,30200,30300,30400,30500,30600,30700,30800,30900,31000,40702,40902,40102);
|
||||
foreach ($itemIds as $row){
|
||||
array_push($addItems,
|
||||
array(
|
||||
'item_id' => $row,
|
||||
'item_num' => 1
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$awardService = new services\AwardService();
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
|
@ -25,6 +25,7 @@ class Nft extends BaseModel
|
||||
const HONOR1_TYPE = 6; //荣誉
|
||||
const GENESIS_TYPE = 7; //创世徽章
|
||||
const PLANET_TYPE = 8; //星球
|
||||
const EXPLORER_TYPE = 9; //Explorer
|
||||
const RING_TYPE = 19; //戒指
|
||||
const AVATAR_TYPE = 30; //装饰
|
||||
|
||||
@ -432,7 +433,8 @@ class Nft extends BaseModel
|
||||
self::HONOR1_TYPE,
|
||||
self::RING_TYPE,
|
||||
self::GENESIS_TYPE,
|
||||
self::PLANET_TYPE
|
||||
self::PLANET_TYPE,
|
||||
self::EXPLORER_TYPE
|
||||
));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user