Merge branch 'wings' of git.kingsome.cn:server/game2006api into wings

This commit is contained in:
hujiabin 2023-09-25 18:05:40 +08:00
commit 08df2e2dc3
9 changed files with 274 additions and 23 deletions

View File

@ -121,26 +121,27 @@ class Battle(object):
], ],
'response': [ 'response': [
_common.RspHead(), _common.RspHead(),
['account_id','','account_id'], _common.BattleData(),
['session_id','','session_id'], ]
['battle_uuid','','battle_uuid'], },
['match_mode',0,'0:匹配 1:排位 2:pve'], {
['rank', 0, '当前段位'], 'method': 'POST',
['name','','用户名字'], 'desc': '获取战斗数据(客户端不用处理)getCustomBattleData',
['level',0,'用户等级'], 'group': 'Battle',
['revive_coin',0,'复活币'], 'url': 'webapp/index.php?c=Battle&a=getCustomBattleData',
['hero_uniid',0,'英雄 uniid'], 'params': [
['hero_id',0,'英雄 item id'], _common.ReqHead(),
['weapon_uuid1',0,'武器1 uniid'], ['account_id', '', 'account_id'],
['weapon_uuid2',0,'武器2 uniid'], ['session_id', '', 'session_id'],
['parachute',0,'降落伞 item id'], ],
['hero_skin',0,'英雄皮肤 item id'], 'response': [
['skill_id',0,'备战技能 item id'], _common.RspHead(),
['battle_times',0,'战斗次数'], ['sign', '', '签名'],
['chip_page',_common.Attr(),'铭文页属性'], ['zone_id', '', 'zone_id'],
['hero_dto','','英雄详情'], ['node_id', '', 'node_id'],
['weapon_dto1','','武器1详情'], ['start_time', '', 'start_time'],
['weapon_dto2','','武器2详情'], ['room_uuid', '', '房间id'],
['!team_list', [_common.BattleTeam()], '队伍数据'],
] ]
}, },
{ {

View File

@ -167,5 +167,20 @@ class Team(object):
'response': [ 'response': [
_common.RspHead(), _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(),
]
}, },
] ]

View File

@ -694,15 +694,28 @@ class TeamInfo(object):
def __init__(self): def __init__(self):
self.fields = [ self.fields = [
['map_id', '', '地图id'],
['node_id', '', 'node_id'],
['zid', '', 'zid'],
['team_uuid', '', '队伍唯一id'], ['team_uuid', '', '队伍唯一id'],
['payload', '', '透传给CMJoin'], ['payload', '', '透传给CMJoin'],
['match_mode', 0, '0: 匹配赛模式 1: 排位赛 3: pve'], ['match_mode', 0, '0: 匹配赛模式 1: 排位赛 3: pve'],
['pve_instance_id', 0, 'pve副本id'], ['pve_instance_id', 0, 'pve副本id'],
['slot_num', 0, '槽位数 >=1 && <= 4'], ['slot_num', 0, '槽位数 >=1 && <= 4'],
['state', 0, '0:未开始 1:准备就绪(这时客户端进入长链接走组队逻辑)'], ['state', 0, '0:未开始 1:准备就绪(这时客户端进入长链接走组队逻辑)'],
['custom_room', CustomRoom(), '自定义房间'],
['!member_list', [TeamMember()], '队伍成员列表(包含自己)'], ['!member_list', [TeamMember()], '队伍成员列表(包含自己)'],
] ]
class CustomRoom(object):
def __init__(self):
self.fields = [
['custom_room_id', '', '自定义房间的ID'],
['custom_room_state', '', '自定义房间的状态'],
['custom_room_pwd', '', '自定义房间的密码'],
]
class BuyableBox(object): class BuyableBox(object):
def __init__(self): def __init__(self):
@ -1478,4 +1491,38 @@ class AvatarInfo(object):
['item_type', 0, '1:翅膀'], ['item_type', 0, '1:翅膀'],
['status', 0, '0:为穿戴 1:已穿戴'], ['status', 0, '0:为穿戴 1:已穿戴'],
['hero_uniid', 0, '穿戴的英雄唯一id'], ['hero_uniid', 0, '穿戴的英雄唯一id'],
] ]
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(), '成员数据'],
]

