This commit is contained in:
aozhiwei 2021-12-10 17:50:09 +08:00
parent 083e563cc5
commit 279dbe96fc
6 changed files with 134 additions and 168 deletions

View File

@ -5,65 +5,74 @@ import _common
class Team(object): class Team(object):
def __init__(self): def __init__(self):
self.apis_ = [ self.apis = [
{ {
'desc': 'createTeam', 'name': 'createTeam',
'group': 'Team', 'desc': '创建队伍',
'url': 'webapp/index.php?c=Team&a=createTeam', 'group': 'Team',
'params': [ 'url': 'webapp/index.php?c=Team&a=createTeam',
_common.ReqHead(), 'params': [
['node_id', 0, '节点id'], _common.ReqHead(),
['map_id', 0, '地图id'], ['node_id', 0, '节点id'],
], ['map_id', 0, '地图id'],
'response': [ ],
_common.RspHead(), 'response': [
['team_info', _common.TeamInfo(), '队伍信息'], _common.RspHead(),
] ['team_uuid', '', '队伍唯一id'],
}, ]
{ },
'desc': 'teamInfo', {
'group': 'Team', 'name': 'teamInfo',
'url': 'webapp/index.php?c=Team&a=teamInfo', 'desc': '获取队伍信息',
'params': [ 'group': 'Team',
_common.ReqHead(), 'url': 'webapp/index.php?c=Team&a=teamInfo',
['team_uuid', '', '队伍唯一id'], 'params': [
], _common.ReqHead(),
'response': [ ['team_uuid', '', '队伍唯一id'],
_common.RspHead(), ],
['team_info', _common.TeamInfo(), '队伍信息'], 'response': [
] _common.RspHead(),
}, ['team_info', _common.TeamInfo(), '队伍信息'],
{ ]
'desc': 'joinTeam', },
'group': 'Team', {
'url': 'webapp/index.php?c=Team&a=joinTeam', 'name': 'joinTeam',
'params': [ 'desc': '加入队伍',
_common.ReqHead(), 'group': 'Team',
], 'url': 'webapp/index.php?c=Team&a=joinTeam',
'response': [ 'params': [
_common.RspHead(), _common.ReqHead(),
] ['team_uuid', '', '队伍唯一id'],
}, ],
{ 'response': [
'desc': 'leaveTeam', _common.RspHead(),
'group': 'Team', ['team_uuid', '', '队伍唯一id'],
'url': 'webapp/index.php?c=Team&a=leaveTeam', ]
'params': [ },
_common.ReqHead(), {
], 'name': 'leaveTeam',
'response': [ 'desc': '离开队伍',
_common.RspHead(), 'group': 'Team',
] 'url': 'webapp/index.php?c=Team&a=leaveTeam',
}, 'params': [
{ _common.ReqHead(),
'desc': 'startGame', ['team_uuid', '', '队伍唯一id'],
'group': 'Team', ],
'url': 'webapp/index.php?c=Team&a=startGame', 'response': [
'params': [ _common.RspHead(),
_common.ReqHead(), ]
], },
'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(),
]
},
] ]

View File

@ -241,6 +241,7 @@ class SeasonCard(object):
['card_lv', 0, '手册等级'], ['card_lv', 0, '手册等级'],
['card_exp', 0, '手册经验'], ['card_exp', 0, '手册经验'],
['card_max_exp', 0, '手册经验上限'], ['card_max_exp', 0, '手册经验上限'],
['buy_level_price', 0, '等级价格(钻石)'],
['!gift_packages', [SeasonCardGiftPackage()], '礼包列表'], ['!gift_packages', [SeasonCardGiftPackage()], '礼包列表'],
['!received_level_rewards1', [0], '等级解锁的奖励已领取等级列表(普通手册)'], ['!received_level_rewards1', [0], '等级解锁的奖励已领取等级列表(普通手册)'],
['!received_level_rewards2', [0], '等级解锁的奖励已领取等级列表(精英)'], ['!received_level_rewards2', [0], '等级解锁的奖励已领取等级列表(精英)'],
@ -326,7 +327,6 @@ class TeamInfo(object):
def __init__(self): def __init__(self):
self.fields = [ self.fields = [
['team_uuid', '', '队伍唯一id'], ['team_uuid', '', '队伍唯一id'],
['map_id', 0, '地图id'],
['state', 0, '0:未开始 1:准备就绪(这时客户端进入长链接走组队逻辑)'], ['state', 0, '0:未开始 1:准备就绪(这时客户端进入长链接走组队逻辑)'],
['member_list', [TeamMember()], '队伍成员列表(包含自己)'], ['!member_list', [TeamMember()], '队伍成员列表(包含自己)'],
] ]

