diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index ff5498c..99103c5 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -12,51 +12,39 @@ class TeamController extends BaseAuthedController { $node_id = (int)$_REQUEST['node_id']; } $team_uuid = $node_id . '_' . md5($_REQUEST['account_id']) . phpcommon\getNowTime(); - - $cloth_id = 0; - $hair_id = 0; - $color_id = 0; - $hat_id = 0; $rank = 1; $equip_id = 0; - $model = false; - $vip_level = 0; - $kuang = 0; + $model = 0; + error_log("创建房间===".$team_uuid); + + $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['cloth_id'])) { - $cloth_id = $_REQUEST['cloth_id']; - } - if (isset($_REQUEST['hair_id'])) { - $hair_id = $_REQUEST['hair_id']; - } - if (isset($_REQUEST['color_id'])) { - $color_id = $_REQUEST['color_id']; - } - if (isset($_REQUEST['hat_id'])) { - $hat_id = $_REQUEST['hat_id']; - } + if (isset($_REQUEST['rank'])) { $rank = $_REQUEST['rank']; } - if (isset($_REQUEST['equip_id'])) { - $equip_id = $_REQUEST['equip_id']; - } + if (isset($_REQUEST['model'])) { $model = $_REQUEST['model']; } - if (isset($_REQUEST['vip_level'])) { - $vip_level = $_REQUEST['vip_level']; - } - if (isset($_REQUEST['kuang'])) { - $kuang = $_REQUEST['kuang']; + 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 accountid=:accountid;', @@ -66,7 +54,6 @@ class TeamController extends BaseAuthedController { $team_db = array( 'team_uuid' => $team_uuid, - 'auto_fill' => $_REQUEST['auto_fill'], 'state' => 0, 'model' => $model, 'map_id' => $map_id, @@ -75,26 +62,24 @@ class TeamController extends BaseAuthedController { 'idx' => 1, 'account_id' => $_REQUEST['account_id'], 'name' => $_REQUEST['name'], - 'avatar_url' => $_REQUEST['avatar_url'], - 'cloth_id' => $cloth_id, - 'hair_id' => $hair_id, - 'color_id' => $color_id, - 'hat_id' => $hat_id, 'rank' => $rank, - 'equip_id' => $equip_id, 'game_times' => $row['game_times'], 'win_times' => $row['win_times'], 'kills' => $row['kills'], 'create_time' => $row['create_time'], - 'vip_level' => $vip_level, - 'kuang' => $kuang, + 'roomManager' => $roomManager, + 'readyState' => $readyState, + 'hiID' => $hiID, + 'hiFrameID' => $hiFrameID, 'sex' => $sex, + 'selectHeroID' => $selectHeroID, + "selectHeroSkinID" => $selectHeroSkinID ) )); $r = $this->getRedis($team_uuid); $r -> set(TEAMID_KEY . $team_uuid, json_encode($team_db)); - $r -> pexpire(TEAMID_KEY . $team_uuid, 1000 * 600); + $r -> pexpire(TEAMID_KEY . $team_uuid, 1000*600); echo json_encode (array( 'errcode' => 0, @@ -130,19 +115,15 @@ class TeamController extends BaseAuthedController { 'idx' => $member['idx'], 'account_id' => $member['account_id'], 'name' => $member['name'], - 'avatar_url' => $member['avatar_url'], - 'cloth_id' => $member['cloth_id'], - 'hair_id' => $member['hair_id'], - 'color_id' => $member['color_id'], - 'hat_id' => $member['hat_id'], 'rank' => $member['rank'], - 'equip_id' => $member['equip_id'], 'game_times' => $member['game_times'], 'win_times' => $member['win_times'], 'kills' => $member['kills'], 'create_time' => $member['create_time'], - 'vip_level' => $member['vip_level'], - 'kuang' => $member['kuang'], + 'hiID' => $member['hiID'], + 'readyState' =>$member['readyState'], + 'hiFrameID' => $member['hiFrameID'], + 'roomManager' => $member['roomManager'], 'sex' => $member['sex'], )); } @@ -150,15 +131,145 @@ class TeamController extends BaseAuthedController { 'errcode' => 0, 'errmsg'=> '', 'team_uuid' => $team_uuid, - 'auto_fill' => $user_db['auto_fill'], 'state' => $user_db['state'], 'member_list' => $member_list, 'model' => $user_db['model'], 'map_id' => $user_db['map_id'], )); } + public function getSelectHeroTeamInfo() + { + if (!isset($_REQUEST['team_uuid'])) { + return; + } + $team_uuid = $_REQUEST['team_uuid']; + $r = $this->getRedis($team_uuid); + $accountid = $_REQUEST['account_id']; + $sessionid = $_REQUEST['session_id']; + $user_db_str = $r->get(TEAMID_KEY . $team_uuid); + if (empty($user_db_str)) { + phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); + return; + } + $user_db = json_decode($user_db_str, true); + if (empty($user_db)) { + phpcommon\sendError(ERR_USER_BASE + 1,'session失效2'); + return; + } + $member_list = array(); + foreach ($user_db['member_list'] as $member) { + array_push($member_list, array( + 'idx' => $member['idx'], + 'account_id' => $member['account_id'], + 'name' => $member['name'], + 'hiID' => $member['hiID'], + 'readyState' => $member['readyState'], + 'hiFrameID' => $member['hiFrameID'], + 'roomManager' => $member['roomManager'], + 'sex' => $member['sex'], + 'selectHeroID' => $member['selectHeroID'], + 'selectHeroSkinID' => $member['selectHeroSkinID'] + )); + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg'=> '', + 'team_uuid' => $team_uuid, + 'state' => $user_db['state'], + 'member_list' => $member_list, + 'model' => $user_db['model'], + 'map_id' => $user_db['map_id'], + )); + } + public function selectHero() + { + if (!isset($_REQUEST['team_uuid'])) { + return; + } + $team_uuid = $_REQUEST['team_uuid']; + + $r = $this->getRedis($team_uuid); + + $user_db_str = $r->get(TEAMID_KEY.$team_uuid); + if (empty($user_db_str)) { + phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); + return; + } + $user_db = json_decode($user_db_str, true); + if (empty($user_db)) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session失效2'); + return; + } + $type = $_REQUEST['type']; + $acctID = $_REQUEST['account_id']; + error_log("SelectHero".$type."==".$acctID); + foreach ($user_db['member_list'] as &$memberlist) + { + if($memberlist['account_id'] == $acctID) + { + if($type == 1) + { + $heroID = $_REQUEST['heroID']; + $heroSkinID = $_REQUEST['heroSkinID']; + $memberlist['selectHeroID'] = $heroID; + $memberlist['selectHeroSkinID'] = $heroSkinID; + } + else if($type == 2) + { + $readyState = $_REQUEST['readyState']; + $memberlist['readyState'] = $readyState; + } + break; + } + } + $r->set(TEAMID_KEY . $team_uuid, json_encode($user_db)); + $r -> pexpire(TEAMID_KEY . $team_uuid, 1000 * 600); + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '' + )); + } + public function readyGame() + { + if (!isset($_REQUEST['team_uuid'])) { + return; + } + $team_uuid = $_REQUEST['team_uuid']; + + $r = $this->getRedis($team_uuid); + + $user_db_str = $r->get(TEAMID_KEY.$team_uuid); + if (empty($user_db_str)) { + phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); + return; + } + $user_db = json_decode($user_db_str, true); + if (empty($user_db)) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session失效2'); + return; + } + $readyState = $_REQUEST['readyState']; + error_log("readyState=====".$readyState); + // $user_db['member_list'] = array_values($user_db['member_list']); + $acctID = $_REQUEST['account_id']; + foreach ($user_db['member_list'] as &$memberlist) + { + if($memberlist['account_id'] == $acctID) + { + $memberlist['readyState'] = $readyState; + break; + } + } + error_log("Data===".json_encode($user_db)); + $r->set(TEAMID_KEY . $team_uuid, json_encode($user_db)); + $r -> pexpire(TEAMID_KEY . $team_uuid, 1000 * 600); + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '' + )); + } public function joinTeam() { if (!isset($_REQUEST['team_uuid'])) { @@ -168,7 +279,6 @@ class TeamController extends BaseAuthedController { $r = $this->getRedis($team_uuid); - $user_db_str = $r->get(TEAMID_KEY.$team_uuid); if (empty($user_db_str)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); @@ -193,45 +303,29 @@ class TeamController extends BaseAuthedController { } } if ($flag == 1) { - phpcommon\sendError(ERR_USER_BASE + 3,'已在队伍中'); - return; + phpcommon\sendError(ERR_USER_BASE + 3,'已在队伍中'); + return; } - - $cloth_id = 0; - $hair_id = 0; - $color_id = 0; - $hat_id = 0; $rank = 1; - $equip_id = 0; - $vip_level = 0; $kuang = 0; $sex = 2; - if (isset($_REQUEST['cloth_id'])) { - $cloth_id = $_REQUEST['cloth_id']; - } - if (isset($_REQUEST['hair_id'])) { - $hair_id = $_REQUEST['hair_id']; - } - if (isset($_REQUEST['color_id'])) { - $color_id = $_REQUEST['color_id']; - } - if (isset($_REQUEST['hat_id'])) { - $hat_id = $_REQUEST['hat_id']; - } + $hiID = 0; + $hiFrameID = 0; + $roomManger = 0; + $readyState = 1; + $selectHeroID = 0; + $selectHeroSkinID = 0; if (isset($_REQUEST['rank'])) { $rank = $_REQUEST['rank']; } - if (isset($_REQUEST['equip_id'])) { - $equip_id = $_REQUEST['equip_id']; - } - if (isset($_REQUEST['vip_level'])) { - $vip_level = $_REQUEST['vip_level']; - } - if (isset($_REQUEST['kuang'])) { - $kuang = $_REQUEST['kuang']; - } if (isset($_REQUEST['sex'])) { $sex = $_REQUEST['sex']; + } + if (isset($_REQUEST['hiID'])) { + $hiID = $_REQUEST['hiID']; + } + if (isset($_REQUEST['hiFrameID'])) { + $hiFrameID = $_REQUEST['hiFrameID']; } $accountid = $_REQUEST['account_id']; $conn = $this->getMysql($accountid); @@ -243,66 +337,60 @@ class TeamController extends BaseAuthedController { 'idx' => $member_num + 1, 'account_id' => $_REQUEST['account_id'], 'name' => $_REQUEST['name'], - 'avatar_url' => $_REQUEST['avatar_url'], - 'cloth_id' => $cloth_id, - 'hair_id' => $hair_id, - 'color_id' => $color_id, - 'hat_id' => $hat_id, 'rank' => $rank, - 'equip_id' => $equip_id, 'game_times' => $row['game_times'], 'win_times' => $row['win_times'], 'kills' => $row['kills'], 'create_time' => $row['create_time'], - 'vip_level' => $vip_level, - 'kuang' => $kuang, + 'hiID' => $hiID, + 'hiFrameID' => $hiFrameID, + 'readyState' => $readyState, + 'roomManager' => $roomManger, 'sex' => $sex, + 'selectHeroID' => $selectHeroID, + "selectHeroSkinID" => $selectHeroSkinID )); - $r->set(TEAMID_KEY . $team_uuid, json_encode($user_db)); + $r->set(TEAMID_KEY . $team_uuid, json_encode($user_db)); $r -> pexpire(TEAMID_KEY . $team_uuid, 1000 * 600); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', + 'roomID' =>$team_uuid, + 'data' =>$user_db )); } public function kickoutMember() { + error_log("剔除玩家==06="); if (!isset($_REQUEST['team_uuid'])) { return; } $team_uuid = $_REQUEST['team_uuid']; + error_log("剔除玩家==="); $r = $this->getRedis($team_uuid); if (!$r) { echo 'is null'; } else { $user_db_str = $r->get(TEAMID_KEY . $team_uuid); if (empty($user_db_str)) { + error_log("剔除玩家==3="); phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); return; } $user_db = json_decode($user_db_str, true); if (empty($user_db)) { + error_log("剔除玩家==5="); phpcommon\sendError(ERR_USER_BASE + 1,'session失效2'); return; } $flag = 0; foreach ($user_db['member_list'] as $member) { - if ($member['account_id'] == $_REQUEST['account_id']) { - if ($member['idx'] != 1) { - phpcommon\sendError(ERR_USER_BASE + 4,'你不是队长'); - return; - } - foreach ($user_db['member_list'] as $member) { - if ($member['account_id'] == $_REQUEST['member_id']) { - $flag = $member['idx'] - 1; - break; - } - } + if ($member['account_id'] == $_REQUEST['member_id']) { + $flag = $member['idx'] - 1; break; } } - unset($user_db['member_list'][$flag]); $user_db['member_list'] = array_values($user_db['member_list']); @@ -328,12 +416,15 @@ class TeamController extends BaseAuthedController { } $team_uuid = $_REQUEST['team_uuid']; $r = $this->getRedis($team_uuid); + $roomManager = $_REQUEST['roomManager']; + error_log("是否是队长===".$roomManager); if (!$r) { echo 'is null'; } else { $user_db_str = $r->get(TEAMID_KEY . $team_uuid); if (empty($user_db_str)) { + error_log("剔除玩家===1"); phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); return; } @@ -355,9 +446,16 @@ class TeamController extends BaseAuthedController { $i = 1; foreach ($user_db['member_list'] as &$memberlist) { $memberlist['idx'] = $i; + if($roomManager == 1) + { + if($i == 1) + { + $memberlist['roomManager'] = 1; + $memberlist['readyState'] = 1; + } + } $i++; } - $r->set(TEAMID_KEY . $team_uuid, json_encode($user_db)); $r -> pexpire(TEAMID_KEY . $team_uuid, 1000 * 600); if (count($user_db['member_list']) == 0) { @@ -417,6 +515,7 @@ class TeamController extends BaseAuthedController { return; } $team_uuid = $_REQUEST['team_uuid']; + error_log("剔除玩家==="); $r = $this->getRedis($team_uuid); if (!$r) {