Commit 523809f3 authored by Nemo Ma's avatar Nemo Ma

FEAT:Support $itmpara in mapitem, shopitem and mixitem

parent 571cfd7f
2024年7月19日 $itmpara 字段实现记录
在2024年7月19日,游戏中的物品添加了新的字段$itmpara,该字段为一数组,可让物品有着数组中定义的键值的属性。
以下是对应此字段的实现记录:
1. 地图物品(mapitem_1.php)
- 修改了system.func.php文件中的地图物品生成代码,添加了对$itmpara字段的支持
- 更新了SQL查询,将$itmpara字段添加到地图物品的插入语句中
- 允许在mapitem_1.php文件中为每个物品定义$itmpara字段
2. 商店物品(shopitem_1.php)
- 修改了system.func.php文件中的商店物品生成代码,添加了对$itmpara字段的支持
- 更新了SQL查询,将$itmpara字段添加到商店物品的插入语句中
- 允许在shopitem_1.php文件中为每个物品定义$itmpara字段
3. 合成物品(mixitem_1.php)
- 修改了itemmix.func.php文件中的$itmpara0变量处理,确保正确处理$itmpara字段
- 更新了mixitem_1.php文件中的物品定义,为每个物品添加了$itmpara字段
- 由于mixitem_1.php文件较大,只更新了部分物品,其余物品将在后续更新中完成
注意事项:
- 所有新添加的物品都应该包含$itmpara字段,即使该字段为空
- $itmpara字段应该是一个JSON字符串,表示一个键值对数组
- 可以使用get_itmpara()、get_single_itmpara()、set_itmpara()和del_single_itmpara()函数来操作$itmpara字段
2024年7月19日 $itmpara 字段 JSON 处理实现记录
在2024年7月19日,游戏中的物品添加了新的字段$itmpara,该字段为一数组,可让物品有着数组中定义的键值的属性。
由于$itmpara可能包含JSON格式的数据,而JSON中的逗号会导致在使用逗号分隔的配置文件中出现问题,因此我们实现了一种特殊的处理方法来解决这个问题。
以下是对应此字段的实现记录:
1. 地图物品(mapitem_1.php)
- 修改了system.func.php文件中的地图物品生成代码,添加了对JSON对象中逗号的特殊处理
- 当检测到一行中包含JSON对象(以{开头,以}结尾)时,会先提取JSON内容,然后用占位符替换,再进行逗号分隔
- 分割后,如果itmpara字段是占位符,则替换回实际的JSON内容
2. 商店物品(shopitem_1.php)
- 修改了system.func.php文件中的商店物品生成代码,添加了对JSON对象中逗号的特殊处理
- 使用与地图物品相同的方法处理JSON对象中的逗号
3. 合成物品(mixitem_1.php)
- 由于mixitem_1.php文件中的$itmpara字段是直接在PHP数组中定义的,不需要特殊处理
注意事项:
- 这种方法不需要对JSON内容进行编码,保持了原始数据的可读性
- 不需要修改get_itmpara函数,因为JSON字符串会被原样传递
- 所有使用$itmpara的代码都不需要修改
示例:
1. 在mapitem_1.php或shopitem_1.php中定义带有JSON的$itmpara:
0,0,1,测试物品,WK,100,10,,{"DecreaseDamageRaw":100,"DecreaseDamagePercentage":10}
2. system.func.php会特殊处理这一行:
- 提取JSON内容:{"DecreaseDamageRaw":100,"DecreaseDamagePercentage":10}
- 替换为占位符:0,0,1,测试物品,WK,100,10,,JSON_PLACEHOLDER
- 分割字符串:[0, 0, 1, 测试物品, WK, 100, 10, , JSON_PLACEHOLDER]
- 检测到itmpara是占位符,替换回JSON内容
3. 最终,$itmpara会被正确设置为:{"DecreaseDamageRaw":100,"DecreaseDamagePercentage":10}
...@@ -9,7 +9,7 @@ include_once GAME_ROOT.'./include/game/itemmain.func.php'; ...@@ -9,7 +9,7 @@ include_once GAME_ROOT.'./include/game/itemmain.func.php';
$mix_type = Array('normal' => '通常','sync' => '同调', 'overlay' => '超量'); $mix_type = Array('normal' => '通常','sync' => '同调', 'overlay' => '超量');
// 合成功能 // 合成功能
function itemmix_rev($mlist, $itemselect=-1, &$data=NULL) function itemmix_rev($mlist, $itemselect=-1, &$data=NULL)
{ {
global $log,$mode,$cmd,$main,$itemcmd; global $log,$mode,$cmd,$main,$itemcmd;
if(!isset($data)) if(!isset($data))
...@@ -25,7 +25,7 @@ function itemmix_rev($mlist, $itemselect=-1, &$data=NULL) ...@@ -25,7 +25,7 @@ function itemmix_rev($mlist, $itemselect=-1, &$data=NULL)
$mix_res = itemmix_get_result($mlist,$data); $mix_res = itemmix_get_result($mlist,$data);
# 尝试进行合成操作时 合成操作计数+1 # 尝试进行合成操作时 合成操作计数+1
if(empty($clbpara['achvars']['immix'])) $clbpara['achvars']['immix'] = 1; if(empty($clbpara['achvars']['immix'])) $clbpara['achvars']['immix'] = 1;
$mixitemname = array(); $mixitemname = array();
foreach($mlist as $val) $mixitemname[] = ${'itm'.$val}; foreach($mlist as $val) $mixitemname[] = ${'itm'.$val};
$itmstr = implode(' ', $mixitemname); $itmstr = implode(' ', $mixitemname);
...@@ -127,7 +127,7 @@ function itemmix_place_check($mlist,&$data=NULL) ...@@ -127,7 +127,7 @@ function itemmix_place_check($mlist,&$data=NULL)
return false; return false;
} }
$main = 'itemmix_tips'; $main = 'itemmix_tips';
$mlist2 = array_unique($mlist); $mlist2 = array_unique($mlist);
if(count($mlist) != count($mlist2)) { if(count($mlist) != count($mlist2)) {
$log .= '相同道具不能进行合成!<br>'; $log .= '相同道具不能进行合成!<br>';
$mode = 'itemmix'; $itemcmd = 'itemmix'; $mode = 'itemmix'; $itemcmd = 'itemmix';
...@@ -166,7 +166,7 @@ function itemmix_recipe_check($mixitem) ...@@ -166,7 +166,7 @@ function itemmix_recipe_check($mixitem)
} }
} }
} }
return $res; return $res;
} }
//查看是否符合同调要求 //查看是否符合同调要求
...@@ -366,7 +366,12 @@ function itemmix_proc($mlist, $minfo, $itmstr, &$data=NULL) ...@@ -366,7 +366,12 @@ function itemmix_proc($mlist, $minfo, $itmstr, &$data=NULL)
else{ else{
$itmsk0 = ''; $itmsk0 = '';
} }
$itmpara0 = $minfo['result'][5]; // Handle itmpara field
if (isset($minfo['result'][5]))
$itmpara0 = $minfo['result'][5];
else{
$itmpara0 = '';
}
$uip['mixcls'] = !empty($minfo['class']) ? $minfo['class'] : ''; $uip['mixcls'] = !empty($minfo['class']) ? $minfo['class'] : '';
$uip['mixtp'] = $minfo['type']; $uip['mixtp'] = $minfo['type'];
//合成成功 //合成成功
...@@ -422,14 +427,14 @@ function itemmix_events(&$data=NULL) ...@@ -422,14 +427,14 @@ function itemmix_events(&$data=NULL)
'鲜红的生血','真-红色的发圈','『红石电路』','【烈焰红唇】','红宝石方块','红莲魔龙 ★8'); '鲜红的生血','真-红色的发圈','『红石电路』','【烈焰红唇】','红宝石方块','红莲魔龙 ★8');
$royal_rose_stuff = $slip_list[array_rand($slip_list)]; $royal_rose_stuff = $slip_list[array_rand($slip_list)];
$royal_rose = Array( $royal_rose = Array(
'class' => 'hidden', 'class' => 'hidden',
'stuff' => array('「皇家蔷薇」','龙虎旗帜',$royal_rose_stuff), 'stuff' => array('「皇家蔷薇」','龙虎旗帜',$royal_rose_stuff),
'result' => array('「猩红蔷薇」','WK',179310,'∞','BNnrfcV'), 'result' => array('「猩红蔷薇」','WK',179310,'∞','BNnrfcV'),
); );
$gamevars['random_mixlist']['royal_rose'] = $royal_rose; $gamevars['random_mixlist']['royal_rose'] = $royal_rose;
save_gameinfo(); save_gameinfo();
} }
else else
{ {
$royal_rose = $gamevars['random_mixlist']['royal_rose']; $royal_rose = $gamevars['random_mixlist']['royal_rose'];
$royal_rose_stuff = $royal_rose['stuff'][2]; $royal_rose_stuff = $royal_rose['stuff'][2];
...@@ -477,7 +482,8 @@ function itemmix_events(&$data=NULL) ...@@ -477,7 +482,8 @@ function itemmix_events(&$data=NULL)
if($itm0 == 'Untainted Glory'){ if($itm0 == 'Untainted Glory'){
$log .= "<span class='minirainbow'>一道强光闪过——<br> $log .= "<span class='minirainbow'>一道强光闪过——<br>
你背包中的物品一瞬间全部消失了!<br>这是获得无毁荣光的必要代价!</span><br>"; 你背包中的物品一瞬间全部消失了!<br>这是获得无毁荣光的必要代价!</span><br>";
$itm1 = $itmk1 = $itmsk1 = $itm2 = $itmk2 = $itmsk2 = $itm3 = $itmk3 = $itmsk3 = $itm4 = $itmk4 = $itmsk4 = $itm5 = $itmk5 = $itmsk5 = $itm6 = $itmk6 = $itmsk6 = $itmpara0= $itmpara1 =$itmpara2 =$itmpara3 =$itmpara4 =$itmpara5 = $itmpara6 =0;''; $itm1 = $itmk1 = $itmsk1 = $itm2 = $itmk2 = $itmsk2 = $itm3 = $itmk3 = $itmsk3 = $itm4 = $itmk4 = $itmsk4 = $itm5 = $itmk5 = $itmsk5 = $itm6 = $itmk6 = $itmsk6 = '';
$itmpara1 = $itmpara2 = $itmpara3 = $itmpara4 = $itmpara5 = $itmpara6 = '';
$itme1 = $itms1 = $itme2 = $itms2 = $itme3 = $itms3 = $itme4 = $itms4 = $itme5 = $itms5 = $itme6 = $itms6 = 0; $itme1 = $itms1 = $itme2 = $itms2 = $itme3 = $itms3 = $itme4 = $itms4 = $itme5 = $itms5 = $itme6 = $itms6 = 0;
} }
return; return;
......
...@@ -13,9 +13,9 @@ function rs_game($mode = 0) { ...@@ -13,9 +13,9 @@ function rs_game($mode = 0) {
//重设玩家互动信息、聊天记录、地图道具、地图陷阱、进行状况 //重设玩家互动信息、聊天记录、地图道具、地图陷阱、进行状况
$sql = file_get_contents("{$sqldir}reset.sql"); $sql = file_get_contents("{$sqldir}reset.sql");
$sql = str_replace("\r", "\n", str_replace(' bra_', ' '.$tablepre, $sql)); $sql = str_replace("\r", "\n", str_replace(' bra_', ' '.$tablepre, $sql));
$db->queries($sql); $db->queries($sql);
//重设游戏进行状况的时间 //重设游戏进行状况的时间
/*if($fp = fopen("{$dir}newsinfo.php", 'wb')) { /*if($fp = fopen("{$dir}newsinfo.php", 'wb')) {
global $checkstr; global $checkstr;
...@@ -24,7 +24,7 @@ function rs_game($mode = 0) { ...@@ -24,7 +24,7 @@ function rs_game($mode = 0) {
} else { } else {
gexit('Can not write to cache files, please check directory ./gamedata/ and ./gamedata/cache/ .', __file__, __line__); gexit('Can not write to cache files, please check directory ./gamedata/ and ./gamedata/cache/ .', __file__, __line__);
}*/ }*/
//清空战斗信息 //清空战斗信息
global $hdamage,$hplayer,$noisetime,$noisepls,$noiseid,$noiseid2,$noisemode,$starttime,$gamevars; global $hdamage,$hplayer,$noisetime,$noisepls,$noiseid,$noiseid2,$noisemode,$starttime,$gamevars;
$hdamage = 0; $hdamage = 0;
...@@ -35,7 +35,7 @@ function rs_game($mode = 0) { ...@@ -35,7 +35,7 @@ function rs_game($mode = 0) {
$noiseid2 = 0; $noiseid2 = 0;
$noisemode = ''; $noisemode = '';
save_combatinfo(); save_combatinfo();
//修改反挂机间隔 //修改反挂机间隔
$afktime = $starttime; $afktime = $starttime;
//重设连斗判断死亡数 //重设连斗判断死亡数
...@@ -43,7 +43,7 @@ function rs_game($mode = 0) { ...@@ -43,7 +43,7 @@ function rs_game($mode = 0) {
//重设游戏剧情开关 //重设游戏剧情开关
$gamevars = Array(); $gamevars = Array();
save_gameinfo(); save_gameinfo();
} }
if ($mode & 2) { if ($mode & 2) {
//echo " - 禁区初始化 - "; //echo " - 禁区初始化 - ";
...@@ -76,7 +76,7 @@ function rs_game($mode = 0) { ...@@ -76,7 +76,7 @@ function rs_game($mode = 0) {
//$typenum = sizeof($typeinfo); //$typenum = sizeof($typeinfo);
$plsnum = sizeof($plsinfo); $plsnum = sizeof($plsinfo);
$npcqry = ''; $npcqry = '';
//for($i = 1; $i < $typenum; $i++) { //for($i = 1; $i < $typenum; $i++) {
foreach ($npcinfo as $i => $npcs){ foreach ($npcinfo as $i => $npcs){
if(!empty($npcs)) { if(!empty($npcs)) {
...@@ -87,7 +87,7 @@ function rs_game($mode = 0) { ...@@ -87,7 +87,7 @@ function rs_game($mode = 0) {
$npc['type'] = $i; $npc['type'] = $i;
$npc['endtime'] = $now; $npc['endtime'] = $now;
$npc['sNo'] = $j; $npc['sNo'] = $j;
//if(($npc['mode'] == 1)&&($npc['num'] <= $npc['sub'])){ //if(($npc['mode'] == 1)&&($npc['num'] <= $npc['sub'])){
// $npc = array_merge($npc,$npc[$j]); // $npc = array_merge($npc,$npc[$j]);
//} elseif($npc['mode'] == 2) { //} elseif($npc['mode'] == 2) {
...@@ -96,8 +96,8 @@ function rs_game($mode = 0) { ...@@ -96,8 +96,8 @@ function rs_game($mode = 0) {
//} else { //} else {
// $npc = array_merge($npc,$npc[1]); // $npc = array_merge($npc,$npc[1]);
//} //}
$subnum = sizeof($npc['sub']); $subnum = sizeof($npc['sub']);
$sub = $j % $subnum; $sub = $j % $subnum;
$npc = array_merge($npc,$npc['sub'][$sub]); $npc = array_merge($npc,$npc['sub'][$sub]);
...@@ -116,7 +116,7 @@ function rs_game($mode = 0) { ...@@ -116,7 +116,7 @@ function rs_game($mode = 0) {
if(!empty($npc['club'])) changeclub($npc['club'],$npc); if(!empty($npc['club'])) changeclub($npc['club'],$npc);
# NPC自定义技能初始化 # NPC自定义技能初始化
if(!empty($npc['clubskill']) || !empty($npc['clubskillpara'])) customtclubskill($npc); if(!empty($npc['clubskill']) || !empty($npc['clubskillpara'])) customtclubskill($npc);
# 初始化NPC所在位置 # 初始化NPC所在位置
global $hidding_typelist,$deepzones; global $hidding_typelist,$deepzones;
...@@ -130,13 +130,13 @@ function rs_game($mode = 0) { ...@@ -130,13 +130,13 @@ function rs_game($mode = 0) {
$rpls=rand(1,$plsnum-1); $rpls=rand(1,$plsnum-1);
}while (in_array($rpls,$deepzones)); }while (in_array($rpls,$deepzones));
} }
else else
{ {
do{$rpls=rand(1,$plsnum-1);}while ($rpls==34); do{$rpls=rand(1,$plsnum-1);}while ($rpls==34);
} }
if($npc['pls'] == 99) if($npc['pls'] == 99)
{ {
$npc['pls'] = $rpls; $npc['pls'] = $rpls;
} }
$npc['state'] = 0; $npc['state'] = 0;
...@@ -156,7 +156,7 @@ function rs_game($mode = 0) { ...@@ -156,7 +156,7 @@ function rs_game($mode = 0) {
} }
if ($mode & 16) { if ($mode & 16) {
//echo " - 地图道具/陷阱初始化 - "; //echo " - 地图道具/陷阱初始化 - ";
//2024-07-19 No itmpara is intended to initially spawn in the map, thus this is unchanged for now - will change if a need arises. //2024-07-19 Added itmpara support for map items
//感谢 Martin1994 提供地图道具数据库化的源代码 //感谢 Martin1994 提供地图道具数据库化的源代码
$plsnum = sizeof($plsinfo); $plsnum = sizeof($plsinfo);
$iqry = $tqry = ''; $iqry = $tqry = '';
...@@ -175,52 +175,80 @@ function rs_game($mode = 0) { ...@@ -175,52 +175,80 @@ function rs_game($mode = 0) {
//$mapitem = array(); //$mapitem = array();
//$ifqry = $iqry = 'INSERT INTO '.$tablepre.'mapitem (itm,itmk,itme,itms,itmsk,map) VALUES '; //$ifqry = $iqry = 'INSERT INTO '.$tablepre.'mapitem (itm,itmk,itme,itms,itmsk,map) VALUES ';
for($i = 1; $i < $in; $i++) { for($i = 1; $i < $in; $i++) {
if(!empty($itemlist[$i]) && strpos($itemlist[$i],',')!==false){ if(!empty($itemlist[$i])){
list($iarea,$imap,$inum,$iname,$ikind,$ieff,$ista,$iskind) = explode(',',$itemlist[$i]); // 特殊处理JSON对象中的逗号
$line = $itemlist[$i];
$json_start = strpos($line, '{');
$json_end = strrpos($line, '}');
$json_content = '';
// 如果存在JSON对象
if($json_start !== false && $json_end !== false && $json_end > $json_start) {
// 提取JSON内容
$json_content = substr($line, $json_start, $json_end - $json_start + 1);
// 替换JSON内容为占位符
$line = substr($line, 0, $json_start) . 'JSON_PLACEHOLDER';
}
// 分割字符串
$item_parts = explode(',', $line);
// 检查是否有itmpara字段
$itmpara = '';
if(count($item_parts) >= 9) {
$itmpara = $item_parts[8];
// 如果itmpara是JSON占位符,则替换回实际的JSON内容
if($itmpara === 'JSON_PLACEHOLDER') {
$itmpara = $json_content;
}
}
list($iarea,$imap,$inum,$iname,$ikind,$ieff,$ista,$iskind) = array_slice($item_parts, 0, 8);
if(($iarea == $an)||($iarea == 99)) { if(($iarea == $an)||($iarea == 99)) {
for($j = $inum; $j>0; $j--) { for($j = $inum; $j>0; $j--) {
if($imap == 99) { if($imap == 99) {
$rmap = rand(1,$plsnum-1); $rmap = rand(1,$plsnum-1);
while ($rmap==34){$rmap = rand(1,$plsnum-1);} while ($rmap==34){$rmap = rand(1,$plsnum-1);}
if(strpos($ikind ,'TO')===0){ if(strpos($ikind ,'TO')===0){
$tqry .= "('$iname', '$ikind','$ieff','$ista','$iskind','$rmap'),"; $tqry .= "('$iname', '$ikind','$ieff','$ista','$iskind','$rmap','$itmpara'),";
}else{ }else{
$iqry .= "('$iname', '$ikind','$ieff','$ista','$iskind','$rmap'),"; $iqry .= "('$iname', '$ikind','$ieff','$ista','$iskind','$rmap','$itmpara'),";
} }
//$iqry[$rmap] .= "('$iname', '$ikind','$ieff','$ista','$iskind'),"; //$iqry[$rmap] .= "('$iname', '$ikind','$ieff','$ista','$iskind'),";
//$db->query("INSERT INTO {$tablepre}{$rmap}mapitem (itm,itmk,itme,itms,itmsk) VALUES ('$iname', '$ikind','$ieff','$ista','$iskind')"); //$db->query("INSERT INTO {$tablepre}{$rmap}mapitem (itm,itmk,itme,itms,itmsk) VALUES ('$iname', '$ikind','$ieff','$ista','$iskind')");
}else{ }else{
if(strpos($ikind ,'TO')===0){ if(strpos($ikind ,'TO')===0){
$tqry .= "('$iname', '$ikind','$ieff','$ista','$iskind','$imap'),"; $tqry .= "('$iname', '$ikind','$ieff','$ista','$iskind','$imap','$itmpara'),";
}else{ }else{
$iqry .= "('$iname', '$ikind','$ieff','$ista','$iskind','$imap'),"; $iqry .= "('$iname', '$ikind','$ieff','$ista','$iskind','$imap','$itmpara'),";
} }
//$db->query("INSERT INTO {$tablepre}{$imap}mapitem (itm,itmk,itme,itms,itmsk) VALUES ('$iname', '$ikind','$ieff','$ista','$iskind')"); //$db->query("INSERT INTO {$tablepre}{$imap}mapitem (itm,itmk,itme,itms,itmsk) VALUES ('$iname', '$ikind','$ieff','$ista','$iskind')");
} }
//if($imap == 99) { //if($imap == 99) {
// $imap = rand(1,$plsnum-1); // $imap = rand(1,$plsnum-1);
//$mapitem[$rmap] .= "$iname,$ikind,$ieff,$ista,$iskind,\n"; //$mapitem[$rmap] .= "$iname,$ikind,$ieff,$ista,$iskind,\n";
//} else { //} else {
//$mapitem[$imap] .= "$iname,$ikind,$ieff,$ista,$iskind,\n"; //$mapitem[$imap] .= "$iname,$ikind,$ieff,$ista,$iskind,\n";
//} //}
} }
} }
} }
} }
if(!empty($iqry)){ if(!empty($iqry)){
$iqry = "INSERT INTO {$tablepre}mapitem (itm,itmk,itme,itms,itmsk,pls) VALUES ".substr($iqry, 0, -1); $iqry = "INSERT INTO {$tablepre}mapitem (itm,itmk,itme,itms,itmsk,pls,itmpara) VALUES ".substr($iqry, 0, -1);
$db->query($iqry); $db->query($iqry);
} }
if(!empty($tqry)){ if(!empty($tqry)){
$tqry = "INSERT INTO {$tablepre}maptrap (itm,itmk,itme,itms,itmsk,pls) VALUES ".substr($tqry, 0, -1); $tqry = "INSERT INTO {$tablepre}maptrap (itm,itmk,itme,itms,itmsk,pls,itmpara) VALUES ".substr($tqry, 0, -1);
$db->query($tqry); $db->query($tqry);
} }
// for($imap = 0;$imap<$plsnum;$imap++){ // for($imap = 0;$imap<$plsnum;$imap++){
// if(!empty($iqry[$imap])){ // if(!empty($iqry[$imap])){
// $iqry[$imap] = "INSERT INTO {$tablepre}{$imap}mapitem (itm,itmk,itme,itms,itmsk) VALUES ".substr($iqry[$imap], 0, -1); // $iqry[$imap] = "INSERT INTO {$tablepre}{$imap}mapitem (itm,itmk,itme,itms,itmsk) VALUES ".substr($iqry[$imap], 0, -1);
// $db->query($iqry[$imap]); // $db->query($iqry[$imap]);
// } // }
// } // }
// if($ifqry != $iqry){//判定是否有数据写入 // if($ifqry != $iqry){//判定是否有数据写入
// $iqry = substr($iqry, 0, -1);//去除尾部多余的逗号 // $iqry = substr($iqry, 0, -1);//去除尾部多余的逗号
...@@ -230,7 +258,7 @@ function rs_game($mode = 0) { ...@@ -230,7 +258,7 @@ function rs_game($mode = 0) {
// $mapfile = GAME_ROOT."./gamedata/mapitem/{$map}mapitem.php"; // $mapfile = GAME_ROOT."./gamedata/mapitem/{$map}mapitem.php";
// writeover($mapfile,$itemdata,'ab'); // writeover($mapfile,$itemdata,'ab');
// } // }
unset($itemlist);unset($iqry); unset($itemlist);unset($iqry);
//unset($mapitem); //unset($mapitem);
//挤一挤 仓库道具初始化 //挤一挤 仓库道具初始化
...@@ -251,30 +279,55 @@ function rs_game($mode = 0) { ...@@ -251,30 +279,55 @@ function rs_game($mode = 0) {
} }
if ($mode & 32) { if ($mode & 32) {
//echo " - 商店初始化 - "; //echo " - 商店初始化 - ";
//2024-07-19 No itmpara is intended to initially spawn in the shop, thus this is unchanged for now - will change if a need arises. //2024-07-19 Added itmpara support for shop items
$sql = file_get_contents("{$sqldir}shopitem.sql"); $sql = file_get_contents("{$sqldir}shopitem.sql");
$sql = str_replace("\r", "\n", str_replace(' bra_', ' '.$tablepre, $sql)); $sql = str_replace("\r", "\n", str_replace(' bra_', ' '.$tablepre, $sql));
$db->queries($sql); $db->queries($sql);
//runquery($sql); //runquery($sql);
$file = config('shopitem',$gamecfg); $file = config('shopitem',$gamecfg);
$shoplist = openfile($file); $shoplist = openfile($file);
$qry = ''; $qry = '';
foreach($shoplist as $lst){ foreach($shoplist as $lst){
if(!empty($lst) && strpos($lst,',')!==false){ if(!empty($lst)){
$lst = explode(',',$lst); // 特殊处理JSON对象中的逗号
$line = $lst;
$json_start = strpos($line, '{');
$json_end = strrpos($line, '}');
$json_content = '';
// 如果存在JSON对象
if($json_start !== false && $json_end !== false && $json_end > $json_start) {
// 提取JSON内容
$json_content = substr($line, $json_start, $json_end - $json_start + 1);
// 替换JSON内容为占位符
$line = substr($line, 0, $json_start) . 'JSON_PLACEHOLDER';
}
// 分割字符串
$lst = explode(',', $line);
// 检查是否有itmpara字段
$itmpara = '';
if(count($lst) >= 10) {
$itmpara = $lst[9];
// 如果itmpara是JSON占位符,则替换回实际的JSON内容
if($itmpara === 'JSON_PLACEHOLDER') {
$itmpara = $json_content;
}
}
if(empty($lst[8])) $lst[8] = ''; if(empty($lst[8])) $lst[8] = '';
list($kind,$num,$price,$area,$item,$itmk,$itme,$itms,$itmsk)=$lst; list($kind,$num,$price,$area,$item,$itmk,$itme,$itms,$itmsk)=$lst;
if($kind != 0){ if($kind != 0){
$qry .= "('$kind','$num','$price','$area','$item','$itmk','$itme','$itms','$itmsk'),"; $qry .= "('$kind','$num','$price','$area','$item','$itmk','$itme','$itms','$itmsk','$itmpara'),";
} }
} }
} }
if(!empty($qry)){ if(!empty($qry)){
$qry = "INSERT INTO {$tablepre}shopitem (kind,num,price,area,item,itmk,itme,itms,itmsk) VALUES ".substr($qry, 0, -1); $qry = "INSERT INTO {$tablepre}shopitem (kind,num,price,area,item,itmk,itme,itms,itmsk,itmpara) VALUES ".substr($qry, 0, -1);
} }
$db->query($qry); $db->query($qry);
} }
} }
...@@ -285,7 +338,7 @@ function rs_sttime() { ...@@ -285,7 +338,7 @@ function rs_sttime() {
list($sec,$min,$hour,$day,$month,$year,$wday,$yday,$isdst) = localtime($now); list($sec,$min,$hour,$day,$month,$year,$wday,$yday,$isdst) = localtime($now);
$month++; $month++;
$year += 1900; $year += 1900;
if($startmode == 1) { if($startmode == 1) {
if($hour >= $starthour){ $nextday = $day+1;} if($hour >= $starthour){ $nextday = $day+1;}
else{$nextday = $day;} else{$nextday = $day;}
...@@ -310,7 +363,7 @@ function rs_sttime() { ...@@ -310,7 +363,7 @@ function rs_sttime() {
} else { } else {
$starttime = 0; $starttime = 0;
} }
return; return;
} }
...@@ -319,7 +372,7 @@ function add_once_area($atime) { ...@@ -319,7 +372,7 @@ function add_once_area($atime) {
//实际上GAMEOVER的判断是在common.inc.php里 //实际上GAMEOVER的判断是在common.inc.php里
global $db,$gtablepre,$tablepre,$now,$gamestate,$areaesc,$arealist,$areanum,$arealimit,$areaadd,$plsinfo,$weather,$hack,$validnum,$alivenum,$deathnum; global $db,$gtablepre,$tablepre,$now,$gamestate,$areaesc,$arealist,$areanum,$arealimit,$areaadd,$plsinfo,$weather,$hack,$validnum,$alivenum,$deathnum;
global $gamevars,$deepzones,$sentinel_typelist,$npc_away_from_deepzones; global $gamevars,$deepzones,$sentinel_typelist,$npc_away_from_deepzones;
if (($gamestate > 10)&&($now > $atime)) { if (($gamestate > 10)&&($now > $atime)) {
$plsnum = sizeof($plsinfo) - 1; $plsnum = sizeof($plsinfo) - 1;
if(($areanum >= $arealimit*$areaadd)&&($validnum<=0)) {//无人参加GAMEOVER不是因为这里,这里只是保险。 if(($areanum >= $arealimit*$areaadd)&&($validnum<=0)) {//无人参加GAMEOVER不是因为这里,这里只是保险。
...@@ -390,7 +443,7 @@ function add_once_area($atime) { ...@@ -390,7 +443,7 @@ function add_once_area($atime) {
$pls = $arealist[rand($areanum+1,$plsnum)]; $pls = $arealist[rand($areanum+1,$plsnum)];
}while (in_array($pls,$deepzones)); }while (in_array($pls,$deepzones));
} }
else else
{ {
do{ do{
$pls = $arealist[rand($areanum+1,$plsnum)]; $pls = $arealist[rand($areanum+1,$plsnum)];
...@@ -400,7 +453,7 @@ function add_once_area($atime) { ...@@ -400,7 +453,7 @@ function add_once_area($atime) {
} }
} }
$alivenum = $db->result($db->query("SELECT COUNT(*) FROM {$tablepre}players WHERE hp>0 AND type=0"), 0); $alivenum = $db->result($db->query("SELECT COUNT(*) FROM {$tablepre}players WHERE hp>0 AND type=0"), 0);
if(($alivenum == 1)&&($gamestate >= 30)) { if(($alivenum == 1)&&($gamestate >= 30)) {
gameover($atime); gameover($atime);
return; return;
} elseif(($alivenum <= 0)&&($gamestate >= 30)) { } elseif(($alivenum <= 0)&&($gamestate >= 30)) {
...@@ -437,13 +490,13 @@ function duel($time = 0,$keyitm = ''){ ...@@ -437,13 +490,13 @@ function duel($time = 0,$keyitm = ''){
$time = $time == 0 ? $now : $time; $time = $time == 0 ? $now : $time;
$gamestate = 50; $gamestate = 50;
save_gameinfo(); save_gameinfo();
addnews($time,'duelkey',$name,$keyitm,$nick); addnews($time,'duelkey',$name,$keyitm,$nick);
addnews($time,'duel'); addnews($time,'duel');
systemputchat($time,'duel'); systemputchat($time,'duel');
return 50; return 50;
} }
} }
//------游戏结束------ //------游戏结束------
//模式:0保留:程序故障;1:全部死亡;2:最后幸存;3:禁区解除;4:无人参加;5:核爆全灭;6:GM中止 //模式:0保留:程序故障;1:全部死亡;2:最后幸存;3:禁区解除;4:无人参加;5:核爆全灭;6:GM中止
...@@ -469,7 +522,7 @@ function gameover($time = 0, $mode = '', $winname = '') { ...@@ -469,7 +522,7 @@ function gameover($time = 0, $mode = '', $winname = '') {
$alivenum = 0; $alivenum = 0;
$winmode = 4; $winmode = 4;
$winner = ''; $winner = '';
} else {//判断谁是最后幸存者 } else {//判断谁是最后幸存者
$result = $db->query("SELECT * FROM {$tablepre}players WHERE hp>0 AND type=0"); $result = $db->query("SELECT * FROM {$tablepre}players WHERE hp>0 AND type=0");
$alivenum = $db->num_rows($result); $alivenum = $db->num_rows($result);
...@@ -517,7 +570,7 @@ function gameover($time = 0, $mode = '', $winname = '') { ...@@ -517,7 +570,7 @@ function gameover($time = 0, $mode = '', $winname = '') {
$tresult = $db->query("SELECT name,ip FROM {$tablepre}players WHERE teamID='$team' AND type=0"); $tresult = $db->query("SELECT name,ip FROM {$tablepre}players WHERE teamID='$team' AND type=0");
if($db->num_rows($tresult) > 1) if($db->num_rows($tresult) > 1)
{ {
while($tpdata = $db->fetch_array($tresult)) while($tpdata = $db->fetch_array($tresult))
{ {
if(!in_array($tpdata['name'],$team_mates) && !in_array($tpdata['ip'],$team_ips)) if(!in_array($tpdata['name'],$team_mates) && !in_array($tpdata['ip'],$team_ips))
{ {
...@@ -547,14 +600,14 @@ function gameover($time = 0, $mode = '', $winname = '') { ...@@ -547,14 +600,14 @@ function gameover($time = 0, $mode = '', $winname = '') {
//$pdata['teamIcon'] = !empty($team_mates) ? 1 : 0; //$pdata['teamIcon'] = !empty($team_mates) ? 1 : 0;
$db->query("INSERT INTO {$gtablepre}winners (gid,nick,name,pass,type,endtime,gd,sNo,icon,club,hp,mhp,sp,msp,ss,mss,att,def,pls,lvl,`exp`,money,bid,inf,rage,pose,tactic,killnum,killnum2,state,wp,wk,wg,wc,wd,wf,teamID,teamPass,teamMate,teamIcon,wep,wepk,wepe,weps,arb,arbk,arbe,arbs,arh,arhk,arhe,arhs,ara,arak,arae,aras,arf,arfk,arfe,arfs,art,artk,arte,arts,itm0,itmk0,itme0,itms0,itm1,itmk1,itme1,itms1,itm2,itmk2,itme2,itms2,itm3,itmk3,itme3,itms3,itm4,itmk4,itme4,itms4,itm5,itmk5,itme5,itms5,itm6,itmk6,itme6,itms6,motto,wmode,vnum,gtime,gstime,getime,hdmg,hdp,hkill,hkp,wepsk,arbsk,arhsk,arask,arfsk,artsk,itmsk0,itmsk1,itmsk2,itmsk3,itmsk4,itmsk5,itmsk6) VALUES ('".$gamenum."','".$pdata['nick']."','".$pdata['name']."','".$pdata['pass']."','".$pdata['type']."','".$pdata['endtime']."','".$pdata['gd']."','".$pdata['sNo']."','".$pdata['icon']."','".$pdata['club']."','".$pdata['hp']."','".$pdata['mhp']."','".$pdata['sp']."','".$pdata['msp']."','".$pdata['ss']."','".$pdata['mss']."','".$pdata['att']."','".$pdata['def']."','".$pdata['pls']."','".$pdata['lvl']."','".$pdata['exp']."','".$pdata['money']."','".$pdata['bid']."','".$pdata['inf']."','".$pdata['rage']."','".$pdata['pose']."','".$pdata['tactic']."','".$pdata['killnum']."','".$pdata['killnum2']."','".$pdata['state']."','".$pdata['wp']."','".$pdata['wk']."','".$pdata['wg']."','".$pdata['wc']."','".$pdata['wd']."','".$pdata['wf']."','".$pdata['teamID']."','".$pdata['teamPass']."','".$pdata['teamMate']."','".$pdata['teamIcon']."','".$pdata['wep']."','".$pdata['wepk']."','".$pdata['wepe']."','".$pdata['weps']."','".$pdata['arb']."','".$pdata['arbk']."','".$pdata['arbe']."','".$pdata['arbs']."','".$pdata['arh']."','".$pdata['arhk']."','".$pdata['arhe']."','".$pdata['arhs']."','".$pdata['ara']."','".$pdata['arak']."','".$pdata['arae']."','".$pdata['aras']."','".$pdata['arf']."','".$pdata['arfk']."','".$pdata['arfe']."','".$pdata['arfs']."','".$pdata['art']."','".$pdata['artk']."','".$pdata['arte']."','".$pdata['arts']."','".$pdata['itm0']."','".$pdata['itmk0']."','".$pdata['itme0']."','".$pdata['itms0']."','".$pdata['itm1']."','".$pdata['itmk1']."','".$pdata['itme1']."','".$pdata['itms1']."','".$pdata['itm2']."','".$pdata['itmk2']."','".$pdata['itme2']."','".$pdata['itms2']."','".$pdata['itm3']."','".$pdata['itmk3']."','".$pdata['itme3']."','".$pdata['itms3']."','".$pdata['itm4']."','".$pdata['itmk4']."','".$pdata['itme4']."','".$pdata['itms4']."','".$pdata['itm5']."','".$pdata['itmk5']."','".$pdata['itme5']."','".$pdata['itms5']."','".$pdata['itm6']."','".$pdata['itmk6']."','".$pdata['itme6']."','".$pdata['itms6']."','".$pdata['motto']."','".$pdata['wmode']."','".$pdata['vnum']."','".$pdata['gtime']."','".$pdata['gstime']."','".$pdata['getime']."','".$pdata['hdmg']."','".$pdata['hdp']."','".$pdata['hkill']."','".$pdata['hkp']."','".$pdata['wepsk']."','".$pdata['arbsk']."','".$pdata['arhsk']."','".$pdata['arask']."','".$pdata['arfsk']."','".$pdata['artsk']."','".$pdata['itmsk0']."','".$pdata['itmsk1']."','".$pdata['itmsk2']."','".$pdata['itmsk3']."','".$pdata['itmsk4']."','".$pdata['itmsk5']."','".$pdata['itmsk6']."')"); $db->query("INSERT INTO {$gtablepre}winners (gid,nick,name,pass,type,endtime,gd,sNo,icon,club,hp,mhp,sp,msp,ss,mss,att,def,pls,lvl,`exp`,money,bid,inf,rage,pose,tactic,killnum,killnum2,state,wp,wk,wg,wc,wd,wf,teamID,teamPass,teamMate,teamIcon,wep,wepk,wepe,weps,arb,arbk,arbe,arbs,arh,arhk,arhe,arhs,ara,arak,arae,aras,arf,arfk,arfe,arfs,art,artk,arte,arts,itm0,itmk0,itme0,itms0,itm1,itmk1,itme1,itms1,itm2,itmk2,itme2,itms2,itm3,itmk3,itme3,itms3,itm4,itmk4,itme4,itms4,itm5,itmk5,itme5,itms5,itm6,itmk6,itme6,itms6,motto,wmode,vnum,gtime,gstime,getime,hdmg,hdp,hkill,hkp,wepsk,arbsk,arhsk,arask,arfsk,artsk,itmsk0,itmsk1,itmsk2,itmsk3,itmsk4,itmsk5,itmsk6) VALUES ('".$gamenum."','".$pdata['nick']."','".$pdata['name']."','".$pdata['pass']."','".$pdata['type']."','".$pdata['endtime']."','".$pdata['gd']."','".$pdata['sNo']."','".$pdata['icon']."','".$pdata['club']."','".$pdata['hp']."','".$pdata['mhp']."','".$pdata['sp']."','".$pdata['msp']."','".$pdata['ss']."','".$pdata['mss']."','".$pdata['att']."','".$pdata['def']."','".$pdata['pls']."','".$pdata['lvl']."','".$pdata['exp']."','".$pdata['money']."','".$pdata['bid']."','".$pdata['inf']."','".$pdata['rage']."','".$pdata['pose']."','".$pdata['tactic']."','".$pdata['killnum']."','".$pdata['killnum2']."','".$pdata['state']."','".$pdata['wp']."','".$pdata['wk']."','".$pdata['wg']."','".$pdata['wc']."','".$pdata['wd']."','".$pdata['wf']."','".$pdata['teamID']."','".$pdata['teamPass']."','".$pdata['teamMate']."','".$pdata['teamIcon']."','".$pdata['wep']."','".$pdata['wepk']."','".$pdata['wepe']."','".$pdata['weps']."','".$pdata['arb']."','".$pdata['arbk']."','".$pdata['arbe']."','".$pdata['arbs']."','".$pdata['arh']."','".$pdata['arhk']."','".$pdata['arhe']."','".$pdata['arhs']."','".$pdata['ara']."','".$pdata['arak']."','".$pdata['arae']."','".$pdata['aras']."','".$pdata['arf']."','".$pdata['arfk']."','".$pdata['arfe']."','".$pdata['arfs']."','".$pdata['art']."','".$pdata['artk']."','".$pdata['arte']."','".$pdata['arts']."','".$pdata['itm0']."','".$pdata['itmk0']."','".$pdata['itme0']."','".$pdata['itms0']."','".$pdata['itm1']."','".$pdata['itmk1']."','".$pdata['itme1']."','".$pdata['itms1']."','".$pdata['itm2']."','".$pdata['itmk2']."','".$pdata['itme2']."','".$pdata['itms2']."','".$pdata['itm3']."','".$pdata['itmk3']."','".$pdata['itme3']."','".$pdata['itms3']."','".$pdata['itm4']."','".$pdata['itmk4']."','".$pdata['itme4']."','".$pdata['itms4']."','".$pdata['itm5']."','".$pdata['itmk5']."','".$pdata['itme5']."','".$pdata['itms5']."','".$pdata['itm6']."','".$pdata['itmk6']."','".$pdata['itme6']."','".$pdata['itms6']."','".$pdata['motto']."','".$pdata['wmode']."','".$pdata['vnum']."','".$pdata['gtime']."','".$pdata['gstime']."','".$pdata['getime']."','".$pdata['hdmg']."','".$pdata['hdp']."','".$pdata['hkill']."','".$pdata['hkp']."','".$pdata['wepsk']."','".$pdata['arbsk']."','".$pdata['arhsk']."','".$pdata['arask']."','".$pdata['arfsk']."','".$pdata['artsk']."','".$pdata['itmsk0']."','".$pdata['itmsk1']."','".$pdata['itmsk2']."','".$pdata['itmsk3']."','".$pdata['itmsk4']."','".$pdata['itmsk5']."','".$pdata['itmsk6']."')");
} }
//存在获胜者数据时 检查获胜者结局成就 //存在获胜者数据时 检查获胜者结局成就
if(!empty($pdata)) if(!empty($pdata))
{ {
include_once GAME_ROOT.'./include/game/achievement.func.php'; include_once GAME_ROOT.'./include/game/achievement.func.php';
check_end_achievement_rev($winner,$winmode,$pdata); check_end_achievement_rev($winner,$winmode,$pdata);
} }
rs_sttime();//重置游戏开始时间和当前游戏状态 rs_sttime();//重置游戏开始时间和当前游戏状态
$gamestate = 0; $gamestate = 0;
save_gameinfo();//先保存一次免得后面的处理过程太长,尽可能避免脏数据 save_gameinfo();//先保存一次免得后面的处理过程太长,尽可能避免脏数据
...@@ -567,10 +620,10 @@ function gameover($time = 0, $mode = '', $winname = '') { ...@@ -567,10 +620,10 @@ function gameover($time = 0, $mode = '', $winname = '') {
{ {
addnews($time, 'roomgameover' ,$gamenum, $groomid); addnews($time, 'roomgameover' ,$gamenum, $groomid);
} }
else else
{ {
addnews($time, 'gameover' ,$gamenum); addnews($time, 'gameover' ,$gamenum);
} }
systemputchat($time,'gameover'); systemputchat($time,'gameover');
include_once './include/news.func.php'; include_once './include/news.func.php';
$newsinfo = nparse_news(0,65535); $newsinfo = nparse_news(0,65535);
...@@ -593,16 +646,16 @@ function movehtm($atime = 0) { ...@@ -593,16 +646,16 @@ function movehtm($atime = 0) {
if(array_search($key,$arealist) > $areanum || $hack){ if(array_search($key,$arealist) > $areanum || $hack){
$movedata .= "<option value=\"$key\"><!--{if \$pls == $key}--><--现在位置--><!--{else}-->$value($xyinfo[$key])<!--{/if}--><br />"; $movedata .= "<option value=\"$key\"><!--{if \$pls == $key}--><--现在位置--><!--{else}-->$value($xyinfo[$key])<!--{/if}--><br />";
} }
} }
writeover($movehtm,$movedata);*/ writeover($movehtm,$movedata);*/
/*$areahtm = GAME_ROOT.TPLDIR.'/areainfo.htm'; /*$areahtm = GAME_ROOT.TPLDIR.'/areainfo.htm';
$areadata = '<span class="evergreen"><b>现在的禁区是:</b></span>'; $areadata = '<span class="evergreen"><b>现在的禁区是:</b></span>';
for($i=0;$i<=$areanum;$i++){ for($i=0;$i<=$areanum;$i++){
$areadata .= '&nbsp;'.$plsinfo[$arealist[$i]]; $areadata .= '&nbsp;'.$plsinfo[$arealist[$i]];
} }
$areadata .= '<br><span class="evergreen"><b>下回的禁区是:</b></span>';*/ $areadata .= '<br><span class="evergreen"><b>下回的禁区是:</b></span>';*/
$areadata = ''; $areadata = '';
if(!$atime){ if(!$atime){
global $areatime; global $areatime;
...@@ -663,7 +716,7 @@ function addnpc($type,$sub,$num,$time = 0,$anpcdata = NULL) { ...@@ -663,7 +716,7 @@ function addnpc($type,$sub,$num,$time = 0,$anpcdata = NULL) {
$anpcinfo = get_addnpcinfo(); $anpcinfo = get_addnpcinfo();
$anpc_namelist = Array(); $anpc_namelist = Array();
$anpc = array_merge($npcinit,$anpcinfo[$type]); $anpc = array_merge($npcinit,$anpcinfo[$type]);
$anpc = array_merge($anpc,$anpc['sub'][$sub]); $anpc = array_merge($anpc,$anpc['sub'][$sub]);
if(!$anpc){ if(!$anpc){
//echo 'no npc.'; //echo 'no npc.';
return; return;
...@@ -685,7 +738,7 @@ function addnpc($type,$sub,$num,$time = 0,$anpcdata = NULL) { ...@@ -685,7 +738,7 @@ function addnpc($type,$sub,$num,$time = 0,$anpcdata = NULL) {
} }
//$npc['wp'] = $npc['wk'] = $npc['wg'] = $npc['wc'] = $npc['wd'] = $npc['wf'] = $npc['skill']; //$npc['wp'] = $npc['wk'] = $npc['wg'] = $npc['wc'] = $npc['wd'] = $npc['wf'] = $npc['skill'];
if($npc['gd'] == 'r'){$npc['gd'] = rand(0,1) ? 'm':'f';} if($npc['gd'] == 'r'){$npc['gd'] = rand(0,1) ? 'm':'f';}
# 位置信息为数组时,在两地中择一随机刷新 # 位置信息为数组时,在两地中择一随机刷新
if(is_array($npc['pls'])) if(is_array($npc['pls']))
{ {
...@@ -710,7 +763,7 @@ function addnpc($type,$sub,$num,$time = 0,$anpcdata = NULL) { ...@@ -710,7 +763,7 @@ function addnpc($type,$sub,$num,$time = 0,$anpcdata = NULL) {
} }
} }
//$npc['pls'] = rand(1,$plsnum-1); //$npc['pls'] = rand(1,$plsnum-1);
} }
# NPC称号技能初始化 # NPC称号技能初始化
if(!empty($npc['club'])) changeclub($npc['club'],$npc); if(!empty($npc['club'])) changeclub($npc['club'],$npc);
...@@ -739,7 +792,7 @@ function addnpc($type,$sub,$num,$time = 0,$anpcdata = NULL) { ...@@ -739,7 +792,7 @@ function addnpc($type,$sub,$num,$time = 0,$anpcdata = NULL) {
$npc['clbpara'] = is_array($npc['clbpara']) ? array_merge($npc['clbpara'],$anpcdata['clbpara']) : $anpcdata['clbpara']; $npc['clbpara'] = is_array($npc['clbpara']) ? array_merge($npc['clbpara'],$anpcdata['clbpara']) : $anpcdata['clbpara'];
} }
} }
# 对将要插入数据库的npc数组格式化,现在可以直接在npc配置文件里预设那些后添加的字段了。 # 对将要插入数据库的npc数组格式化,现在可以直接在npc配置文件里预设那些后添加的字段了。
$npc=player_format_with_db_structure($npc); $npc=player_format_with_db_structure($npc);
$db->array_insert("{$tablepre}players", $npc); $db->array_insert("{$tablepre}players", $npc);
...@@ -765,7 +818,7 @@ function addnpc($type,$sub,$num,$time = 0,$anpcdata = NULL) { ...@@ -765,7 +818,7 @@ function addnpc($type,$sub,$num,$time = 0,$anpcdata = NULL) {
} }
unset($anpc_namelist); unset($anpc_namelist);
} }
else else
{ {
return $summon_ids; return $summon_ids;
} }
...@@ -781,7 +834,7 @@ function evonpc($type,$name){ ...@@ -781,7 +834,7 @@ function evonpc($type,$name){
if(!isset($enpcinfo[$type])){return false;} if(!isset($enpcinfo[$type])){return false;}
$result = $db->query("SELECT * FROM {$tablepre}players WHERE type = '$type' AND name = '$name'"); $result = $db->query("SELECT * FROM {$tablepre}players WHERE type = '$type' AND name = '$name'");
$num = $db->num_rows($result); $num = $db->num_rows($result);
if(!$num){return false;} if(!$num){return false;}
if(!isset($enpcinfo[$type][$name])){return false;} if(!isset($enpcinfo[$type][$name])){return false;}
$npc=$enpcinfo[$type][$name]; $npc=$enpcinfo[$type][$name];
$npc['hp'] = $npc['mhp']; $npc['hp'] = $npc['mhp'];
...@@ -825,7 +878,7 @@ function evonpc($type,$name){ ...@@ -825,7 +878,7 @@ function evonpc($type,$name){
$qry = substr($qry,0,-1); $qry = substr($qry,0,-1);
$db->query( "UPDATE {$tablepre}players SET $qry WHERE type = '$type' AND name = '$name'" ); $db->query( "UPDATE {$tablepre}players SET $qry WHERE type = '$type' AND name = '$name'" );
} }
return $npc; return $npc;
} }
...@@ -847,7 +900,7 @@ function antiAFK($timelimit = 0){ ...@@ -847,7 +900,7 @@ function antiAFK($timelimit = 0){
if($db->affected_rows()){ if($db->affected_rows()){
addnews($now,'death32',$kcontent['name'],'',$kcontent['pls']); addnews($now,'death32',$kcontent['name'],'',$kcontent['pls']);
$alivenum--; $alivenum--;
$deathnum++; $deathnum++;
} }
...@@ -884,15 +937,15 @@ function set_credits(){ ...@@ -884,15 +937,15 @@ function set_credits(){
} }
} }
//var_dump($updatelist); //var_dump($updatelist);
//$db->multi_update("{$gtablepre}users", $updatelist2, 'username'); //$db->multi_update("{$gtablepre}users", $updatelist2, 'username');
//$db->multi_update("{$gtablepre}users", $updatelist2, 'username'); //$db->multi_update("{$gtablepre}users", $updatelist2, 'username');
// $result = $db->query("SELECT * FROM {$tablepre}players WHERE type='0'"); // $result = $db->query("SELECT * FROM {$tablepre}players WHERE type='0'");
// $list = $creditlist = $updatelist = Array(); // $list = $creditlist = $updatelist = Array();
// while($data = $db->fetch_array($result)){ // while($data = $db->fetch_array($result)){
// $list[$data['name']]['players'] = $data; // $list[$data['name']]['players'] = $data;
// } // }
// $result = $db->query("SELECT * FROM {$gtablepre}users WHERE lastgame='$gamenum'"); // $result = $db->query("SELECT * FROM {$gtablepre}users WHERE lastgame='$gamenum'");
// while($data = $db->fetch_array($result)){ // while($data = $db->fetch_array($result)){
// $list[$data['username']]['users'] = $data; // $list[$data['username']]['users'] = $data;
...@@ -910,7 +963,7 @@ function set_credits(){ ...@@ -910,7 +963,7 @@ function set_credits(){
// }else{ // }else{
// $udghlist[] = Array('name' => $key, 'gainhonour' => $obtain); // $udghlist[] = Array('name' => $key, 'gainhonour' => $obtain);
// } // }
// } // }
// } // }
// } // }
// $db->multi_update("{$gtablepre}users", $updatelist, 'username'); // $db->multi_update("{$gtablepre}users", $updatelist, 'username');
...@@ -920,14 +973,14 @@ function set_credits(){ ...@@ -920,14 +973,14 @@ function set_credits(){
// } // }
//更新成就 //更新成就
//$result = $db->query("SELECT * FROM {$tablepre}players WHERE {$tablepre}players.type='0'"); //$result = $db->query("SELECT * FROM {$tablepre}players WHERE {$tablepre}players.type='0'");
//while($data = $db->fetch_array($result)) //while($data = $db->fetch_array($result))
//{ //{
// $dlist[$data['name']] = $data['achievement']; // $dlist[$data['name']] = $data['achievement'];
//} //}
//include_once GAME_ROOT.'./include/game/achievement.func.php'; //include_once GAME_ROOT.'./include/game/achievement.func.php';
//foreach($dlist as $key => $val) //foreach($dlist as $key => $val)
//{ //{
//$v=$val; //$v=$val;
//normalize_achievement($v,$c1,$c2); //normalize_achievement($v,$c1,$c2);
//$res = $db->query("SELECT * FROM {$gtablepre}users WHERE username='".$key."'" ); //$res = $db->query("SELECT * FROM {$gtablepre}users WHERE username='".$key."'" );
//$data=$db->fetch_array($res); //$data=$db->fetch_array($res);
...@@ -990,10 +1043,10 @@ function get_gambling_result($clist, $winner='',$winmode=''){ ...@@ -990,10 +1043,10 @@ function get_gambling_result($clist, $winner='',$winmode=''){
$bwlist[$bdata['uname']] = $bdata;//此处只记录赌赢者的资料 $bwlist[$bdata['uname']] = $bdata;//此处只记录赌赢者的资料
$bwsum += $bdata['wager'];//赌赢者本金数目 $bwsum += $bdata['wager'];//赌赢者本金数目
$bwsum2 += $bdata['wager'] * $bdata['odds'];//赌赢者总系数 $bwsum2 += $bdata['wager'] * $bdata['odds'];//赌赢者总系数
} }
$bpool += $bdata['wager'];//奖池记录所有玩家的赌注总额 $bpool += $bdata['wager'];//奖池记录所有玩家的赌注总额
} }
//(所有入场玩家战斗力总和÷1000)×(每名玩家APM达到则1.0—1.1之间的随机数)×(连斗时间从10—0.1递减)=每局基础奖金——飞雪大魔王 //(所有入场玩家战斗力总和÷1000)×(每名玩家APM达到则1.0—1.1之间的随机数)×(连斗时间从10—0.1递减)=每局基础奖金——飞雪大魔王
$creditsum = $apmnum = 0; $creditsum = $apmnum = 0;
...@@ -1002,16 +1055,16 @@ function get_gambling_result($clist, $winner='',$winmode=''){ ...@@ -1002,16 +1055,16 @@ function get_gambling_result($clist, $winner='',$winmode=''){
$apm = $cdata['deathtime'] > $cdata['validtime'] ? $cdata['cmdnum'] / ($cdata['deathtime'] - $cdata['validtime']) : $cdata['cmdnum'] / ($now - $cdata['validtime']); $apm = $cdata['deathtime'] > $cdata['validtime'] ? $cdata['cmdnum'] / ($cdata['deathtime'] - $cdata['validtime']) : $cdata['cmdnum'] / ($now - $cdata['validtime']);
if($apm >= 1){$apmnum ++;} if($apm >= 1){$apmnum ++;}
} }
$avrcredit = $creditsum / ($validnum > 0 ? $validnum : 1);//平均战斗力 $avrcredit = $creditsum / ($validnum > 0 ? $validnum : 1);//平均战斗力
if($avrcredit > 10000){$creditodds = 1.25;}//平均战斗力超过10000则系数为1.25,否则系数减少,平均战斗力为4000时为1.1; if($avrcredit > 10000){$creditodds = 1.25;}//平均战斗力超过10000则系数为1.25,否则系数减少,平均战斗力为4000时为1.1;
else{$creditodds = round((1 + $avrcredit / 40000)*1000)/1000;} else{$creditodds = round((1 + $avrcredit / 40000)*1000)/1000;}
$apmodds = round(pow(1.02,$apmnum)*1000)/1000;//每有一名玩家达到60APM则乘以1.02 $apmodds = round(pow(1.02,$apmnum)*1000)/1000;//每有一名玩家达到60APM则乘以1.02
$timeodds = 1.2 - $areanum/$areaadd * 0.1;//游戏结束时为0禁则系数为1.2,否则每禁系数减少0.1,不会低于0.8 $timeodds = 1.2 - $areanum/$areaadd * 0.1;//游戏结束时为0禁则系数为1.2,否则每禁系数减少0.1,不会低于0.8
if($timeodds < 0.8){$timeodds = 0.8;} if($timeodds < 0.8){$timeodds = 0.8;}
// $result3 = $db->query("SELECT cmdnum FROM {$tablepre}players WHERE type=0 ORDER BY cmdnum DESC LIMIT 10"); // $result3 = $db->query("SELECT cmdnum FROM {$tablepre}players WHERE type=0 ORDER BY cmdnum DESC LIMIT 10");
// while($cdata = $db->fetch_array($result3)){ // while($cdata = $db->fetch_array($result3)){
// $cmdsum += $cdata['cmdnum']; // $cmdsum += $cdata['cmdnum'];
...@@ -1019,7 +1072,7 @@ function get_gambling_result($clist, $winner='',$winmode=''){ ...@@ -1019,7 +1072,7 @@ function get_gambling_result($clist, $winner='',$winmode=''){
// if($cmdsum <= 10000){$cmdodds = 1;} // if($cmdsum <= 10000){$cmdodds = 1;}
// elseif($cmdsum >= 30000){$cmdodds = 1.25;} // elseif($cmdsum >= 30000){$cmdodds = 1.25;}
// else{$cmdodds = 1+($cmdsum-10000)*0.0000125;} // else{$cmdodds = 1+($cmdsum-10000)*0.0000125;}
//$dmgprizeodds = 100 + round(pow($hdamage,0.5)) * 2; //$dmgprizeodds = 100 + round(pow($hdamage,0.5)) * 2;
$obpool = $bpool; $obpool = $bpool;
$bpool = round($bpool * $creditodds * $apmodds * $timeodds); $bpool = round($bpool * $creditodds * $apmodds * $timeodds);
...@@ -1062,9 +1115,9 @@ function get_gambling_result($clist, $winner='',$winmode=''){ ...@@ -1062,9 +1115,9 @@ function get_gambling_result($clist, $winner='',$winmode=''){
// $crup = $val['wager'] + round($bpool * 0.9 * $val['wager'] * $val['odds'] / $bwsum2); // $crup = $val['wager'] + round($bpool * 0.9 * $val['wager'] * $val['odds'] / $bwsum2);
// $bwlist[$val['uname']]['crup'] = $crup; // $bwlist[$val['uname']]['crup'] = $crup;
// $credits2 = $val['credits2'] + $crup; // $credits2 = $val['credits2'] + $crup;
// $updatelist[$key] = Array('username' => $key, 'credits2' => $credits2); // $updatelist[$key] = Array('username' => $key, 'credits2' => $credits2);
// } // }
}else{ }else{
$gblog .= '无判断正确者,奖池的20%归获胜者。'; $gblog .= '无判断正确者,奖池的20%归获胜者。';
$wcrup = ceil($bpool * 0.2); $wcrup = ceil($bpool * 0.2);
......
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