diff --git a/doc/Battle.py b/doc/Battle.py index 476df3e7..2e1ccbca 100644 --- a/doc/Battle.py +++ b/doc/Battle.py @@ -121,26 +121,27 @@ class Battle(object): ], 'response': [ _common.RspHead(), - ['account_id','','account_id'], - ['session_id','','session_id'], - ['battle_uuid','','battle_uuid'], - ['match_mode',0,'0:匹配 1:排位 2:pve'], - ['rank', 0, '当前段位'], - ['name','','用户名字'], - ['level',0,'用户等级'], - ['revive_coin',0,'复活币'], - ['hero_uniid',0,'英雄 uniid'], - ['hero_id',0,'英雄 item id'], - ['weapon_uuid1',0,'武器1 uniid'], - ['weapon_uuid2',0,'武器2 uniid'], - ['parachute',0,'降落伞 item id'], - ['hero_skin',0,'英雄皮肤 item id'], - ['skill_id',0,'备战技能 item id'], - ['battle_times',0,'战斗次数'], - ['chip_page',_common.Attr(),'铭文页属性'], - ['hero_dto','','英雄详情'], - ['weapon_dto1','','武器1详情'], - ['weapon_dto2','','武器2详情'], + _common.BattleData(), + ] + }, + { + 'method': 'POST', + 'desc': '获取战斗数据(客户端不用处理)getCustomBattleData', + 'group': 'Battle', + 'url': 'webapp/index.php?c=Battle&a=getCustomBattleData', + 'params': [ + _common.ReqHead(), + ['account_id', '', 'account_id'], + ['session_id', '', 'session_id'], + ], + 'response': [ + _common.RspHead(), + ['sign', '', '签名'], + ['zone_id', '', 'zone_id'], + ['node_id', '', 'node_id'], + ['start_time', '', 'start_time'], + ['room_uuid', '', '房间id'], + ['!team_list', [_common.BattleTeam()], '队伍数据'], ] }, { diff --git a/doc/Team.py b/doc/Team.py index 30c48576..b22ef6d2 100644 --- a/doc/Team.py +++ b/doc/Team.py @@ -167,5 +167,20 @@ class Team(object): '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(), + ] }, ] diff --git a/doc/_common.py b/doc/_common.py index ead04f9b..8201b803 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -694,15 +694,28 @@ class TeamInfo(object): def __init__(self): self.fields = [ + ['map_id', '', '地图id'], + ['node_id', '', 'node_id'], + ['zid', '', 'zid'], ['team_uuid', '', '队伍唯一id'], ['payload', '', '透传给CMJoin'], ['match_mode', 0, '0: 匹配赛模式 1: 排位赛 3: pve'], ['pve_instance_id', 0, 'pve副本id'], ['slot_num', 0, '槽位数 >=1 && <= 4'], ['state', 0, '0:未开始 1:准备就绪(这时客户端进入长链接走组队逻辑)'], + ['custom_room', CustomRoom(), '自定义房间'], ['!member_list', [TeamMember()], '队伍成员列表(包含自己)'], ] +class CustomRoom(object): + + def __init__(self): + self.fields = [ + ['custom_room_id', '', '自定义房间的ID'], + ['custom_room_state', '', '自定义房间的状态'], + ['custom_room_pwd', '', '自定义房间的密码'], + ] + class BuyableBox(object): def __init__(self): @@ -1478,4 +1491,38 @@ class AvatarInfo(object): ['item_type', 0, '1:翅膀'], ['status', 0, '0:为穿戴 1:已穿戴'], ['hero_uniid', 0, '穿戴的英雄唯一id'], - ] \ No newline at end of file + ] + +class BattleData(object): + + def __init__(self): + self.fields = [ + ['account_id','','account_id'], + ['session_id','','session_id'], + ['battle_uuid','','battle_uuid'], + ['match_mode',0,'0:匹配 1:排位 2:pve'], + ['rank', 0, '当前段位'], + ['name','','用户名字'], + ['level',0,'用户等级'], + ['revive_coin',0,'复活币'], + ['hero_uniid',0,'英雄 uniid'], + ['hero_id',0,'英雄 item id'], + ['weapon_uuid1',0,'武器1 uniid'], + ['weapon_uuid2',0,'武器2 uniid'], + ['parachute',0,'降落伞 item id'], + ['hero_skin',0,'英雄皮肤 item id'], + ['skill_id',0,'备战技能 item id'], + ['battle_times',0,'战斗次数'], + ['chip_page', Attr(),'铭文页属性'], + ['hero_dto','','英雄详情'], + ['weapon_dto1','','武器1详情'], + ['weapon_dto2','','武器2详情'], + ] + +class BattleTeam(object): + + def __init__(self): + self.fields = [ + ['team_uuid','','队伍唯一id'], + ['!members', BattleData(), '成员数据'], + ] diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index e5f532be..25aa1e6a 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -75,6 +75,18 @@ class BagController extends BaseAuthedController { $this->renameCard($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3); } break; + case mt\Item::FUNC_GUILD_CARD_SUBTYPE: + { + $this->_decItems(array( + array( + 'item_id' => $itemMeta['id'], + 'item_num' => 1 + ) + )); + $this->_rspOk(); + return; + } + break; case mt\Item::DRUG_TILI_SUBTYPE: { $this->useTiliDrug($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3); diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 1f3edc57..c84bea3a 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -67,6 +67,14 @@ class BaseAuthedController extends BaseController { $this->mysqlConn = null; } + public function switchOnlineAccount($accountId){ + $this->accountId = $accountId; + $this->mysqlConn = null; + $r = $this->_getRedis($this->_getAccountId()); + $this->sessionId = $r->get(LAST_SESSION_KEY . $this->_getAccountId()); + return !empty($this->sessionId); + } + public function _handlePre() { // if (SERVER_ENV == _ONLINE) { diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index c938c76f..30abcbf6 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -327,6 +327,144 @@ class BattleController extends BaseAuthedController { myself()->_rspData($data); } + public function getCustomBattleData() + { + $sign = ''; + $customData = array(); + { + $rawData = file_get_contents('php://input'); + error_log($rawData); + $sign = strstr($rawData, '|', 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']; + $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); + } + + private function genInitBattleData() + { + $accountId = myself()->_getAccountId(); + $sessionId = myself()->_getSessionId(); + $battleUuid = ''; + $currentGetStar = myself()->_getDailyV(TN_DAILY_GET_STAR_NUM, 0); + $info = array( + 'account_id' => $accountId, + 'session_id' => $sessionId, + 'battle_uuid' => $battleUuid, + 'current_get_star' => $currentGetStar, + 'elo' => 0, + 'rank' => 0, + 'name' => '', + 'level' =>'', + 'hero_uniid' => '', + 'hero_id' => '', + 'weapon_uuid1' => '', + 'weapon_uuid2' => '', + 'parachute' => '', + 'hero_skin' => '', + 'skill_id' => '', + 'chip_page' => array(), + 'battle_times' => '', + + 'hero_dto' => '', + 'weapon_dto1' => '', + 'weapon_dto2' => '', + 'is_valid_battle' => 0, + //'payload' => json_encode($member['cmjoin']), + 'errcode' => 0, + 'errmsg' => '', + ); + return $info; + } + public function getBattleDataNew() { error_log(json_encode($_REQUEST)); diff --git a/webapp/controller/ComputingPowerController.class.php b/webapp/controller/ComputingPowerController.class.php index e9b2b197..bb55f48c 100644 --- a/webapp/controller/ComputingPowerController.class.php +++ b/webapp/controller/ComputingPowerController.class.php @@ -74,6 +74,7 @@ class ComputingPowerController extends BaseAuthedController $curr_period['assignable_cec'] = $currentMeta['cec_pool']; $curr_period['total_exchange_hash_rate'] = $ownerNum; $curr_period['total_hash_rate'] = $totalNum; + $curr_period['await_time'] = strtotime($currentMeta['end_time']) - myself()->_getNowTime(); $target = \services\NumberService::ceilEx(min($totalNum / $currentMeta['cec_pool'] , 1),6); if ($totalNum == 0) { diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index e88db4e2..1e2703e0 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -30,6 +30,7 @@ class TeamController extends BaseAuthedController { public function createTeam() { + $mapId = getReqVal('map_id', 0); $nodeId = getReqVal('node_id', 1); $matchMode = getReqVal('match_mode', 0); $pveInstanceId = getReqVal('pve_instance_id', 0); @@ -81,13 +82,18 @@ class TeamController extends BaseAuthedController { $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)); + 'member_list' => array($userDto), + 'custom_room' => array(), + ); $r = $this->_getRedis($teamUuid); $this->saveTeamDb($r, $teamUuid, $teamDb); @@ -481,6 +487,28 @@ class TeamController extends BaseAuthedController { )); } + 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) { diff --git a/webapp/mt/Item.php b/webapp/mt/Item.php index dddc2f37..9151fade 100644 --- a/webapp/mt/Item.php +++ b/webapp/mt/Item.php @@ -107,12 +107,13 @@ class Item { const AVATAR_TYPE = 29; const FUNC_RENAME_CARD_SUBTYPE = 1; - const MATERIAL_CHIP_SUBTYPE = 3; + const FUNC_GUILD_CARD_SUBTYPE = 3; const DRUG_TILI_SUBTYPE = 4; const DRUG_DURABILITY_SUBTYPE = 5; const ROLE_CHIP_SUBTYPE = 1; const GUN_CHIP_SUBTYPE = 2; + const MATERIAL_CHIP_SUBTYPE = 3; const HERO_FRAGMENT_SUBTYPE = 1; const HERO_FRAGMENT_SUBTYPE_PRO = 3;