View File

@ -75,6 +75,18 @@ class BagController extends BaseAuthedController {
$this->renameCard($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3); $this->renameCard($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3);
} }
break; 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: case mt\Item::DRUG_TILI_SUBTYPE:
{ {
$this->useTiliDrug($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3); $this->useTiliDrug($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3);

View File

@ -67,6 +67,14 @@ class BaseAuthedController extends BaseController {
$this->mysqlConn = null; $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() public function _handlePre()
{ {
// if (SERVER_ENV == _ONLINE) { // if (SERVER_ENV == _ONLINE) {

View File

@ -327,6 +327,144 @@ class BattleController extends BaseAuthedController {
myself()->_rspData($data); 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() public function getBattleDataNew()
{ {
error_log(json_encode($_REQUEST)); error_log(json_encode($_REQUEST));

View File

@ -74,6 +74,7 @@ class ComputingPowerController extends BaseAuthedController
$curr_period['assignable_cec'] = $currentMeta['cec_pool']; $curr_period['assignable_cec'] = $currentMeta['cec_pool'];
$curr_period['total_exchange_hash_rate'] = $ownerNum; $curr_period['total_exchange_hash_rate'] = $ownerNum;
$curr_period['total_hash_rate'] = $totalNum; $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); $target = \services\NumberService::ceilEx(min($totalNum / $currentMeta['cec_pool'] , 1),6);
if ($totalNum == 0) { if ($totalNum == 0) {

View File

@ -30,6 +30,7 @@ class TeamController extends BaseAuthedController {
public function createTeam() public function createTeam()
{ {
$mapId = getReqVal('map_id', 0);
$nodeId = getReqVal('node_id', 1); $nodeId = getReqVal('node_id', 1);
$matchMode = getReqVal('match_mode', 0); $matchMode = getReqVal('match_mode', 0);
$pveInstanceId = getReqVal('pve_instance_id', 0); $pveInstanceId = getReqVal('pve_instance_id', 0);
@ -81,13 +82,18 @@ class TeamController extends BaseAuthedController {
$userDto['permission'] = 1; $userDto['permission'] = 1;
$userDto['createtime'] = $userDb['createtime']; $userDto['createtime'] = $userDb['createtime'];
$teamDb = array( $teamDb = array(
'map_id' => $mapId,
'node_id' => $nodeId,
'zid' => $zid,
'team_uuid' => $teamUuid, 'team_uuid' => $teamUuid,
'state' => 0, 'state' => 0,
'payload' => '', 'payload' => '',
'match_mode' => $matchMode, 'match_mode' => $matchMode,
'pve_instance_id' => $pveInstanceId, 'pve_instance_id' => $pveInstanceId,
'slot_num' => 1, 'slot_num' => 1,
'member_list' => array($userDto)); 'member_list' => array($userDto),
'custom_room' => array(),
);
$r = $this->_getRedis($teamUuid); $r = $this->_getRedis($teamUuid);
$this->saveTeamDb($r, $teamUuid, $teamDb); $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) private function readTeamDb($r, $teamUuid)
{ {

View File

@ -107,12 +107,13 @@ class Item {
const AVATAR_TYPE = 29; const AVATAR_TYPE = 29;
const FUNC_RENAME_CARD_SUBTYPE = 1; const FUNC_RENAME_CARD_SUBTYPE = 1;
const MATERIAL_CHIP_SUBTYPE = 3; const FUNC_GUILD_CARD_SUBTYPE = 3;
const DRUG_TILI_SUBTYPE = 4; const DRUG_TILI_SUBTYPE = 4;
const DRUG_DURABILITY_SUBTYPE = 5; const DRUG_DURABILITY_SUBTYPE = 5;
const ROLE_CHIP_SUBTYPE = 1; const ROLE_CHIP_SUBTYPE = 1;
const GUN_CHIP_SUBTYPE = 2; const GUN_CHIP_SUBTYPE = 2;
const MATERIAL_CHIP_SUBTYPE = 3;
const HERO_FRAGMENT_SUBTYPE = 1; const HERO_FRAGMENT_SUBTYPE = 1;
const HERO_FRAGMENT_SUBTYPE_PRO = 3; const HERO_FRAGMENT_SUBTYPE_PRO = 3;