Commit 31b2f0c9 authored by Nemo Ma's avatar Nemo Ma

BUGFIX: Item infinite durability

parent f74e6c7c
修复耐久度为∞的消耗道具被错误消耗的问题
时间:2025年1月19日
## 问题描述
玩家汇报使用了一件耐久度为∞(itms='∞')的消耗道具时,该物品被直接消耗。
耐久度∞的道具正确的处理是可以无限使用。
## 问题分析
通过对比item.func.old和新版本的item.main.php,发现在重构过程中,有几处地方直接使用了`$itms--`而没有检查`$nosta`(无限耐久度标识)。
## 修复内容
### 1. include/game/item.main.php
**位置**:第218行
**问题**:元素大师使用提示纸条时直接消耗道具
**修复前**:
```php
$itms--;
```
**修复后**:
```php
if ($itms != $nosta) {
$itms--;
}
```
### 2. include/game/item.tool.php
**位置**:多处
**问题**:多个工具类道具使用时直接消耗道具
#### 2.1 探测器电池(第98行)
**修复前**:
```php
$itms--;
```
**修复后**:
```php
if ($itms != $nosta) {
$itms--;
}
```
#### 2.2 御神签(第111行)
**修复前**:
```php
$itms--;
```
**修复后**:
```php
if ($itms != $nosta) {
$itms--;
}
```
#### 2.3 凸眼鱼(第118行)
**修复前**:
```php
$itms--; $isk = $cnum;
```
**修复后**:
```php
if ($itms != $nosta) {
$itms--;
}
$isk = $cnum;
```
#### 2.4 鱼眼凸(第127行)
**修复前**:
```php
$itms--; $isk = $cnum;
```
**修复后**:
```php
if ($itms != $nosta) {
$itms--;
}
$isk = $cnum;
```
#### 2.5 天候棒(第139行)
**修复前**:
```php
$itms--;
```
**修复后**:
```php
if ($itms != $nosta) {
$itms--;
}
```
#### 2.6 消音器(第146行)
**修复前**:
```php
$itms--;
```
**修复后**:
```php
if ($itms != $nosta) {
$itms--;
}
```
### 3. include/game/item.giftbox.php
**位置**:多处
**问题**:礼品盒类道具使用时直接消耗道具
#### 3.1 YGO box(第134行)
**修复前**:
```php
$itms--; $oitm = $itm;
```
**修复后**:
```php
$oitm = $itm;
if ($itms != $nosta) {
$itms--;
}
```
#### 3.2 FY box(第161行)
**修复前**:
```php
$itms--; $oitm = $itm;
```
**修复后**:
```php
$oitm = $itm;
if ($itms != $nosta) {
$itms--;
}
```
#### 3.3 Debug box(第188行)
**修复前**:
```php
$itms--; $oitm = $itm;
```
**修复后**:
```php
$oitm = $itm;
if ($itms != $nosta) {
$itms--;
}
```
#### 3.4 Gift box(第20行)
**修复前**:
```php
$itms--; $oitm = $itm; $oitmk = $itmk;
```
**修复后**:
```php
$oitm = $itm; $oitmk = $itmk;
if ($itms != $nosta) {
$itms--;
}
```
### 4. include/game/item.weather.php
**位置**:第20行
**问题**:天气控制道具使用时直接消耗道具
**修复前**:
```php
$itms--;
if ($itms <= 0) {
$log .= "<span class=\"red\">$itm</span>用光了。<br>";
$itm = $itmk = $itmsk = '';
$itme = $itms = 0;
}
```
**修复后**:
```php
if ($itms != $nosta) {
$itms--;
if ($itms <= 0) {
$log .= "<span class=\"red\">$itm</span>用光了。<br>";
$itm = $itmk = $itmsk = '';
$itme = $itms = 0;
}
}
```
### 5. include/game/item.other.php
**位置**:第410行
**问题**:🎆C类型道具(Weird Fireseed Box)使用时直接消耗道具
**修复前**:
```php
$itms--; $oitm = $itm; $oitmk = $itmk;
```
**修复后**:
```php
$oitm = $itm; $oitmk = $itmk;
if ($itms != $nosta) {
$itms--;
}
```
## 修复原理
在旧版本的item.func.old中,所有的物品消耗都正确地使用了以下模式:
```php
if ($itms != $nosta) {
$itms--;
if ($itms <= 0) {
$log .= "<span class=\"red\">$itm</span>用光了。<br>";
$itm = $itmk = $itmsk = '';
$itme = $itms = 0;
}
}
```
其中`$nosta`是全局变量,表示无限耐久度的标识(通常为'∞')。
当物品的耐久度等于`$nosta`时,不应该减少耐久度,从而实现无限使用的效果。
## 测试建议
1. 创建一个耐久度为∞的消耗道具
2. 使用该道具,确认道具不会被消耗
3. 测试各种类型的道具:
- 元素大师的提示纸条
- 工具类道具(探测器电池、御神签等)
- 礼品盒类道具
## 注意事项
此修复确保了所有消耗道具在使用时都会正确检查耐久度是否为无限,
保持了与旧版本item.func.old的一致性。
...@@ -17,7 +17,10 @@ function item_giftbox($itmn, &$data) { ...@@ -17,7 +17,10 @@ function item_giftbox($itmn, &$data) {
$log.="你打开了<span class=\"yellow\">$itm</span>。<br>"; $log.="你打开了<span class=\"yellow\">$itm</span>。<br>";
$itms--; $oitm = $itm; $oitmk = $itmk; $oitm = $itm; $oitmk = $itmk;
if ($itms != $nosta) {
$itms--;
}
//if($itms <= 0) destory_single_item($data,$itmn,1); //if($itms <= 0) destory_single_item($data,$itmn,1);
if(strpos($oitmk, 'ps') === 0){//银色盒子 if(strpos($oitmk, 'ps') === 0){//银色盒子
...@@ -131,7 +134,10 @@ function item_ygo_box($itmn, &$data) { ...@@ -131,7 +134,10 @@ function item_ygo_box($itmn, &$data) {
$itmsk = & ${'itmsk' . $itmn}; $itmsk = & ${'itmsk' . $itmn};
$log.="你打开了<span class=\"yellow\">$itm</span>。<br>"; $log.="你打开了<span class=\"yellow\">$itm</span>。<br>";
$itms--; $oitm = $itm; $oitm = $itm;
if ($itms != $nosta) {
$itms--;
}
if($itms <= 0) destory_single_item($data,$itmn,1); if($itms <= 0) destory_single_item($data,$itmn,1);
$file1 = config('box',$gamecfg); $file1 = config('box',$gamecfg);
...@@ -158,7 +164,10 @@ function item_fy_box($itmn, &$data) { ...@@ -158,7 +164,10 @@ function item_fy_box($itmn, &$data) {
$itmsk = & ${'itmsk' . $itmn}; $itmsk = & ${'itmsk' . $itmn};
$log.="你打开了<span class=\"yellow\">$itm</span>。<br>"; $log.="你打开了<span class=\"yellow\">$itm</span>。<br>";
$itms--; $oitm = $itm; $oitm = $itm;
if ($itms != $nosta) {
$itms--;
}
if($itms <= 0) destory_single_item($data,$itmn,1); if($itms <= 0) destory_single_item($data,$itmn,1);
$file1 = config('fy',$gamecfg); $file1 = config('fy',$gamecfg);
...@@ -185,7 +194,10 @@ function item_debug_box($itmn, &$data) { ...@@ -185,7 +194,10 @@ function item_debug_box($itmn, &$data) {
$itmsk = & ${'itmsk' . $itmn}; $itmsk = & ${'itmsk' . $itmn};
$log.="你打开了<span class=\"yellow\">$itm</span>。<br>"; $log.="你打开了<span class=\"yellow\">$itm</span>。<br>";
$itms--; $oitm = $itm; $oitm = $itm;
if ($itms != $nosta) {
$itms--;
}
if($itms <= 0) destory_single_item($data,$itmn,1); if($itms <= 0) destory_single_item($data,$itmn,1);
$file1 = config('f99',$gamecfg); $file1 = config('f99',$gamecfg);
......
...@@ -215,14 +215,16 @@ function itemuse($itmn,&$data=NULL) { ...@@ -215,14 +215,16 @@ function itemuse($itmn,&$data=NULL) {
$log .= "特征的元素组合起来,就有机会组合出【{$s_result}】属性。”</span><br>"; $log .= "特征的元素组合起来,就有机会组合出【{$s_result}】属性。”</span><br>";
//阅后即焚 //阅后即焚
$log .="<br>……说这么多鬼记得住啊!<br>你思考了一下,决定把{$itm}吃进肚子里,以便慢慢消化其中的知识。<br>"; $log .="<br>……说这么多鬼记得住啊!<br>你思考了一下,决定把{$itm}吃进肚子里,以便慢慢消化其中的知识。<br>";
$itms--; if ($itms != $nosta) {
$itms--;
}
# 将提示给到的次要特征组合加入笔记内 # 将提示给到的次要特征组合加入笔记内
if(empty($clbpara['elements']['info']['sd']['sd'.$s_id])) if(empty($clbpara['elements']['info']['sd']['sd'.$s_id]))
$clbpara['elements']['info']['sd']['sd'.$s_id] = 1; $clbpara['elements']['info']['sd']['sd'.$s_id] = 1;
} }
// 消耗物品 // 消耗物品
if ($itms <= 0 && $itm) { if ($itms <= 0 && $itms != $nosta && $itm) {
$log .= "<span class=\"red\">$itm</span>用光了。<br>"; $log .= "<span class=\"red\">$itm</span>用光了。<br>";
$itm = $itmk = $itmsk = ''; $itm = $itmk = $itmsk = '';
$itme = $itms = 0; $itme = $itms = 0;
......
...@@ -407,7 +407,10 @@ function item_fireworks($itmn, &$data) { ...@@ -407,7 +407,10 @@ function item_fireworks($itmn, &$data) {
# Officially dubbed Weird Box. # Officially dubbed Weird Box.
$log.="你打开了<span class=\"yellow\">$itm</span>。<br>"; $log.="你打开了<span class=\"yellow\">$itm</span>。<br>";
$itms--; $oitm = $itm; $oitmk = $itmk; $oitm = $itm; $oitmk = $itmk;
if ($itms != $nosta) {
$itms--;
}
include_once config('randomFSW',$gamecfg); include_once config('randomFSW',$gamecfg);
......
...@@ -95,7 +95,9 @@ function item_tool($itmn, &$data) { ...@@ -95,7 +95,9 @@ function item_tool($itmn, &$data) {
for($i = 1; $i <= 6; $i++) { for($i = 1; $i <= 6; $i++) {
if (${'itmk' . $i} == 'R') { if (${'itmk' . $i} == 'R') {
${'itme' . $i} += $itme; ${'itme' . $i} += $itme;
$itms--; if ($itms != $nosta) {
$itms--;
}
$flag = true; $flag = true;
$log .= "为<span class=\"yellow\">{${'itm'.$i}}</span>充了电。"; $log .= "为<span class=\"yellow\">{${'itm'.$i}}</span>充了电。";
break; break;
...@@ -108,14 +110,19 @@ function item_tool($itmn, &$data) { ...@@ -108,14 +110,19 @@ function item_tool($itmn, &$data) {
$log .= "使用了<span class=\"yellow\">$itm</span>。<br>"; $log .= "使用了<span class=\"yellow\">$itm</span>。<br>";
include_once GAME_ROOT . './include/game/item2.func.php'; include_once GAME_ROOT . './include/game/item2.func.php';
divining(); divining();
$itms--; if ($itms != $nosta) {
$itms--;
}
} elseif ($itm == '凸眼鱼') { } elseif ($itm == '凸眼鱼') {
$tm = $now - $corpseprotect; // 尸体保护 $tm = $now - $corpseprotect; // 尸体保护
$db->query("UPDATE {$tablepre}players SET weps='0',wep2s='0',arbs='0',arhs='0',aras='0',arfs='0',arts='0',itms0='0',itms1='0',itms2='0',itms3='0',itms4='0',itms5='0',itms6='0',money='0' WHERE hp <= 0 AND endtime <= $tm"); $db->query("UPDATE {$tablepre}players SET weps='0',wep2s='0',arbs='0',arhs='0',aras='0',arfs='0',arts='0',itms0='0',itms1='0',itms2='0',itms3='0',itms4='0',itms5='0',itms6='0',money='0' WHERE hp <= 0 AND endtime <= $tm");
$cnum = $db->affected_rows(); $cnum = $db->affected_rows();
addnews($now, 'corpseclear', $name, $cnum, $nick); addnews($now, 'corpseclear', $name, $cnum, $nick);
$log .= "使用了<span class=\"yellow\">$itm</span>。<br>突然刮起了一阵怪风,吹走了地上的{$cnum}具尸体!<br>"; $log .= "使用了<span class=\"yellow\">$itm</span>。<br>突然刮起了一阵怪风,吹走了地上的{$cnum}具尸体!<br>";
$itms--; $isk = $cnum; if ($itms != $nosta) {
$itms--;
}
$isk = $cnum;
} elseif ($itm == '鱼眼凸') { } elseif ($itm == '鱼眼凸') {
$tm = $now - $corpseprotect; // 尸体保护 $tm = $now - $corpseprotect; // 尸体保护
$db->query("UPDATE {$tablepre}players SET pls='$pls' WHERE hp <= 0 AND endtime <= $tm"); $db->query("UPDATE {$tablepre}players SET pls='$pls' WHERE hp <= 0 AND endtime <= $tm");
...@@ -124,7 +131,10 @@ function item_tool($itmn, &$data) { ...@@ -124,7 +131,10 @@ function item_tool($itmn, &$data) {
$log .= "使用了<span class=\"yellow\">$itm</span>。<br>突然刮起了一阵怪风,将遍布全场的{$cnum}具尸体吹到了你所在的地方!<br>"; $log .= "使用了<span class=\"yellow\">$itm</span>。<br>突然刮起了一阵怪风,将遍布全场的{$cnum}具尸体吹到了你所在的地方!<br>";
$rp += diceroll(1024); $rp += diceroll(1024);
$log .= "<span class=\"lime\">这过于惨无人道了!</span><br>你觉得罪恶感爬上了你的脊梁!<br>"; $log .= "<span class=\"lime\">这过于惨无人道了!</span><br>你觉得罪恶感爬上了你的脊梁!<br>";
$itms--; $isk = $cnum; if ($itms != $nosta) {
$itms--;
}
$isk = $cnum;
} elseif ($itm == '天候棒') { } elseif ($itm == '天候棒') {
if($weather <= 13) { if($weather <= 13) {
$weather = rand(10, 13); $weather = rand(10, 13);
...@@ -136,14 +146,18 @@ function item_tool($itmn, &$data) { ...@@ -136,14 +146,18 @@ function item_tool($itmn, &$data) {
addnews($now, 'wthfail', $name, $weather, $nick); addnews($now, 'wthfail', $name, $weather, $nick);
$log .= "你转动了几下天候棒。<br>但天气并未发生改变!<br>"; $log .= "你转动了几下天候棒。<br>但天气并未发生改变!<br>";
} }
$itms--; if ($itms != $nosta) {
$itms--;
}
} elseif ($itm == '消音器') { } elseif ($itm == '消音器') {
if (strpos($wepk, 'WG') !== 0) { if (strpos($wepk, 'WG') !== 0) {
$log .= '你没有装备枪械,不能使用消音器。<br>'; $log .= '你没有装备枪械,不能使用消音器。<br>';
} elseif (strpos($wepsk, 'S') === false) { } elseif (strpos($wepsk, 'S') === false) {
$wepsk .= 'S'; $wepsk .= 'S';
$log .= "你给<span class=\"yellow\">$wep</span>安装了<span class=\"yellow\">$itm</span>。<br>"; $log .= "你给<span class=\"yellow\">$wep</span>安装了<span class=\"yellow\">$itm</span>。<br>";
$itms--; if ($itms != $nosta) {
$itms--;
}
} else { } else {
$log .= "你的武器已经安装了消音器。<br>"; $log .= "你的武器已经安装了消音器。<br>";
} }
......
...@@ -17,10 +17,12 @@ function item_weather($itmn, &$data) { ...@@ -17,10 +17,12 @@ function item_weather($itmn, &$data) {
include_once GAME_ROOT . './include/game/item2.func.php'; include_once GAME_ROOT . './include/game/item2.func.php';
wthchange($itm, $itmsk); wthchange($itm, $itmsk);
$itms--; if ($itms != $nosta) {
if ($itms <= 0) { $itms--;
$log .= "<span class=\"red\">$itm</span>用光了。<br>"; if ($itms <= 0) {
$itm = $itmk = $itmsk = ''; $log .= "<span class=\"red\">$itm</span>用光了。<br>";
$itme = $itms = 0; $itm = $itmk = $itmsk = '';
$itme = $itms = 0;
}
} }
} }
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