Tokiwa Battle Royale  GE777
A PHP Battle Royale inspired game
 All Data Structures Namespaces Files Functions Variables Pages
game.php
Go to the documentation of this file.
1 <?php
2 
3 define('CURSCRIPT', 'game');
4 require './include/common.inc.php';
5 require GAME_ROOT.'./include/game.func.php';
6 
7 if(!$cuser||!$cpass) { gexit($_ERROR['no_login'],__file__,__line__); }
8 if($mode == 'quit') {
9 
10  gsetcookie('user','');
11  gsetcookie('pass','');
12  header("Location: index.php");
13  exit();
14 
15 }
16 $result = $db->query("SELECT * FROM {$tablepre}players WHERE name = '$cuser' AND type = 0");
17 if(!$db->num_rows($result)) { header("Location: valid.php");exit(); }
18 
19 $pdata = $db->fetch_array($result);
20 if($pdata['pass'] != $cpass) {
21  $tr = $db->query("SELECT `password` FROM {$tablepre}users WHERE username='$cuser'");
22  $tp = $db->fetch_array($tr);
23  $password = $tp['password'];
24  if($password == $cpass) {
25  $db->query("UPDATE {$tablepre}players SET pass='$password' WHERE name='$cuser'");
26  } else {
27  gexit($_ERROR['wrong_pw'],__file__,__line__);
28  }
29 }
30 
31 
32 
33 if($gamestate == 0) {
34  header("Location: end.php");exit();
35 }
36 
37 extract($pdata);
39 init_profile();
40 
41 $log = '';
42 //读取聊天信息
43 $chatdata = getchat(0,$teamID);
44 
45 //读取玩家互动信息
46 $result = $db->query("SELECT lid,time,log FROM {$tablepre}log WHERE toid = '$pid' AND prcsd = 0 ORDER BY time,lid");
47 $llist = '';
48 while($logtemp = $db->fetch_array($result)){
49  $log .= date("H:i:s",$logtemp['time']).','.$logtemp['log'].'<br />';
50  $llist .= $logtemp['lid'].',';
51 }
52 if(!empty($llist)){
53  $llist = '('.substr($llist,0,-1).')';
54  $db->query("UPDATE {$tablepre}log SET prcsd=1 WHERE toid = '$pid' AND lid IN $llist");
55 }
56 if($hp > 0){//判断冷却时间是否过去
57  //显示枪声信息
58  if(($now <= $noisetime+$noiselimit)&&$noisemode&&($noiseid!=$pid)&&($noiseid2!=$pid)) {
59  if(($now-$noisetime) < 60) {
60  $noisesec = $now - $noisetime;
61  $log .= "<span class=\"yellow b\">{$noisesec}秒前,{$plsinfo[$noisepls]}传来了{$noiseinfo[$noisemode]}。</span><br>";
62  } else {
63  $noisemin = floor(($now-$noisetime)/60);
64  $log .= "<span class=\"yellow b\">{$noisemin}分钟前,{$plsinfo[$noisepls]}传来了{$noiseinfo[$noisemode]}。</span><br>";
65  }
66  }
67  if($coldtimeon){
68  $cdover = $cdsec*1000 + $cdmsec + $cdtime;
69  $nowmtime = floor(getmicrotime()*1000);
70  $rmcdtime = $nowmtime >= $cdover ? 0 : $cdover - $nowmtime;
71  }
72 }
73 //var_dump($itm3);
74 if($hp <= 0){
75  $dtime = date("Y年m月d日H时i分s秒",$endtime);
76  $kname='';
77  if($bid) {
78  $result = $db->query("SELECT name FROM {$tablepre}players WHERE pid='$bid'");
79  if($db->num_rows($result)) { $kname = $db->result($result,0); }
80  }
81  $mode = 'death';
82 } elseif($state ==1 || $state == 2 || $state == 3){
83  $mode = 'rest';
84 } elseif($itms0){
85  $mode = 'itemmain';
86 } else {
87  $mode = 'command';
88 }
89 
90 $cmd = $main = '';
91 if((strpos($action,'corpse')===0 || strpos($action,'pacorpse')===0) && $gamestate<40){
92  $cid = strpos($action,'corpse')===0 ? str_replace('corpse','',$action) : str_replace('pacorpse','',$action);
93  if($cid){
94  $result = $db->query("SELECT * FROM {$tablepre}players WHERE pid='$cid' AND hp=0");
95  if($db->num_rows($result)>0){
96  $edata = $db->fetch_array($result);
97  include_once GAME_ROOT.'./include/game/battle.func.php';
98  findcorpse($edata);
99  extract($edata,EXTR_PREFIX_ALL,'w');
100  init_battle(1);
101  $main = 'battle';
102  }
103  }
104 }
105 if($hp > 0 && $coldtimeon && $showcoldtimer && $rmcdtime){$log .= "行动冷却时间:<span id=\"timer\" class=\"yellow\">0.0</span>秒<script type=\"text/javascript\">demiSecTimerStarter($rmcdtime);</script><br>";}
106 
107 if ($club==0)
108 {
109  include_once GAME_ROOT.'./include/game/clubslct.func.php';
110  getclub($name,$c1,$c2,$c3);
111  $clubavl[0]=0; $clubavl[1]=$c1; $clubavl[2]=$c2; $clubavl[3]=$c3;
112 }
113 
114 include template('game');
115 
116 ?>
getclub($who, &$c1, &$c2, &$c3)
$noisetime
Definition: combatinfo.php:7
$noiseid2
Definition: combatinfo.php:10
findcorpse(&$w_pdata)
Definition: battle.func.php:80
$noiseid
Definition: combatinfo.php:9
$chatdata
Definition: game.php:43
getchat($last, $team='', $limit=0)
if(!$cuser||!$cpass) if($mode== 'quit') $result
Definition: game.php:16
$endtime
Definition: botservice.php:321
$noisemode
Definition: combatinfo.php:11
if(!$db->num_rows($result)) $pdata
Definition: game.php:19
if(PHP_VERSION< '4.3.0') $action
Definition: install.php:14
$db
Definition: clear.php:32
【生存者数:<?php echo $alivenum?> 人】< input type="button"value="显示全部幸存者"onClick="$('alivemode').value='all';$('gbmode').value='none';postCmd('alive','alive.php');"></p > if($gamblingon &&$gamestate >=20) elseif($gamblingon &&$gamestate<=10)
Definition: 1_alive.tpl.php:18
init_profile()
Definition: game.func.php:32
if(strpos($username,'Yoshiko')!==false) if(preg_match($iplimit, $onlineip)) $password
Definition: login.php:114
const GAME_ROOT
Definition: clear.php:6
$cmd
Definition: game.php:90
$noiselimit
Definition: system.php:38
$showcoldtimer
Definition: gamecfg_1.php:30
$coldtimeon
Definition: gamecfg_1.php:28
$main
Definition: command.php:457
$log
Definition: game.php:41
$now
Definition: clear.php:23
$_ERROR
getmicrotime()
$gamestate
Definition: gameinfo.php:4
gsetcookie($var, $value, $life=0, $prefix=1)
gexit($message= '', $file= '', $line=0)
Definition: global.func.php:30
init_battle($ismeet=0)
Definition: game.func.php:170
$cpass
Definition: common.inc.php:207
$llist
Definition: game.php:47
if(!defined('IN_GAME')) init_playerdata()
Definition: game.func.php:9