From 9e740ca211465a9276e481bfe00705da12761129 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Mon, 18 Sep 2023 14:14:51 +0800 Subject: [PATCH 01/12] 1 --- webapp/controller/ComputingPowerController.class.php | 1 + 1 file changed, 1 insertion(+) 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) { From 34744ce32cc59c9e5bd1a812a13220cb96040cce Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Wed, 20 Sep 2023 16:58:02 +0800 Subject: [PATCH 02/12] 1 --- doc/_common.py | 1 + webapp/controller/TeamController.class.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/doc/_common.py b/doc/_common.py index f06194d4..1859243c 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -693,6 +693,7 @@ class TeamInfo(object): def __init__(self): self.fields = [ + ['map_id', '', '地图id'], ['team_uuid', '', '队伍唯一id'], ['payload', '', '透传给CMJoin'], ['match_mode', 0, '0: 匹配赛模式 1: 排位赛 3: pve'], diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index e88db4e2..df097660 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,6 +82,7 @@ class TeamController extends BaseAuthedController { $userDto['permission'] = 1; $userDto['createtime'] = $userDb['createtime']; $teamDb = array( + 'map_id' => $mapId, 'team_uuid' => $teamUuid, 'state' => 0, 'payload' => '', From c61c0a66284db7d74104421d6ad315ce711f89ab Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Thu, 21 Sep 2023 11:30:24 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E5=B7=A5=E4=BC=9A=E6=94=B9=E5=90=8D?= =?UTF-8?q?=E5=8D=A1=E6=B6=88=E8=80=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/gamedb2006_migrate_230920_01.sql | 17 +++++++++++++++++ webapp/controller/BagController.class.php | 12 ++++++++++++ webapp/mt/Item.php | 3 ++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 sql/gamedb2006_migrate_230920_01.sql diff --git a/sql/gamedb2006_migrate_230920_01.sql b/sql/gamedb2006_migrate_230920_01.sql new file mode 100644 index 00000000..aeeecb19 --- /dev/null +++ b/sql/gamedb2006_migrate_230920_01.sql @@ -0,0 +1,17 @@ +begin; + +CREATE TABLE `t_mail` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', + `mailid` bigint NOT NULL DEFAULT '0' COMMENT '邮件id', + `confirmed` int(11) NOT NULL DEFAULT '0' COMMENT 'confirmed', + `attachments` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '附件', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + KEY `account_id_mailid` (`account_id`, `mailid`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +insert into version (version) values(2023091301); + +commit; 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/mt/Item.php b/webapp/mt/Item.php index 009c53e0..9b2e3ce0 100644 --- a/webapp/mt/Item.php +++ b/webapp/mt/Item.php @@ -106,12 +106,13 @@ class Item { const PLANET_TYPE = 28; 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; From 3ef16b6187a966d0eec97bdf305ca7a82abd6a47 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Thu, 21 Sep 2023 13:31:36 +0800 Subject: [PATCH 04/12] 1 --- sql/gamedb2006_migrate_230920_01.sql | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 sql/gamedb2006_migrate_230920_01.sql diff --git a/sql/gamedb2006_migrate_230920_01.sql b/sql/gamedb2006_migrate_230920_01.sql deleted file mode 100644 index aeeecb19..00000000 --- a/sql/gamedb2006_migrate_230920_01.sql +++ /dev/null @@ -1,17 +0,0 @@ -begin; - -CREATE TABLE `t_mail` ( - `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', - `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', - `mailid` bigint NOT NULL DEFAULT '0' COMMENT '邮件id', - `confirmed` int(11) NOT NULL DEFAULT '0' COMMENT 'confirmed', - `attachments` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '附件', - `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', - PRIMARY KEY (`idx`), - KEY `account_id_mailid` (`account_id`, `mailid`) -) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; - -insert into version (version) values(2023091301); - -commit; From a97f6469fa585f6d4c818a6cebc9cad26eb8552b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 21 Sep 2023 14:03:50 +0800 Subject: [PATCH 05/12] 1 --- doc/Battle.py | 38 ++++++++++++++++++-------------------- doc/_common.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/doc/Battle.py b/doc/Battle.py index 476df3e7..da5acd46 100644 --- a/doc/Battle.py +++ b/doc/Battle.py @@ -121,26 +121,24 @@ 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(), + ] + }, + { + 'desc': '获取战斗数据(客户端不用处理)getCustomBattleData', + 'group': 'Battle', + 'url': 'webapp/index.php?c=Battle&a=getCustomBattleData', + 'params': [ + _common.ReqHead(), + ['account_id', '', 'account_id'], + ['session_id', '', 'session_id'], + ['battle_uuid', '', 'battle_uuid'], + ], + 'response': [ + _common.RspHead(), + ['sign', '', '签名'], + ['room_uuid', '', '房间id'], + ['!team_list', _common.BattleTeam(), '队伍数据'], ] }, { diff --git a/doc/_common.py b/doc/_common.py index 1859243c..efcff4fc 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1466,3 +1466,37 @@ class StakingPreview(object): ['time', 0, '天数'], ['interest', 0, '利息'], ] + +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',_common.Attr(),'铭文页属性'], + ['hero_dto','','英雄详情'], + ['weapon_dto1','','武器1详情'], + ['weapon_dto2','','武器2详情'], + ] + +class BattleTeam(object): + + def __init__(self): + self.fields = [ + ['team_uuid','','队伍唯一id'], + ['!members', _common.BattleData(), '成员数据'], + ] From 20f9bbfea175ad017b44237b3048927ca5dac7a9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 21 Sep 2023 15:21:35 +0800 Subject: [PATCH 06/12] 1 --- doc/Battle.py | 4 +- webapp/controller/BattleController.class.php | 119 +++++++++++++++++++ 2 files changed, 121 insertions(+), 2 deletions(-) diff --git a/doc/Battle.py b/doc/Battle.py index da5acd46..52e22caf 100644 --- a/doc/Battle.py +++ b/doc/Battle.py @@ -125,6 +125,7 @@ class Battle(object): ] }, { + 'method': 'POST', 'desc': '获取战斗数据(客户端不用处理)getCustomBattleData', 'group': 'Battle', 'url': 'webapp/index.php?c=Battle&a=getCustomBattleData', @@ -132,13 +133,12 @@ class Battle(object): _common.ReqHead(), ['account_id', '', 'account_id'], ['session_id', '', 'session_id'], - ['battle_uuid', '', 'battle_uuid'], ], 'response': [ _common.RspHead(), ['sign', '', '签名'], ['room_uuid', '', '房间id'], - ['!team_list', _common.BattleTeam(), '队伍数据'], + ['!team_list', [_common.BattleTeam()], '队伍数据'], ] }, { diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 508d4624..badfbb73 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -299,6 +299,125 @@ class BattleController extends BaseAuthedController { } } +// { +// for ($i = 1; $i <= 2; ++$i) { +// if (isset($info['weapon_uuid' . $i])) { +// $gunDb = Gun::findByAccountId($account_id, $info['weapon_uuid' . $i]); +// if ($gunDb) { +// $info['weapon_dto' . $i] = Gun::toDto($gunDb); +// } +// } +// } +// } + + { + $itemDb = Bag::findEx($account_id, 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($data['members'], $info); + 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, '|'); + } + + $data = array( + 'members' => array() + ); + $currSeason = mt\RankSeason::getCurrentSeason(); + $account_id = getReqVal('account_id', ''); + $session_id = getReqVal('session_id', ''); + $battle_uuid = getReqVal('battle_uuid', ''); + $current_get_star = myself()->_getDailyV(TN_DAILY_GET_STAR_NUM, 0); + $info = array( + 'account_id' => $account_id, + 'session_id' => $session_id, + 'battle_uuid' => $battle_uuid, + 'current_get_star' => $current_get_star, + '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' => '', + ); + if (!phpcommon\isValidSessionId($account_id, $session_id)) { + $info['errcode'] = 50; + $info['errmsg'] = 'invalid session_id'; + }else{ + { + $userDb = User::find($account_id); + 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($account_id); + 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); + } + + }else{ + $info['errcode'] = 51; + $info['errmsg'] = 'paramater error'; + } + } + + { + $heroDb = Hero::findByAccountId($account_id,$info['hero_uniid']); + if ($heroDb) { + $info['is_valid_battle'] = 1; + $info['hero_dto'] = Hero::toDto($heroDb); + } else { + $info['errcode'] = 51; + $info['errmsg'] = 'paramater error'; + } + } + // { // for ($i = 1; $i <= 2; ++$i) { // if (isset($info['weapon_uuid' . $i])) { From c9f8433356b4ed9c8cf0033ad1cc3ecc8c59915d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 21 Sep 2023 15:24:07 +0800 Subject: [PATCH 07/12] 1 --- webapp/controller/BattleController.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index badfbb73..2189676c 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -335,6 +335,10 @@ class BattleController extends BaseAuthedController { error_log($rawData); $sign = strstr($rawData, '|', true); $customData = strstr($rawData, '|'); + if (md5($customData . HALL_KEY) != $sign) { + myself()->_rspErr(1, 'sign error'); + return; + } } $data = array( From c761d426fbef40bae5b3e4ba6c0e3593dfbd82ee Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Thu, 21 Sep 2023 16:25:45 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E9=98=9F=E4=BC=8D=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Team.py | 15 +++++++++++ doc/_common.py | 12 +++++++++ webapp/controller/TeamController.class.php | 31 +++++++++++++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) 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 efcff4fc..bd9188a8 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -694,15 +694,27 @@ 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): diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index df097660..ec2f3b54 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -83,13 +83,17 @@ class TeamController extends BaseAuthedController { $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); @@ -483,6 +487,31 @@ 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_state, + ); +// $teamDb['custom_room_id'] = $custom_room_id; +// $teamDb['custom_room_state'] = $custom_room_state; +// $teamDb['custom_room_pwd'] = $custom_room_state; + $this->saveTeamDb($r, $teamUuid, $teamDb); + $this->_rspData(array( + 'team_uuid' => $teamUuid + )); + } + private function readTeamDb($r, $teamUuid) { From db0c5eac48dd63aa3c244452d823dcdfa876a5b8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 21 Sep 2023 16:27:29 +0800 Subject: [PATCH 09/12] 1 --- doc/Battle.py | 3 + .../controller/BaseAuthedController.class.php | 8 + webapp/controller/BattleController.class.php | 153 +++++++++--------- 3 files changed, 88 insertions(+), 76 deletions(-) diff --git a/doc/Battle.py b/doc/Battle.py index 52e22caf..2e1ccbca 100644 --- a/doc/Battle.py +++ b/doc/Battle.py @@ -137,6 +137,9 @@ class Battle(object): '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/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index ffbd6efe..cd071dc1 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -65,6 +65,14 @@ class BaseAuthedController extends BaseController { $this->mysqlConn = null; } + public function switchOnlineAccount($accountId){ + $this->accountId = $accountId; + $this->mysqlConn = null; + $r = $this->_getRedis($this->_getAccountId()); + $myself->sessionId = $r->get(LAST_SESSION_KEY . $this->_getAccountId()); + return !empty($myself->sessionId); + } + public function _handlePre() { // if (SERVER_ENV == _ONLINE) { diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 2189676c..f617b08b 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -341,48 +341,31 @@ class BattleController extends BaseAuthedController { } } + $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, 'members' => array() ); - $currSeason = mt\RankSeason::getCurrentSeason(); - $account_id = getReqVal('account_id', ''); - $session_id = getReqVal('session_id', ''); - $battle_uuid = getReqVal('battle_uuid', ''); - $current_get_star = myself()->_getDailyV(TN_DAILY_GET_STAR_NUM, 0); - $info = array( - 'account_id' => $account_id, - 'session_id' => $session_id, - 'battle_uuid' => $battle_uuid, - 'current_get_star' => $current_get_star, - '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' => '', - ); - if (!phpcommon\isValidSessionId($account_id, $session_id)) { - $info['errcode'] = 50; - $info['errmsg'] = 'invalid session_id'; - }else{ - { - $userDb = User::find($account_id); - if ($userDb){ + $currSeason = mt\RankSeason::getCurrentSeason(); + foreach ($customData['members'] as $team) { + 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']; @@ -405,50 +388,68 @@ class BattleController extends BaseAuthedController { $info['battle_times'] = getXVal($seasonBattleData, 'total_battle_times', 0); } - }else{ - $info['errcode'] = 51; - $info['errmsg'] = 'paramater error'; - } - } - - { - $heroDb = Hero::findByAccountId($account_id,$info['hero_uniid']); - if ($heroDb) { - $info['is_valid_battle'] = 1; - $info['hero_dto'] = Hero::toDto($heroDb); - } else { - $info['errcode'] = 51; - $info['errmsg'] = 'paramater error'; - } - } - -// { -// for ($i = 1; $i <= 2; ++$i) { -// if (isset($info['weapon_uuid' . $i])) { -// $gunDb = Gun::findByAccountId($account_id, $info['weapon_uuid' . $i]); -// if ($gunDb) { -// $info['weapon_dto' . $i] = Gun::toDto($gunDb); -// } -// } -// } -// } - - { - $itemDb = Bag::findEx($account_id, 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; + $heroDb = Hero::findByAccountId($account_id,$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($account_id, 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($data['members'], $info); } } - array_push($data['members'], $info); myself()->_rspData($data); } + private function genInitBattleData() + { + $accountId = myself()->_getAccountId(); + $sessionId = myself()->_getSessionId(); + $battleUuuid = ''; + $currentGetStar = myself()->_getDailyV(TN_DAILY_GET_STAR_NUM, 0); + $info = array( + 'account_id' => $accountId, + 'session_id' => $sessionIid, + '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' => '', + ); + } + public function getBattleDataNew() { error_log(json_encode($_REQUEST)); From a13df32bcabfc65d1e33c31dd9e0c2e5282f5982 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Thu, 21 Sep 2023 16:29:31 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E9=98=9F=E4=BC=8D=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/controller/TeamController.class.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index ec2f3b54..1e2703e0 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -501,11 +501,8 @@ class TeamController extends BaseAuthedController { $teamDb['custom_room'] = array( 'custom_room_id' => $custom_room_id, 'custom_room_state' => $custom_room_state, - 'custom_room_pwd' => $custom_room_state, + 'custom_room_pwd' => $custom_room_pwd, ); -// $teamDb['custom_room_id'] = $custom_room_id; -// $teamDb['custom_room_state'] = $custom_room_state; -// $teamDb['custom_room_pwd'] = $custom_room_state; $this->saveTeamDb($r, $teamUuid, $teamDb); $this->_rspData(array( 'team_uuid' => $teamUuid From d86af0711bc1a813701ac7794fec1f544dfd2b38 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 21 Sep 2023 16:34:48 +0800 Subject: [PATCH 11/12] 1 --- doc/_common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/_common.py b/doc/_common.py index bd9188a8..bf5b26fc 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1499,7 +1499,7 @@ class BattleData(object): ['hero_skin',0,'英雄皮肤 item id'], ['skill_id',0,'备战技能 item id'], ['battle_times',0,'战斗次数'], - ['chip_page',_common.Attr(),'铭文页属性'], + ['chip_page', Attr(),'铭文页属性'], ['hero_dto','','英雄详情'], ['weapon_dto1','','武器1详情'], ['weapon_dto2','','武器2详情'], @@ -1510,5 +1510,5 @@ class BattleTeam(object): def __init__(self): self.fields = [ ['team_uuid','','队伍唯一id'], - ['!members', _common.BattleData(), '成员数据'], + ['!members', BattleData(), '成员数据'], ] From d761bafcd35a6300cfa81e2d6e77c1b2d3290f8f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 25 Sep 2023 15:32:50 +0800 Subject: [PATCH 12/12] 1 --- .../controller/BaseAuthedController.class.php | 4 +-- webapp/controller/BattleController.class.php | 30 ++++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index cd071dc1..cdef5724 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -69,8 +69,8 @@ class BaseAuthedController extends BaseController { $this->accountId = $accountId; $this->mysqlConn = null; $r = $this->_getRedis($this->_getAccountId()); - $myself->sessionId = $r->get(LAST_SESSION_KEY . $this->_getAccountId()); - return !empty($myself->sessionId); + $this->sessionId = $r->get(LAST_SESSION_KEY . $this->_getAccountId()); + return !empty($this->sessionId); } public function _handlePre() diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index f617b08b..980d245b 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -335,10 +335,16 @@ class BattleController extends BaseAuthedController { 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']; @@ -351,11 +357,16 @@ class BattleController extends BaseAuthedController { 'zone_id' => $zoneId, 'node_id' => $nodeId, 'room_uuid' => $roomUuid, - 'members' => array() + 'start_time' => $startTime, + 'team_list' => array() ); $currSeason = mt\RankSeason::getCurrentSeason(); - foreach ($customData['members'] as $team) { + 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); @@ -381,14 +392,14 @@ class BattleController extends BaseAuthedController { $chipPageDb = ChipPage::find($userPresetInfo['presetInfo']['chip_page']); $info['chip_page'] = ChipPage::toDtoBattle($chipPageDb); $info['honor_info'] = $userPresetInfo['honor_info']; - $battleDb = Battle::find($account_id); + $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($account_id,$info['hero_uniid']); + $heroDb = Hero::findByAccountId($accountId,$info['hero_uniid']); if ($heroDb) { $info['is_valid_battle'] = 1; $info['hero_dto'] = Hero::toDto($heroDb); @@ -398,7 +409,7 @@ class BattleController extends BaseAuthedController { } { - $itemDb = Bag::findEx($account_id, V_ITEM_REVIVE_COIN); + $itemDb = Bag::findEx($accountId, V_ITEM_REVIVE_COIN); $info['revive_coin'] = $itemDb && $itemDb['item_num'] > 0 ? $itemDb['item_num'] : 0; } @@ -409,9 +420,11 @@ class BattleController extends BaseAuthedController { } } } - array_push($data['members'], $info); + array_push($teamInfo['members'], $info); } + array_push($data['team_list'], $teamInfo); } + error_log(json_encode($data)); myself()->_rspData($data); } @@ -419,11 +432,11 @@ class BattleController extends BaseAuthedController { { $accountId = myself()->_getAccountId(); $sessionId = myself()->_getSessionId(); - $battleUuuid = ''; + $battleUuid = ''; $currentGetStar = myself()->_getDailyV(TN_DAILY_GET_STAR_NUM, 0); $info = array( 'account_id' => $accountId, - 'session_id' => $sessionIid, + 'session_id' => $sessionId, 'battle_uuid' => $battleUuid, 'current_get_star' => $currentGetStar, 'elo' => 0, @@ -448,6 +461,7 @@ class BattleController extends BaseAuthedController { 'errcode' => 0, 'errmsg' => '', ); + return $info; } public function getBattleDataNew()