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):
def __init__(self):
self.apis_ = [
{
'desc': 'createTeam',
'group': 'Team',
'url': 'webapp/index.php?c=Team&a=createTeam',
'params': [
_common.ReqHead(),
['node_id', 0, '节点id'],
['map_id', 0, '地图id'],
],
'response': [
_common.RspHead(),
['team_info', _common.TeamInfo(), '队伍信息'],
]
},
{
'desc': 'teamInfo',
'group': 'Team',
'url': 'webapp/index.php?c=Team&a=teamInfo',
'params': [
_common.ReqHead(),
['team_uuid', '', '队伍唯一id'],
],
'response': [
_common.RspHead(),
['team_info', _common.TeamInfo(), '队伍信息'],
]
},
{
'desc': 'joinTeam',
'group': 'Team',
'url': 'webapp/index.php?c=Team&a=joinTeam',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
]
},
{
'desc': 'leaveTeam',
'group': 'Team',
'url': 'webapp/index.php?c=Team&a=leaveTeam',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
]
},
{
'desc': 'startGame',
'group': 'Team',
'url': 'webapp/index.php?c=Team&a=startGame',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
]
},
self.apis = [
{
'name': 'createTeam',
'desc': '创建队伍',
'group': 'Team',
'url': 'webapp/index.php?c=Team&a=createTeam',
'params': [
_common.ReqHead(),
['node_id', 0, '节点id'],
['map_id', 0, '地图id'],
],
'response': [
_common.RspHead(),
['team_uuid', '', '队伍唯一id'],
]
},
{
'name': 'teamInfo',
'desc': '获取队伍信息',
'group': 'Team',
'url': 'webapp/index.php?c=Team&a=teamInfo',
'params': [
_common.ReqHead(),
['team_uuid', '', '队伍唯一id'],
],
'response': [
_common.RspHead(),
['team_info', _common.TeamInfo(), '队伍信息'],
]
},
{
'name': 'joinTeam',
'desc': '加入队伍',
'group': 'Team',
'url': 'webapp/index.php?c=Team&a=joinTeam',
'params': [
_common.ReqHead(),
['team_uuid', '', '队伍唯一id'],
],
'response': [
_common.RspHead(),
['team_uuid', '', '队伍唯一id'],
]
},
{
'name': 'leaveTeam',
'desc': '离开队伍',
'group': 'Team',
'url': 'webapp/index.php?c=Team&a=leaveTeam',
'params': [
_common.ReqHead(),
['team_uuid', '', '队伍唯一id'],
],
'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_exp', 0, '手册经验'],
['card_max_exp', 0, '手册经验上限'],
['buy_level_price', 0, '等级价格(钻石)'],
['!gift_packages', [SeasonCardGiftPackage()], '礼包列表'],
['!received_level_rewards1', [0], '等级解锁的奖励已领取等级列表(普通手册)'],
['!received_level_rewards2', [0], '等级解锁的奖励已领取等级列表(精英)'],
@ -326,7 +327,6 @@ class TeamInfo(object):
def __init__(self):
self.fields = [
['team_uuid', '', '队伍唯一id'],
['map_id', 0, '地图id'],
['state', 0, '0:未开始 1:准备就绪(这时客户端进入长链接走组队逻辑)'],
['member_list', [TeamMember()], '队伍成员列表(包含自己)'],
['!member_list', [TeamMember()], '队伍成员列表(包含自己)'],
]

View File

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

View File

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

View File

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

View File

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