View File

@ -81,6 +81,8 @@ class MissionController extends BaseAuthedController {
} }
} }
$this->_rspData(array( $this->_rspData(array(
'current_active_value' => 0,
'max_active_value' => 0,
'mission_list1' => $missionDtoList1, 'mission_list1' => $missionDtoList1,
'mission_list2' => $missionDtoList2 'mission_list2' => $missionDtoList2
)); ));

View File

@ -66,6 +66,7 @@ class SeasonCardController extends BaseAuthedController {
public function info() public function info()
{ {
$seasonCardMeta = mt\SeasonCard::get(1);
$this->_rspData(array( $this->_rspData(array(
'info' => array( 'info' => array(
'season_id' => $this->currSeasonMeta['id'], 'season_id' => $this->currSeasonMeta['id'],
@ -75,6 +76,7 @@ class SeasonCardController extends BaseAuthedController {
'card_exp' => $this->seasonDb ? $this->seasonDb['card_exp'] : 0, 'card_exp' => $this->seasonDb ? $this->seasonDb['card_exp'] : 0,
'card_max_exp' => $this->seasonDb ? $this->seasonDb['card_exp'] : 1, 'card_max_exp' => $this->seasonDb ? $this->seasonDb['card_exp'] : 1,
'gift_packages' => $this->getGiftPackages(), 'gift_packages' => $this->getGiftPackages(),
'buy_level_price' => $seasonCardMeta ? $seasonCardMeta['cost'] : 0,
'received_level_rewards1' => $this->getReceivedLevelRewards(SeasonCard::NORMAL_PACKAGE_ID), 'received_level_rewards1' => $this->getReceivedLevelRewards(SeasonCard::NORMAL_PACKAGE_ID),
'received_level_rewards2' => $this->getReceivedLevelRewards(SeasonCard::VIP_PACKAGE_ID), 'received_level_rewards2' => $this->getReceivedLevelRewards(SeasonCard::VIP_PACKAGE_ID),
) )
@ -136,14 +138,21 @@ class SeasonCardController extends BaseAuthedController {
$this->_rspErr(2, 'add_level越界'); $this->_rspErr(2, 'add_level越界');
return; return;
} }
$costItemId = V_ITEM_GOLD; $costItemId = V_ITEM_DIAMOND;
$costItemNum = mt\SeasonCard::calcCost($currCardMeta, $newCardMeta); $costItemNum = mt\SeasonCard::calcCost($currCardMeta, $newCardMeta);
$itemNum = $this->_getItemCount($costItemId, $this->userInfo); $itemNum = $this->_getItemCount($costItemId, $this->userInfo);
if ($itemNum < $costItemId) { if ($itemNum < $costItemNum) {
$this->_rspErr(3, '金币不足'); $this->_rspErr(3, '钻石不足');
return; return;
} }
$this->_decItems(array(
array(
'item_id' => $costItemId,
'item_num' => $costItemNum
)
));
Season::updateCardLv($this->currSeasonMeta['id'], $newLevel); Season::updateCardLv($this->currSeasonMeta['id'], $newLevel);
$this->propertyChgService->addUserChg();
$this->_rspData(array( $this->_rspData(array(
'award' => $this->awardService->toDto(), 'award' => $this->awardService->toDto(),
'property_chg' => $this->propertyChgService->toDto(), 'property_chg' => $this->propertyChgService->toDto(),

View File

@ -1,86 +1,32 @@
<?php <?php
require_once('models/User.php');
use phpcommon\SqlHelper;
use models\User;
use models\Hero;
class TeamController extends BaseAuthedController { class TeamController extends BaseAuthedController {
public function createTeam() public function createTeam()
{ {
$node_id = 1; $nodeId = getReqVal('node_id', 1);
if (isset($_REQUEST['node_id'])) { $teamUuid = $nodeId . '_' . md5($this->_getAccountId()) . $this->_getNowTime();
$node_id = (int)$_REQUEST['node_id'];
}
$team_uuid = $node_id . '_' . md5($_REQUEST['account_id']) . phpcommon\getNowTime();
$rank = 1;
$equip_id = 0;
$model = 0;
$hiID = 0; $userDb = User::find($this->_getAccountId());
$hiFrameID = 0; $teamDb = array(
$sex = 2; 'team_uuid' => $teamUuid,
$map_id = 0;
$roomManager = 1;
$readyState = 1;
$selectHeroID = 0;
$selectHeroSkinID = 0;
if (isset($_REQUEST['map_id'])) {
$map_id = $_REQUEST['map_id'];
}
if (isset($_REQUEST['rank'])) {
$rank = $_REQUEST['rank'];
}
if (isset($_REQUEST['model'])) {
$model = $_REQUEST['model'];
}
if (isset($_REQUEST['hiID'])) {
$hiID = $_REQUEST['hiID'];
}
if (isset($_REQUEST['sex'])) {
$sex = $_REQUEST['sex'];
}
if (isset($_REQUEST['hiFrameID'])) {
$hiFrameID = $_REQUEST['hiFrameID'];
}
$account_id = $_REQUEST['account_id'];
$conn = $this->_getMysql($account_id);
$row = $conn->execQueryOne('SELECT game_times, win_times, kills, create_time FROM user WHERE account_id=:account_id;',
array(
'account_id' => $account_id,
));
$team_db = array(
'team_uuid' => $team_uuid,
'state' => 0, 'state' => 0,
'model' => $model, 'member_list' => array($userDb));
'map_id' => $map_id,
'member_list' => array(
array(
'idx' => 1,
'account_id' => $_REQUEST['account_id'],
'name' => $_REQUEST['name'],
'rank' => $rank,
'game_times' => $row['game_times'],
'win_times' => $row['win_times'],
'kills' => $row['kills'],
'create_time' => $row['create_time'],
'roomManager' => $roomManager,
'readyState' => $readyState,
'hiID' => $hiID,
'hiFrameID' => $hiFrameID,
'sex' => $sex,
'selectHeroID' => $selectHeroID,
"selectHeroSkinID" => $selectHeroSkinID
)
));
$r = $this->_getRedis($team_uuid); $r = $this->_getRedis($teamUuid);
$r -> set(TEAMID_KEY . $team_uuid, json_encode($team_db)); $r->set(TEAMID_KEY . $teamUuid, json_encode($teamDb));
$r -> pexpire(TEAMID_KEY . $team_uuid, 1000*600); $r->pexpire(TEAMID_KEY . $teamUuid, 1000*600);
echo json_encode (array( echo json_encode (array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
'team_uuid' => $team_uuid 'team_uuid' => $teamUuid
)); ));
} }
@ -89,13 +35,13 @@ class TeamController extends BaseAuthedController {
if (!isset($_REQUEST['team_uuid'])) { if (!isset($_REQUEST['team_uuid'])) {
return; return;
} }
$team_uuid = $_REQUEST['team_uuid']; $teamUuid = $_REQUEST['team_uuid'];
$r = $this->_getRedis($team_uuid); $r = $this->_getRedis($teamUuid);
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$sessionid = $_REQUEST['session_id']; $sessionid = $_REQUEST['session_id'];
$user_db_str = $r->get(TEAMID_KEY . $team_uuid); $user_db_str = $r->get(TEAMID_KEY . $teamUuid);
if (empty($user_db_str)) { if (empty($user_db_str)) {
phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); phpcommon\sendError(ERR_USER_BASE + 1,'session失效1');
return; return;
@ -126,7 +72,7 @@ class TeamController extends BaseAuthedController {
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg'=> '', 'errmsg'=> '',
'team_uuid' => $team_uuid, 'team_uuid' => $teamUuid,
'state' => $user_db['state'], 'state' => $user_db['state'],
'member_list' => $member_list, 'member_list' => $member_list,
'model' => $user_db['model'], 'model' => $user_db['model'],
@ -139,11 +85,11 @@ class TeamController extends BaseAuthedController {
if (!isset($_REQUEST['team_uuid'])) { if (!isset($_REQUEST['team_uuid'])) {
return; return;
} }
$team_uuid = $_REQUEST['team_uuid']; $teamUuid = $_REQUEST['team_uuid'];
$r = $this->_getRedis($team_uuid); $r = $this->_getRedis($teamUuid);
$user_db_str = $r->get(TEAMID_KEY.$team_uuid); $user_db_str = $r->get(TEAMID_KEY.$teamUuid);
if (empty($user_db_str)) { if (empty($user_db_str)) {
phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); phpcommon\sendError(ERR_USER_BASE + 1,'session失效1');
return; return;
@ -214,12 +160,12 @@ class TeamController extends BaseAuthedController {
'selectHeroID' => $selectHeroID, 'selectHeroID' => $selectHeroID,
"selectHeroSkinID" => $selectHeroSkinID "selectHeroSkinID" => $selectHeroSkinID
)); ));
$r->set(TEAMID_KEY . $team_uuid, json_encode($user_db)); $r->set(TEAMID_KEY . $teamUuid, json_encode($user_db));
$r -> pexpire(TEAMID_KEY . $team_uuid, 1000 * 600); $r -> pexpire(TEAMID_KEY . $teamUuid, 1000 * 600);
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
'roomID' =>$team_uuid, 'roomID' =>$teamUuid,
'data' =>$user_db 'data' =>$user_db
)); ));
} }
@ -229,12 +175,12 @@ class TeamController extends BaseAuthedController {
if (!isset($_REQUEST['team_uuid'])) { if (!isset($_REQUEST['team_uuid'])) {
return; return;
} }
$team_uuid = $_REQUEST['team_uuid']; $teamUuid = $_REQUEST['team_uuid'];
$r = $this->_getRedis($team_uuid); $r = $this->_getRedis($teamUuid);
if (!$r) { if (!$r) {
echo 'is null'; echo 'is null';
} else { } else {
$user_db_str = $r->get(TEAMID_KEY . $team_uuid); $user_db_str = $r->get(TEAMID_KEY . $teamUuid);
if (empty($user_db_str)) { if (empty($user_db_str)) {
phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); phpcommon\sendError(ERR_USER_BASE + 1,'session失效1');
return; return;
@ -260,8 +206,8 @@ class TeamController extends BaseAuthedController {
$i++; $i++;
} }
$r->set(TEAMID_KEY . $team_uuid, json_encode($user_db)); $r->set(TEAMID_KEY . $teamUuid, json_encode($user_db));
$r -> pexpire(TEAMID_KEY . $team_uuid, 1000 * 600); $r -> pexpire(TEAMID_KEY . $teamUuid, 1000 * 600);
} }
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
@ -274,14 +220,14 @@ class TeamController extends BaseAuthedController {
if (!isset($_REQUEST['team_uuid'])) { if (!isset($_REQUEST['team_uuid'])) {
return; return;
} }
$team_uuid = $_REQUEST['team_uuid']; $teamUuid = $_REQUEST['team_uuid'];
$r = $this->_getRedis($team_uuid); $r = $this->_getRedis($teamUuid);
$roomManager = $_REQUEST['roomManager']; $roomManager = $_REQUEST['roomManager'];
if (!$r) { if (!$r) {
echo 'is null'; echo 'is null';
} else { } else {
$user_db_str = $r->get(TEAMID_KEY . $team_uuid); $user_db_str = $r->get(TEAMID_KEY . $teamUuid);
if (empty($user_db_str)) { if (empty($user_db_str)) {
phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); phpcommon\sendError(ERR_USER_BASE + 1,'session失效1');
return; return;
@ -314,10 +260,10 @@ class TeamController extends BaseAuthedController {
} }
$i++; $i++;
} }
$r->set(TEAMID_KEY . $team_uuid, json_encode($user_db)); $r->set(TEAMID_KEY . $teamUuid, json_encode($user_db));
$r -> pexpire(TEAMID_KEY . $team_uuid, 1000 * 600); $r -> pexpire(TEAMID_KEY . $teamUuid, 1000 * 600);
if (count($user_db['member_list']) == 0) { if (count($user_db['member_list']) == 0) {
$r->del(TEAMID_KEY . $team_uuid, json_encode($user_db)); $r->del(TEAMID_KEY . $teamUuid, json_encode($user_db));
} }
} }
echo json_encode(array( echo json_encode(array(
@ -331,13 +277,13 @@ class TeamController extends BaseAuthedController {
if (!isset($_REQUEST['team_uuid'])) { if (!isset($_REQUEST['team_uuid'])) {
return; return;
} }
$team_uuid = $_REQUEST['team_uuid']; $teamUuid = $_REQUEST['team_uuid'];
$r = $this->_getRedis($team_uuid); $r = $this->_getRedis($teamUuid);
if (!$r){ if (!$r){
echo 'is null'; echo 'is null';
} else { } else {
$user_db_str = $r->get(TEAMID_KEY . $team_uuid); $user_db_str = $r->get(TEAMID_KEY . $teamUuid);
if (empty($user_db_str)) { if (empty($user_db_str)) {
phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); phpcommon\sendError(ERR_USER_BASE + 1,'session失效1');
@ -358,8 +304,8 @@ class TeamController extends BaseAuthedController {
} }
$user_db['auto_fill'] = $_REQUEST['auto_fill']; $user_db['auto_fill'] = $_REQUEST['auto_fill'];
$user_db['map_id'] = $_REQUEST['map_id']; $user_db['map_id'] = $_REQUEST['map_id'];
$r->set(TEAMID_KEY . $team_uuid, json_encode($user_db)); $r->set(TEAMID_KEY . $teamUuid, json_encode($user_db));
$r -> pexpire(TEAMID_KEY . $team_uuid, 1000 * 600); $r -> pexpire(TEAMID_KEY . $teamUuid, 1000 * 600);
} }
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
@ -372,14 +318,14 @@ class TeamController extends BaseAuthedController {
if (!isset($_REQUEST['team_uuid'])) { if (!isset($_REQUEST['team_uuid'])) {
return; return;
} }
$team_uuid = $_REQUEST['team_uuid']; $teamUuid = $_REQUEST['team_uuid'];
//error_log("剔除玩家==="); //error_log("剔除玩家===");
$r = $this->_getRedis($team_uuid); $r = $this->_getRedis($teamUuid);
if (!$r) { if (!$r) {
echo 'is null'; echo 'is null';
} else { } else {
$user_db_str = $r->get(TEAMID_KEY . $team_uuid); $user_db_str = $r->get(TEAMID_KEY . $teamUuid);
if (empty($user_db_str)) { if (empty($user_db_str)) {
phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); phpcommon\sendError(ERR_USER_BASE + 1,'session失效1');
@ -399,8 +345,8 @@ class TeamController extends BaseAuthedController {
} }
} }
$user_db['state'] = $_REQUEST['state']; $user_db['state'] = $_REQUEST['state'];
$r->set(TEAMID_KEY . $team_uuid, json_encode($user_db)); $r->set(TEAMID_KEY . $teamUuid, json_encode($user_db));
$r->pexpire(TEAMID_KEY . $team_uuid, 10 * 1000); $r->pexpire(TEAMID_KEY . $teamUuid, 10 * 1000);
} }
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,

View File

@ -19,7 +19,7 @@ class SeasonCard {
public static function calcCost($currMeta, $newMeta) public static function calcCost($currMeta, $newMeta)
{ {
$cost = 0; $cost = 0;
$nextMeta = self::get($currMeta['lv']); $nextMeta = self::get($currMeta['lv'] + 1);
while ($nextMeta && $nextMeta['lv'] <= $newMeta['lv']) { while ($nextMeta && $nextMeta['lv'] <= $newMeta['lv']) {
$cost += $nextMeta['cost']; $cost += $nextMeta['cost'];
$nextMeta = self::get($nextMeta['lv'] + 1); $nextMeta = self::get($nextMeta['lv'] + 1);