Commit 481e44fe authored by hisuinohoshi's avatar hisuinohoshi

Add revcombat.func.php,revbattle.htm,revbattleresult.htm

change:{command.php,item.func.php;game.func.php:init_battle();player_save()}
fix:{game.func.php:update_db_player_structure()}
提供了支持NPCvsNPC战斗的相关函数与页面……本来希望是能作为翻新的战斗函数也提供给玩家用的……但是暂时做不到!
在player_save()的流程中加入了键名过滤环节,现在有乱七八糟内容的玩家/NPC数据也能直接用player_save()存回数据库而不会爆炸了……希望不要有BUG。
parent 5fdd70c1
......@@ -98,7 +98,7 @@ if($hp > 0){
$mode = 'command';
}else{
//进入指令判断
if($mode !== 'combat' && $mode !== 'corpse' && strpos($action,'pacorpse')===false && $mode !== 'senditem'){
if($mode !== 'combat' && $mode !== 'revcombat' && $mode !== 'corpse' && strpos($action,'pacorpse')===false && $mode !== 'senditem'){
$action = '';
}
if($command == 'menu') {
......@@ -405,6 +405,24 @@ if($hp > 0){
} elseif($mode == 'combat') {
include_once GAME_ROOT.'./include/game/combat.func.php';
combat(1,$command);
} elseif($mode == 'revcombat'){
//NPC vs NPC:
if($command == 'enter' && (strpos($action,'corpse')===0 || strpos($action,'pacorpse')===0))
{
$cid = strpos($action,'corpse')===0 ? str_replace('corpse','',$action) : str_replace('pacorpse','',$action);
if($cid)
{
global $db,$tablepre;
$result = $db->query("SELECT * FROM {$tablepre}players WHERE pid='$cid' AND hp=0");
if($db->num_rows($result)>0)
{
$edata = $db->fetch_array($result);
extract($edata,EXTR_PREFIX_ALL,'w');
include_once GAME_ROOT.'./include/game/battle.func.php';
findcorpse($edata);
}
}
}
} elseif($mode == 'rest') {
include_once GAME_ROOT.'./include/state.func.php';
rest($command);
......
......@@ -7,6 +7,7 @@ if(!defined('IN_GAME')) {
//格式化储存player表 可能也是四面的遗产
function update_db_player_structure($type=0)
{
global $db,$tablepre,$checkstr;
$db_player_structure = $db_player_structure_types = $tpldata = Array();
$dps_need_update = 0;//判定是否需要更新玩家字段
......@@ -18,9 +19,9 @@ function update_db_player_structure($type=0)
if($dps_need_update){//如果要更新,直接新建一个表,不需要依赖已有的players表
$sql = file_get_contents($sql_file);
$sql = str_replace("\r", "\n", str_replace(' bra_', ' '.$gtablepre.'tmp_', $sql));
$sql = str_replace("\r", "\n", str_replace(' bra_', ' '.$tablepre.'tmp_', $sql));
$db->queries($sql);
$result = $db->query("DESCRIBE {$gtablepre}tmp_players");
$result = $db->query("DESCRIBE {$tablepre}tmp_players");
while ($sttdata = $db->fetch_array($result))
{
global ${$sttdata['Field']};
......@@ -38,6 +39,17 @@ function update_db_player_structure($type=0)
}
return $type ? $db_player_structure_types : $db_player_structure;
}
//返回一个只有数据库合法字段键名的pdata数组
function player_format_with_db_structure($data){
$ndata=Array();
$db_player_structure = update_db_player_structure();
foreach ($db_player_structure as $key){
if (isset($data[$key])) {
$ndata[$key]=$data[$key];
}
}
return $ndata;
}
//将sk转为数组格式 只会转换登记过的属性
function get_itmsk_array($sk_value)
{
......@@ -269,6 +281,7 @@ function init_profile(){
function init_battle($ismeet = 0){
global $wep,$wepk;
global $w_type,$w_name,$w_gd,$w_sNo,$w_icon,$w_lvl,$w_rage,$w_hp,$w_sp,$w_mhp,$w_msp,$w_wep,$w_wepk,$w_wepe,$w_sNoinfo,$w_iconImg,$w_hpstate,$w_spstate,$w_ragestate,$w_wepestate,$w_isdead,$hpinfo,$spinfo,$rageinfo,$wepeinfo,$fog,$typeinfo,$sexinfo,$infinfo,$w_exp,$w_upexp,$baseexp,$w_pose,$w_tactic,$w_inf,$w_infdata;
global $n_type,$n_name,$n_gd,$n_sNo,$n_icon,$n_hp,$n_mhp,$n_sp,$n_msp,$n_rage,$n_wep,$n_wepk,$n_wepe,$n_lvl,$n_pose,$n_tactic,$n_inf;
$w_upexp = round(($w_lvl*$baseexp)+(($w_lvl+1)*$baseexp));
if (CURSCRIPT == 'botservice')
......@@ -284,7 +297,6 @@ function init_battle($ismeet = 0){
$w_ragestate = "<span class=\"red\">$rageinfo[3]</span>";
$w_isdead = true;
if (CURSCRIPT == 'botservice') echo "w_dead=1\n";
} else{
if($w_hp < $w_mhp*0.2) {
$w_hpstate = "<span class=\"red\">$hpinfo[2]</span>";
......@@ -311,6 +323,38 @@ function init_battle($ismeet = 0){
$w_ragestate = "$rageinfo[0]";
}
}
if($n_hp <= 0)
{
global $n_hpstate,$n_spstate,$n_ragestate,$n_isdead;
$n_hpstate = "<span class=\"red\">$hpinfo[3]</span>";
$n_spstate = "<span class=\"red\">$spinfo[3]</span>";
$n_ragestate = "<span class=\"red\">$rageinfo[3]</span>";
$n_isdead = true;
} elseif(isset($n_hp)) {
global $n_hpstate,$n_spstate,$n_ragestate;
if($n_hp < $n_mhp*0.2) {
$n_hpstate = "<span class=\"red\">$hpinfo[2]</span>";
} elseif($n_hp < $n_mhp*0.5) {
$n_hpstate = "<span class=\"yellow\">$hpinfo[1]</span>";
} else {
$n_hpstate = "<span class=\"clan\">$hpinfo[0]</span>";
}
if($n_sp < $n_msp*0.2) {
$n_spstate = "$spinfo[2]";
} elseif($n_sp < $n_msp*0.5) {
$n_spstate = "$spinfo[1]";
} else {
$n_spstate = "$spinfo[0]";
}
if($n_rage >= 100) {
$n_ragestate = "<span class=\"red\">$rageinfo[2]</span>";
} elseif($n_rage >= 30) {
$n_ragestate = "<span class=\"yellow\">$rageinfo[1]</span>";
} else {
$n_ragestate = "$rageinfo[0]";
}
}
if($w_wepe >= 400) {
$w_wepestate = "$wepeinfo[3]";
......@@ -331,6 +375,14 @@ function init_battle($ismeet = 0){
global $wep_words,$wepk_words,$w_wep_words,$w_wepk_words;
$wep_words = parse_itm_desc($wep,'m'); $w_wep_words = parse_itm_desc($w_wep,'m');
$wepk_words = parse_itm_desc($wepk,'k'); $w_wepk_words = parse_itm_desc($w_wepk,'k');
//初始化第三方信息 如果有的话
if(isset($n_type))
{
global $n_wep_words,$n_wepk_words,$n_iconImg;
$n_iconImg = $n_type ? 'n_'.$n_icon.'.gif' : $n_gd.'_'.$n_icon.'.gif';
$n_wep_words = parse_itm_desc($n_wep,'m');
$n_wepk_words = parse_itm_desc($n_wepk,'k');
}
$w_sNoinfo = "$typeinfo[$w_type]({$sexinfo[$w_gd]}{$w_sNo}号)";
$w_i = $w_type > 0 ? 'n' : $w_gd;
$w_iconImg = $w_i.'_'.$w_icon.'.gif';
......@@ -423,8 +475,9 @@ function player_save($data){
global $db,$tablepre;
if(isset($data['pid'])){
$pid = $data['pid'];
unset($data['pid']);
$db->array_update("{$tablepre}players",$data,"pid='$pid'");
$ndata = player_format_with_db_structure($data);
unset($data);
$db->array_update("{$tablepre}players",$ndata,"pid='$pid'");
}
return;
}
......
......@@ -1788,6 +1788,14 @@ function itemuse($itmn) {
$itm = $itmk = $itmsk = '';
$itme = $itms = 0;
//-----------------------//
} elseif ($itm == '电子蛐蛐测试装置') {
//这是一个测试用道具 设置好$nid(先手者pid)和$eid(挨打者pid)后可以看这两个人打架 把其中一个设置成自己的pid就可以亲自下场 //自己下场现在有BUG
//$nid:先手攻击者的pid;$eid:挨打者的pid
//如果$nid打死了$eid的话,尸体会由你来摸,这不是BUG,是一个暂时缺少条件判断的特性。
$nid = 1; $eid = 15;
include_once GAME_ROOT.'./include/game/revcombat.func.php';
rev_combat_prepare($nid,$eid);
return;
} elseif ($itm == '提示纸条A') {
$log .= '你读着纸条上的内容:<br>“执行官其实都是幻影,那个红暮的身上应该有召唤幻影的玩意。”<br>“用那个东西然后打倒幻影的话能用游戏解除钥匙出去吧。”<br>';
} elseif ($itm == '提示纸条B') {
......
This diff is collapsed.
This diff is collapsed.
<input type="hidden" name="mode" value="revcombat">
<input type="hidden" name="command" value="enter">
<input type="button" class="cmdbutton" name="submit" value="确定" onclick="postCmd('gamecmd','command.php');this.disabled=true;">
\ No newline at end of file
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