Commit 1f2831de authored by Nemo Ma's avatar Nemo Ma

Revert "Revert "feat: 完善前端接口""

This reverts commit e625568c.
parent e625568c
...@@ -395,6 +395,7 @@ ...@@ -395,6 +395,7 @@
); );
} }
echo (json_encode(array( echo (json_encode(array(
"page" => "game",
/** 玩家状态 */ /** 玩家状态 */
"playerState" => array( "playerState" => array(
/** 玩家信息 */ /** 玩家信息 */
...@@ -697,6 +698,13 @@ ...@@ -697,6 +698,13 @@
"radar" => $radarscreen, "radar" => $radarscreen,
/** 元素口袋 */ /** 元素口袋 */
"element" => $club == 20 ? getElement() : null, "element" => $club == 20 ? getElement() : null,
/** 死亡信息 */
"death" => $hp <= 0 ? array(
"title" => $stateinfo[$state],
"content" => $dinfo[$state],
"time" => $dtime,
"name" => (!empty($kname) && (in_array($state, Array(20, 21, 22, 23, 24, 28, 29)))) ? $kname : null,
) : null,
), ),
/** 搜寻状态 */ /** 搜寻状态 */
"searchState" => array( "searchState" => array(
......
...@@ -33,7 +33,14 @@ if($hp<=0 || $state>=10) { ...@@ -33,7 +33,14 @@ if($hp<=0 || $state>=10) {
} }
} }
include template('ending'); if ($udata['u_templateid'] == 1 && !strstr($_SERVER['HTTP_REFERER'], 'php') && $_SERVER['HTTP_REFERER'] != '') {
echo json_encode(array(
"page" => "end",
"title" => $stateinfo[$state],
));
} else {
include template('ending');
}
?> ?>
\ No newline at end of file
...@@ -16,7 +16,7 @@ if(isset($mode) && $mode == 'quit') { ...@@ -16,7 +16,7 @@ if(isset($mode) && $mode == 'quit') {
} }
//$result = $db->query("SELECT * FROM {$tablepre}players WHERE name = '$cuser' AND type = 0"); //$result = $db->query("SELECT * FROM {$tablepre}players WHERE name = '$cuser' AND type = 0");
$pdata = fetch_playerdata_by_name($cuser); $pdata = fetch_playerdata_by_name($cuser);
if(!$pdata) { header("Location: valid.php");exit(); } if(!$pdata) { header("Location: valid.php".'?'.$_SERVER['QUERY_STRING']);exit(); }
//$pdata = $db->fetch_array($result); //$pdata = $db->fetch_array($result);
if($pdata['pass'] != $cpass) { if($pdata['pass'] != $cpass) {
......
...@@ -30,8 +30,15 @@ function gameerrorhandler($code, $msg, $file, $line){ ...@@ -30,8 +30,15 @@ function gameerrorhandler($code, $msg, $file, $line){
function gexit($message = '',$file = '', $line = 0) { function gexit($message = '',$file = '', $line = 0) {
global $charset,$title,$extrahead,$allowcsscache,$errorinfo; global $charset,$title,$extrahead,$allowcsscache,$errorinfo;
global $gameversion,$cuser,$cpass; global $gameversion,$cuser,$cpass;
include template('error'); if ($_GET['is_new']) {
exit(); echo json_encode(array(
"error" => $message,
));
exit();
} else {
include template('error');
exit();
}
} }
function output($content = '') { function output($content = '') {
......
...@@ -57,7 +57,46 @@ if(!empty($roomact)) ...@@ -57,7 +57,46 @@ if(!empty($roomact))
} }
else else
{ {
include template('index'); if ($_GET['is_new']) {
echo json_encode(array(
// 当前回合数
"num" => $gamenum,
// 当前游戏状态
"state" => $gstate[$gamestate],
// 当前游戏时间
"timing" => $timing,
// 显示当前游戏时间
"showNowTime" => $gamestate > 10,
// 显示下局游戏时间
"showNextTime" => $starttime > $now,
// 最高伤害玩家
"maxDamagePlayer" => $hplayer,
// 最高伤害值
"maxDamage" => $hdamage,
// 上局结果
"lastResult" => $gwin[$winmode],
// 上局优胜者
"lastWinner" => $winner,
// 禁区
"areaHour" => $areahour,
"areaLimit" => $arealimit,
"areaAdd" => $areaadd,
"areaNum" => $areanum,
// 自动逃避禁区
"areaAutoHide" => $areaesc && $gamestate < 40,
// 人数
"validNum" => $validnum,
"aliveNum" => $alivenum,
"deathNum" => $deathnum,
// 当前房间号:
"roomID" => $groomid,
// 用户名
"username" => $cuser,
));
return;
} else {
include template('index');
}
} }
?> ?>
......
...@@ -284,7 +284,27 @@ if($mode == 'enter') { ...@@ -284,7 +284,27 @@ if($mode == 'enter') {
save_gameinfo(); save_gameinfo();
include template('validover'); if ($_GET['is_new']) {
echo json_encode(array(
"page" => "validOver",
"nick" => $nickinfo,
"name" => $cuser,
"sub" => $sexinfo[$gd].$sNo.'号',
"avatar" => $gd.'_'.$icon.'.gif',
"nowHp" => $hp,
"maxHp" => $mhp,
"nowMp" => $sp,
"maxMp" => $msp,
"attack" => $att,
"defense" => $def,
"gift" => $clubinfo[$club],
"weapon" => $wep,
"randomItem1" => $itm[3],
"randomItem2" => $itm[4],
));
} else {
include template('validover');
}
} elseif($mode == 'notice') { } elseif($mode == 'notice') {
//include template('notice'); //include template('notice');
header("Location: game.php"); header("Location: game.php");
...@@ -305,7 +325,44 @@ if($mode == 'enter') { ...@@ -305,7 +325,44 @@ if($mode == 'enter') {
$iconarray = get_iconlist($icon); $iconarray = get_iconlist($icon);
$utlist = get_utitlelist(); $utlist = get_utitlelist();
$select_icon = $icon; $select_icon = $icon;
include template('valid'); if ($_GET['is_new']) {
// 获取可选称号
$nickList = array_map(function($val) use ($titles_list) {
return array(
'id' => $val,
'title' => $titles_list[$val]
);
}, $nicksrev['nicks']);
// 获取可选普通内定称号
$normalGiftList = array_map(function($val) use ($clubinfo) {
return array(
'id' => $val,
'title' => $clubinfo[$val]
);
}, $t2_list);
// 获取可选特殊内定称号
$specialGiftList = array_map(function($val) use ($clubinfo) {
return array(
'id' => $val,
'title' => $clubinfo[$val]
);
}, $t1_list);
echo json_encode(array(
"page" => "valid",
"name" => $username, // 用户名
"avatar" => $select_icon, // 头像
"gender" => $gender, // 性别
"nick" => $udata['nick'], // 头衔
"nickList" => $nickList, // 可选头衔
"normalGiftList" => $normalGiftList, // 可选普通内定称号
"specialGiftList" => $specialGiftList, // 可选特殊内定称号
"motto" => $motto, // 口头禅
"killMessage" => $killmsg, // 杀人宣言
"lastWord" => $lastword, // 遗言
));
} else {
include template('valid');
}
} }
function makeclub() { function makeclub() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment