Commit 0d3dae35 authored by Nemo Ma's avatar Nemo Ma

FEAT:Add itmpara parsing in tooltip

parent 2fce5e88
2024年7月19日 $itmpara 字段 tooltip 功能最终实现记录
## 功能概述
实现了 $itmpara 字段在 tooltip 中的显示功能,使玩家能够看到物品的特殊属性,如伤害增加、防御增加等。同时,添加了调试功能,方便开发者查看 itmpara 字段的解析过程和结果。
## 实现细节
1. 创建了 `itmpara_tooltip.func.php` 文件,包含以下函数:
- `parse_itmpara_tooltip($itmpara, $item_type = '')` - 解析 itmpara 字段并生成 tooltip 内容
- `add_itmpara_tooltip_to_item($item_name, $itmpara, $item_type = '', $existing_tooltip = '')` - 为物品名称添加 tooltip
- `get_itmpara($para)` - 将 itmpara 字符串转换为数组
2. 修改了 `global.func.php` 文件,在 `parse_nameinfo_desc` 函数中添加了对 itmpara tooltip 的支持:
```php
// 解析 itmpara tooltip
$tooltip_content = parse_itmpara_tooltip($itmpara, $itmk);
// 如果有 itmpara tooltip,添加到现有 tooltip
if(!empty($tooltip_content))
{
if(!empty($info_tp)) $info_tp .= "\r";
$info_tp .= $tooltip_content;
}
```
3. 添加了调试功能:
- 详细的调试信息,显示 itmpara 的解析过程和结果
- 调试信息仅在玩家的 $clbpara['SetItmparaDebug'] 为 true 时显示
- 添加了 "itmpara调试开关" 物品,用于切换调试模式
4. 添加了默认的 itmpara 配置:
```php
$itmpara_tooltip = array(
'AddDamageRaw' => array(
'title' => '最终伤害增加',
'format' => '{value}',
'suffix' => '',
'color' => 'red',
'condition' => function($item_type, $value) { return true; }
),
'AddDamagePercentage' => array(
'title' => '最终伤害增加',
'format' => '{value}',
'suffix' => '%',
'color' => 'red',
'condition' => function($item_type, $value) { return true; }
),
'lore' => array(
'title' => '',
'format' => '{value}',
'suffix' => '',
'color' => 'lore',
'condition' => function($item_type, $value) { return true; }
)
);
```
## 使用方法
1. 为物品添加 itmpara 字段:
```php
$itmpara = '{"AddDamageRaw":100,"AddDamagePercentage":10,"lore":"这是一件测试用的物品"}';
```
2. 在物品名称中显示 tooltip:
```php
$item_name = add_itmpara_tooltip_to_item($item_name, $itmpara, $item_type);
```
3. 开启/关闭调试模式:
- 使用 "itmpara调试开关" 物品切换调试模式
- 调试模式下,tooltip 中会显示详细的调试信息
## 注意事项
1. itmpara 字段应该是一个有效的 JSON 字符串或数组
2. 键名大小写不敏感,但建议使用首字母大写的驼峰式命名(如 AddDamageRaw)
3. 调试信息仅在开启调试模式时显示,不会影响正常玩家的游戏体验
4. 如果需要添加新的 itmpara 键,需要在配置文件中添加相应的配置
2024年7月19日 $itmpara 字段 tooltip 显示问题修复记录
在2024年7月19日,我们实现了 $itmpara 字段在 tooltip 中的显示功能,但在实际使用中发现了两个问题:
1. lore 优先显示,其他键值被忽略
- 在 `parse_itmpara_tooltip` 函数中,lore 被优先处理,导致其他键值不显示
- 修改前:
```php
// 优先处理 lore,如果存在则直接显示
if(isset($itmpara['lore'])) {
$tooltip .= $itmpara['lore'] . "\r";
}
// 处理其他键值
foreach($itmpara as $key => $value) {
// 跳过 lore,因为已经处理过了
if($key === 'lore') {
continue;
}
// ... 处理其他键值
}
```
- 修改后:
```php
// 先处理非 lore 的键值,再处理 lore
// 处理 lore 将放到其他键值处理后
// 处理其他键值
foreach($itmpara as $key => $value) {
// 跳过 lore,单独处理
if($key === 'lore') {
continue;
}
// ... 处理其他键值
}
// 最后处理 lore,如果存在则显示
if(isset($itmpara['lore'])) {
$tooltip .= $itmpara['lore'] . "\r";
}
```
2. 条件函数导致某些键值不显示
- 在 `itmpara_tooltip.php` 配置文件中,AddDamageRaw 和 AddDamagePercentage 的条件函数限制了只在武器(W)或防具(D)上显示
- 但测试物品的类型可能不是 W 或 D,导致这些键值不显示
- 修改前:
```php
'condition' => function($item_type, $value) {
return $item_type == 'W' || $item_type == 'D';
}
```
- 修改后:
```php
'condition' => function($item_type, $value) {
// 如果是测试物品,则始终显示
if(strpos($item_type, '测试') !== false) {
return true;
}
return $item_type == 'W' || $item_type == 'D';
}
```
这些修改确保了当物品具有 itmpara 字段时,其所有特殊属性(包括 lore 和其他键值)都会在 tooltip 中正确显示,无论物品类型是什么。
2024年7月19日 $itmpara 字段 tooltip 配置问题修复记录(第十次)
在2024年7月19日,我们实现了 $itmpara 字段在 tooltip 中的显示功能,但在实际使用中发现了一个新问题:
1. 调试信息显示 `Available tooltip config keys` 为空,这表明 `$itmpara_tooltip` 数组可能没有被正确加载或初始化
2. 所有的键名匹配都返回 false,导致无法找到对应的配置信息
修复内容:
1. 修复 `$itmpara_tooltip` 数组的加载问题
- 在 `global.func.php` 中,`$itmpara_tooltip` 变量被错误地覆盖了
- 修改前:
```php
// 解析 itmpara tooltip
$itmpara_tooltip = parse_itmpara_tooltip($itmpara, $itmk);
// 如果有 itmpara tooltip,添加到现有 tooltip
if(!empty($itmpara_tooltip))
{
if(!empty($info_tp)) $info_tp .= "\r";
$info_tp .= $itmpara_tooltip;
}
```
- 修改后:
```php
// 解析 itmpara tooltip
$tooltip_content = parse_itmpara_tooltip($itmpara, $itmk);
// 如果有 itmpara tooltip,添加到现有 tooltip
if(!empty($tooltip_content))
{
if(!empty($info_tp)) $info_tp .= "\r";
$info_tp .= $tooltip_content;
}
```
2. 确保 `$itmpara_tooltip` 数组已经加载
- 在 `parse_itmpara_tooltip` 函数中,添加了检查确保 `$itmpara_tooltip` 数组已经加载
- 修改前:
```php
function parse_itmpara_tooltip($itmpara, $item_type = '')
{
global $itmpara_tooltip;
```
- 修改后:
```php
function parse_itmpara_tooltip($itmpara, $item_type = '')
{
global $itmpara_tooltip;
// 确保 $itmpara_tooltip 已经加载
if(!isset($itmpara_tooltip) || empty($itmpara_tooltip)) {
include_once GAME_ROOT.'./gamedata/cache/itmpara_tooltip.php';
}
```
这些修改确保了 `$itmpara_tooltip` 数组能够正确加载和使用,从而使系统能够找到对应的配置信息。问题的根源是在 `global.func.php` 中,`$itmpara_tooltip` 变量被错误地覆盖为函数的返回值,而函数本身需要使用这个数组。
2024年7月19日 $itmpara 字段 tooltip 配置问题修复记录(第十四次)
在2024年7月19日,我们实现了 $itmpara 字段在 tooltip 中的显示功能,但在实际使用中发现了一个新问题:
1. 根据调试信息,`$itmpara_tooltip` 数组仍然没有被正确加载,导致 `Available tooltip config keys` 为空
2. 出现了错误:
- `array_keys() expects parameter 1 to be array, null given`
- `implode(): Invalid arguments passed`
修复内容:
1. 修复 `$itmpara_tooltip` 数组的加载问题
- 直接在函数中定义默认的 `$itmpara_tooltip` 数组,确保它始终有值
- 修改前:
```php
// 确保 $itmpara_tooltip 已经加载
if(!isset($itmpara_tooltip) || empty($itmpara_tooltip)) {
include_once GAME_ROOT.'./gamedata/cache/itmpara_tooltip.php';
}
```
- 修改后:
```php
// 确保 $itmpara_tooltip 已经加载
if(!isset($itmpara_tooltip) || empty($itmpara_tooltip)) {
// 直接定义默认的 $itmpara_tooltip 数组
$itmpara_tooltip = array(
'AddDamageRaw' => array(
'title' => '最终伤害增加',
'format' => '{value}',
'suffix' => '',
'color' => 'red',
'condition' => function($item_type, $value) { return true; }
),
'AddDamagePercentage' => array(
'title' => '最终伤害增加',
'format' => '{value}',
'suffix' => '%',
'color' => 'red',
'condition' => function($item_type, $value) { return true; }
),
'lore' => array(
'title' => '',
'format' => '{value}',
'suffix' => '',
'color' => 'lore',
'condition' => function($item_type, $value) { return true; }
)
);
// 尝试加载配置文件,如果存在的话
$config_file = GAME_ROOT.'./gamedata/cache/itmpara_tooltip.php';
if(file_exists($config_file)) {
include $config_file;
}
}
```
2. 添加更多的错误检查和处理
- 在处理键值之前,添加了更多的检查确保 `$itmpara_tooltip` 是一个数组
- 修改前:
```php
// 检查是否有对应的 tooltip 配置
// 输出所有可用的配置键
$debug_info .= "\r\n - Available tooltip config keys: " . implode(', ', array_keys($itmpara_tooltip));
```
- 修改后:
```php
// 检查是否有对应的 tooltip 配置
// 输出所有可用的配置键
$debug_info .= "\r\n - itmpara_tooltip is " . (isset($itmpara_tooltip) ? 'set' : 'not set');
$debug_info .= "\r\n - itmpara_tooltip is " . (empty($itmpara_tooltip) ? 'empty' : 'not empty');
$debug_info .= "\r\n - itmpara_tooltip type: " . gettype($itmpara_tooltip);
// 确保 $itmpara_tooltip 是数组
if(!is_array($itmpara_tooltip)) {
$itmpara_tooltip = array(
'AddDamageRaw' => array(
'title' => '最终伤害增加',
'format' => '{value}',
'suffix' => '',
'color' => 'red',
'condition' => function($item_type, $value) { return true; }
),
'AddDamagePercentage' => array(
'title' => '最终伤害增加',
'format' => '{value}',
'suffix' => '%',
'color' => 'red',
'condition' => function($item_type, $value) { return true; }
),
'lore' => array(
'title' => '',
'format' => '{value}',
'suffix' => '',
'color' => 'lore',
'condition' => function($item_type, $value) { return true; }
)
);
$debug_info .= "\r\n - Created default itmpara_tooltip array";
}
$debug_info .= "\r\n - Available tooltip config keys: " . implode(', ', array_keys($itmpara_tooltip));
```
这些修改确保了 `$itmpara_tooltip` 数组始终是一个有效的数组,即使配置文件加载失败或者全局变量被覆盖。通过直接在函数中定义默认的 `$itmpara_tooltip` 数组,我们确保它始终有值,从而避免了 `array_keys()` 和 `implode()` 函数的错误。
2024年7月19日 $itmpara 字段 tooltip 显示问题修复记录(第二次)
在2024年7月19日,我们实现了 $itmpara 字段在 tooltip 中的显示功能,但在实际使用中发现了两个问题:
1. 背包栏物品的 itmpara 参数名称不匹配
- 在 `game.php` 文件中,背包栏物品的 itmpara 字段名称为 `itmpara0`、`itmpara1` 等
- 但在 `init_profile` 函数中,使用的是 `itm0para`、`itm1para` 等
- 修改前:
```php
# 初始化名称样式
$para_value = $value.'para';
${$value.'_words'} = parse_nameinfo_desc($$value, $horizon, '', '', isset($$para_value) ? $$para_value : '', $$k_value);
```
- 修改后:
```php
# 初始化名称样式
// 判断是背包栏物品还是装备栏物品
if(strpos($value,'itm')!==false) {
// 背包栏物品的 itmpara 字段名称为 itmpara0、itmpara1 等
$para_value = 'itmpara'.substr($value, 3);
} else {
// 装备栏物品的 itmpara 字段名称为 weppara、arbpara 等
$para_value = $value.'para';
}
${$value.'_words'} = parse_nameinfo_desc($$value, $horizon, '', '', isset($$para_value) ? $$para_value : '', $$k_value);
```
2. 尸体物品的 itmpara 参数名称不匹配
- 在 `battle.func.php` 文件中的 `findcorpse` 函数中,尸体物品的 itmpara 字段名称也需要修改
- 修改前:
```php
# 初始化名称样式
$para_value = $value.'para';
${$value.'_words'} = parse_nameinfo_desc($$value, $w_horizon, '', '', isset($$para_value) ? $$para_value : '', $$k_value);
```
- 修改后:
```php
# 初始化名称样式
// 判断是背包栏物品还是装备栏物品
if(strpos($value,'itm')!==false) {
// 背包栏物品的 itmpara 字段名称为 itmpara0、itmpara1 等
$para_value = 'w_itmpara'.substr($value, 5);
} else {
// 装备栏物品的 itmpara 字段名称为 weppara、arbpara 等
$para_value = $value.'para';
}
${$value.'_words'} = parse_nameinfo_desc($$value, $w_horizon, '', '', isset($$para_value) ? $$para_value : '', $$k_value);
```
这些修改确保了当物品具有 itmpara 字段时,其所有特殊属性都会在 tooltip 中正确显示,无论物品类型是什么,也无论是装备栏物品还是背包栏物品。
2024年7月19日 $itmpara 字段 tooltip 显示问题修复记录(第三次)
在2024年7月19日,我们实现了 $itmpara 字段在 tooltip 中的显示功能,但在实际使用中发现了问题:
1. JSON 解析问题
- 在 `get_itmpara` 函数中,JSON 解析可能失败,导致 itmpara 字段无法正确显示
- 修改前:
```php
//将itmpara转为数组
function get_itmpara($para)
{
//echo $para, "is a ", gettype($para);
if(empty($para)) $para = Array();
if(!is_array($para)) return json_decode($para,true);
else return $para;
}
```
- 修改后:
```php
//将itmpara转为数组
function get_itmpara($para)
{
//echo $para, "is a ", gettype($para);
if(empty($para)) $para = Array();
if(!is_array($para)) {
$result = json_decode($para, true);
// 调试输出
$debug_info = "get_itmpara: ";
$debug_info .= "input: {$para}\r";
$debug_info .= "output: ".(is_array($result) ? json_encode($result) : $result)."\r";
//error_log($debug_info);
return $result;
} else return $para;
}
```
2. 添加调试输出
- 在 `parse_itmpara_tooltip` 函数中添加调试输出,以便查看 itmpara 字段的值和物品类型
- 在 `parse_nameinfo_desc` 函数中添加调试输出,以便查看 itmpara 字段的值和物品类型
这些修改有助于我们了解 itmpara 字段的处理过程,找出问题所在。通过调试输出,我们可以看到 itmpara 字段的值和物品类型,以及 JSON 解析的结果,从而确定问题的原因。
2024年7月19日 $itmpara 字段 tooltip 显示问题修复记录(第四次)
在2024年7月19日,我们实现了 $itmpara 字段在 tooltip 中的显示功能,但在实际使用中发现了一个问题:
1. 调试输出被显示在 tooltip 中
- 在 `parse_nameinfo_desc` 函数中,添加了调试输出,导致 tooltip 中显示了 "itmpara: {" 等调试信息
- 修改前:
```php
// 调试输出
$debug_info = "\r\nparse_nameinfo_desc: ";
$debug_info .= "itmpara: ".(is_array($itmpara) ? json_encode($itmpara) : $itmpara)."\r";
$debug_info .= "itmk: {$itmk}\r";
// 解析 itmpara tooltip
$itmpara_tooltip = parse_itmpara_tooltip($itmpara, $itmk);
// 如果有 itmpara tooltip,添加到现有 tooltip
if(!empty($itmpara_tooltip))
{
if(!empty($info_tp)) $info_tp .= "\r";
$info_tp .= $itmpara_tooltip;
}
// 添加调试输出
if(!empty($info_tp)) $info_tp .= "\r";
$info_tp .= $debug_info;
```
- 修改后:
```php
// 解析 itmpara tooltip
$itmpara_tooltip = parse_itmpara_tooltip($itmpara, $itmk);
// 如果有 itmpara tooltip,添加到现有 tooltip
if(!empty($itmpara_tooltip))
{
if(!empty($info_tp)) $info_tp .= "\r";
$info_tp .= $itmpara_tooltip;
}
```
2. 同样在 `parse_itmpara_tooltip` 函数中也有调试输出
- 修改前:
```php
function parse_itmpara_tooltip($itmpara, $item_type = '')
{
global $itmpara_tooltip;
// 调试输出
$debug_output = "itmpara: ".(is_array($itmpara) ? json_encode($itmpara) : $itmpara)."\r";
$debug_output .= "item_type: {$item_type}\r";
// 如果 itmpara 为空,直接返回空字符串
if(empty($itmpara)) {
return '';
}
```
- 修改后:
```php
function parse_itmpara_tooltip($itmpara, $item_type = '')
{
global $itmpara_tooltip;
// 如果 itmpara 为空,直接返回空字符串
if(empty($itmpara)) {
return '';
}
```
3. 在 `get_itmpara` 函数中也有调试输出
- 修改前:
```php
function get_itmpara($para)
{
//echo $para, "is a ", gettype($para);
if(empty($para)) $para = Array();
if(!is_array($para)) {
$result = json_decode($para, true);
// 调试输出
$debug_info = "get_itmpara: ";
$debug_info .= "input: {$para}\r";
$debug_info .= "output: ".(is_array($result) ? json_encode($result) : $result)."\r";
//error_log($debug_info);
return $result;
} else return $para;
}
```
- 修改后:
```php
function get_itmpara($para)
{
if(empty($para)) $para = Array();
if(!is_array($para)) {
$result = json_decode($para, true);
return $result;
} else return $para;
}
```
这些修改确保了当物品具有 itmpara 字段时,其特殊属性会在 tooltip 中正确显示,不会显示调试信息。
2024年7月19日 $itmpara 字段 tooltip 显示问题修复记录(第五次)
在2024年7月19日,我们实现了 $itmpara 字段在 tooltip 中的显示功能,但在实际使用中发现了一个问题:
1. JSON 解析问题导致 itmpara 值显示不完整
- 在调试信息中,itmpara 值只显示了 "{" 而不是完整的 JSON 对象
- 实际的 itmpara 值应该是:{"AddDamageRaw":100,"AddDamagePercentage":10,"lore":"这是一件测试用的物品,起码不会按原样去桃箱。"}
- 但只显示了 "{",这可能是导致前两个键值(AddDamageRaw 和 AddDamagePercentage)不显示的原因
2. 修复 get_itmpara 函数中的 JSON 解析问题
- 修改前:
```php
function get_itmpara($para)
{
if(empty($para)) $para = Array();
if(!is_array($para)) {
$result = json_decode($para, true);
return $result;
} else return $para;
}
```
- 修改后:
```php
function get_itmpara($para)
{
if(empty($para)) $para = Array();
if(!is_array($para)) {
// 尝试修复 JSON 解析问题
// 如果字符串中包含逗号,可能会导致 JSON 解析失败
// 确保字符串是有效的 JSON
$para = trim($para);
// 检查是否是有效的 JSON 格式
if (substr($para, 0, 1) == '{' && substr($para, -1) == '}') {
$result = json_decode($para, true);
// 如果解析失败,尝试修复 JSON 字符串
if ($result === null && json_last_error() !== JSON_ERROR_NONE) {
// 尝试修复不完整的 JSON
// 如果字符串被截断,尝试添加缺失的部分
if (strpos($para, '{"') === 0 && strpos($para, '"}') === false) {
$para .= '"}'; // 添加缺失的右花括号
}
// 再次尝试解析
$result = json_decode($para, true);
}
return $result;
} else {
// 不是 JSON 格式,直接返回
return $para;
}
} else return $para;
}
```
3. 添加调试输出到 parse_itmpara_tooltip 函数
- 修改前:
```php
// 如果 itmpara 不是数组,尝试将其转换为数组
if(!is_array($itmpara)) {
$itmpara = get_itmpara($itmpara);
if(empty($itmpara)) {
return '';
}
}
```
- 修改后:
```php
// 如果 itmpara 不是数组,尝试将其转换为数组
if(!is_array($itmpara)) {
// 添加调试输出,查看原始的 itmpara 值
$debug_info = "\r\nOriginal itmpara: {$itmpara}";
$itmpara = get_itmpara($itmpara);
// 添加调试输出,查看解析后的 itmpara 值
$debug_info .= "\r\nParsed itmpara: ".(is_array($itmpara) ? json_encode($itmpara) : $itmpara);
if(empty($itmpara)) {
return $debug_info; // 返回调试信息而不是空字符串
}
}
```
4. 在 parse_itmpara_tooltip 函数的返回值中添加调试信息
- 修改前:
```php
return rtrim($tooltip, "\r");
```
- 修改后:
```php
// 添加调试信息到返回的 tooltip
if(isset($debug_info)) {
$tooltip .= $debug_info;
}
return rtrim($tooltip, "\r");
```
这些修改有助于我们了解 itmpara 字段的处理过程,找出问题所在。通过调试输出,我们可以看到 itmpara 字段的原始值和解析后的值,从而确定问题的原因。
2024年7月19日 $itmpara 字段 tooltip 显示问题修复记录(第六次)
在2024年7月19日,我们实现了 $itmpara 字段在 tooltip 中的显示功能,但在实际使用中发现了几个问题:
1. 调试信息没有显示,只显示了 lore 内容
2. 移除 lore 键值后,tooltip 完全不显示
3. 出现错误:`Invalid argument supplied for foreach() in itmpara_tooltip.func.php on line 47`
这个错误表明在 `foreach($itmpara as $key => $value)` 语句中,`$itmpara` 不是一个数组或可迭代对象,这可能是问题的根源。
修复内容:
1. 修复 `parse_itmpara_tooltip` 函数中的错误
- 添加更详细的调试信息
- 确保 `$itmpara` 始终是一个数组
- 修改前:
```php
function parse_itmpara_tooltip($itmpara, $item_type = '')
{
global $itmpara_tooltip;
// 如果 itmpara 为空,直接返回空字符串
if(empty($itmpara)) {
return '';
}
// 如果 itmpara 不是数组,尝试将其转换为数组
if(!is_array($itmpara)) {
// 添加调试输出,查看原始的 itmpara 值
$debug_info = "\r\nOriginal itmpara: {$itmpara}";
$itmpara = get_itmpara($itmpara);
// 添加调试输出,查看解析后的 itmpara 值
$debug_info .= "\r\nParsed itmpara: ".(is_array($itmpara) ? json_encode($itmpara) : $itmpara);
if(empty($itmpara)) {
return $debug_info; // 返回调试信息而不是空字符串
}
}
```
- 修改后:
```php
function parse_itmpara_tooltip($itmpara, $item_type = '')
{
global $itmpara_tooltip;
// 初始化调试信息
$debug_info = "\r\n---------- DEBUG INFO ----------";
$debug_info .= "\r\nFunction: parse_itmpara_tooltip";
$debug_info .= "\r\nInput type: " . gettype($itmpara);
$debug_info .= "\r\nInput value: " . (is_array($itmpara) ? json_encode($itmpara) : $itmpara);
$debug_info .= "\r\nItem type: {$item_type}";
// 如果 itmpara 为空,直接返回调试信息
if(empty($itmpara)) {
$debug_info .= "\r\nEmpty itmpara detected";
return $debug_info;
}
// 如果 itmpara 不是数组,尝试将其转换为数组
if(!is_array($itmpara)) {
$debug_info .= "\r\nConverting itmpara to array using get_itmpara()";
$itmpara = get_itmpara($itmpara);
$debug_info .= "\r\nAfter conversion:";
$debug_info .= "\r\n - Type: " . gettype($itmpara);
$debug_info .= "\r\n - Value: " . (is_array($itmpara) ? json_encode($itmpara) : $itmpara);
$debug_info .= "\r\n - Empty: " . (empty($itmpara) ? 'true' : 'false');
if(empty($itmpara)) {
$debug_info .= "\r\nEmpty result after conversion";
return $debug_info;
}
// 确保 $itmpara 是数组
if(!is_array($itmpara)) {
$debug_info .= "\r\nWarning: itmpara is still not an array after conversion";
$debug_info .= "\r\nForcing conversion to empty array";
$itmpara = array();
}
}
```
2. 修复 `foreach` 循环中的错误
- 添加检查确保 `$itmpara` 是数组并且不为空
- 修改前:
```php
// 处理其他键值
foreach($itmpara as $key => $value) {
// 跳过 lore,单独处理
if($key === 'lore') {
continue;
}
```
- 修改后:
```php
// 处理其他键值
$debug_info .= "\r\nProcessing itmpara keys:";
$debug_info .= "\r\n - itmpara type: " . gettype($itmpara);
$debug_info .= "\r\n - itmpara empty: " . (empty($itmpara) ? 'true' : 'false');
// 确保 $itmpara 是数组并且不为空
if(is_array($itmpara) && !empty($itmpara)) {
$debug_info .= "\r\n - Keys: " . implode(', ', array_keys($itmpara));
foreach($itmpara as $key => $value) {
$debug_info .= "\r\nProcessing key: {$key} = " . (is_array($value) ? json_encode($value) : $value);
```
3. 修复 `get_itmpara` 函数中的 JSON 解析问题
- 添加更详细的调试信息
- 添加更多的 JSON 解析错误处理
- 添加手动解析 JSON 的功能
- 修改前:
```php
function get_itmpara($para)
{
if(empty($para)) $para = Array();
if(!is_array($para)) {
// 尝试修复 JSON 解析问题
// 如果字符串中包含逗号,可能会导致 JSON 解析失败
// 确保字符串是有效的 JSON
$para = trim($para);
// 检查是否是有效的 JSON 格式
if (substr($para, 0, 1) == '{' && substr($para, -1) == '}') {
$result = json_decode($para, true);
// 如果解析失败,尝试修复 JSON 字符串
if ($result === null && json_last_error() !== JSON_ERROR_NONE) {
// 尝试修复不完整的 JSON
// 如果字符串被截断,尝试添加缺失的部分
if (strpos($para, '{"') === 0 && strpos($para, '"}') === false) {
$para .= '"}'; // 添加缺失的右花括号
}
// 再次尝试解析
$result = json_decode($para, true);
}
return $result;
} else {
// 不是 JSON 格式,直接返回
return $para;
}
} else return $para;
}
```
- 修改后:
```php
function get_itmpara($para)
{
// 记录调试信息
$debug = "get_itmpara debug:\n";
$debug .= "Input type: " . gettype($para) . "\n";
$debug .= "Input value: " . (is_string($para) ? $para : (is_array($para) ? json_encode($para) : gettype($para))) . "\n";
if(empty($para)) {
$debug .= "Empty input, returning empty array\n";
//error_log($debug);
return Array();
}
if(!is_array($para)) {
// 如果是字符串,尝试解析为 JSON
if(is_string($para)) {
$debug .= "Processing string input\n";
// 去除空白字符
$para = trim($para);
$debug .= "After trim: " . $para . "\n";
// 检查是否是 JSON 格式
if(substr($para, 0, 1) == '{' && substr($para, -1) == '}') {
$debug .= "Detected JSON format\n";
// 尝试修复可能的 JSON 格式问题
// 有时候 JSON 字符串可能被截断或损坏
// 先尝试直接解析
$result = json_decode($para, true);
$error = json_last_error();
$debug .= "First decode attempt: " . ($error === JSON_ERROR_NONE ? "success" : "failed") . "\n";
$debug .= "Error code: " . $error . "\n";
$debug .= "Error message: " . json_last_error_msg() . "\n";
// 如果解析失败,尝试修复
if($result === null && $error !== JSON_ERROR_NONE) {
$debug .= "Attempting to fix JSON string\n";
// 尝试修复常见问题
// 1. 如果是被截断的 JSON,尝试添加右花括号
if(substr_count($para, '{') > substr_count($para, '}')) {
$para .= str_repeat('}', substr_count($para, '{') - substr_count($para, '}'));
$debug .= "Added missing closing braces\n";
}
// 2. 如果有引号不匹配,尝试修复
if(substr_count($para, '"') % 2 != 0) {
$para .= '"';
$debug .= "Added missing quote\n";
}
// 3. 尝试使用替代方法解析
// 如果是简单的键值对,手动解析
if(strpos($para, '{"') === 0) {
$debug .= "Attempting manual parsing\n";
// 去除花括号
$content = substr($para, 1, -1);
$debug .= "Content without braces: " . $content . "\n";
// 尝试手动解析键值对
$manual_result = array();
// 尝试使用正则表达式提取键值对
preg_match_all('/"([^"]+)"\s*:\s*([^,}]+)/', $content, $matches);
if(!empty($matches[1]) && !empty($matches[2])) {
for($i = 0; $i < count($matches[1]); $i++) {
$key = $matches[1][$i];
$value = trim($matches[2][$i]);
// 如果值是数字
if(is_numeric($value)) {
$value = strpos($value, '.') !== false ? (float)$value : (int)$value;
}
// 如果值是字符串(带引号)
elseif(substr($value, 0, 1) == '"' && substr($value, -1) == '"') {
$value = substr($value, 1, -1);
}
$manual_result[$key] = $value;
}
}
$debug .= "Manual parsing result: " . json_encode($manual_result) . "\n";
// 如果手动解析成功,使用手动解析的结果
if(!empty($manual_result)) {
$result = $manual_result;
} else {
// 再次尝试使用 json_decode
$result = json_decode($para, true);
$debug .= "Second decode attempt: " . (json_last_error() === JSON_ERROR_NONE ? "success" : "failed") . "\n";
}
}
}
// 如果解析结果为空,返回空数组
if($result === null) {
$debug .= "Failed to parse JSON, returning empty array\n";
//error_log($debug);
return array();
}
$debug .= "Final result: " . json_encode($result) . "\n";
//error_log($debug);
return $result;
} else {
$debug .= "Not a JSON string, returning as is\n";
//error_log($debug);
return $para;
}
} else {
$debug .= "Not a string or array, returning empty array\n";
//error_log($debug);
return array();
}
} else {
$debug .= "Already an array, returning as is\n";
//error_log($debug);
return $para;
}
}
```
4. 修复 lore 处理
- 添加检查确保 `$itmpara` 是数组
- 修改前:
```php
// 最后处理 lore,如果存在则显示
if(isset($itmpara['lore'])) {
$tooltip .= $itmpara['lore'] . "\r";
}
```
- 修改后:
```php
// 最后处理 lore,如果存在则显示
if(is_array($itmpara) && isset($itmpara['lore'])) {
$debug_info .= "\r\nProcessing lore key:";
$debug_info .= "\r\n - Value: {$itmpara['lore']}";
$tooltip .= $itmpara['lore'] . "\r";
$debug_info .= "\r\n - Added lore to tooltip";
} else {
$debug_info .= "\r\nNo lore key found or itmpara is not an array";
}
```
这些修改有助于我们了解 itmpara 字段的处理过程,找出问题所在。通过详细的调试输出,我们可以看到 itmpara 字段的原始值、解析过程和最终结果,从而确定问题的原因。
2024年7月19日 $itmpara 字段 tooltip 显示问题修复记录(第七次)
在2024年7月19日,我们实现了 $itmpara 字段在 tooltip 中的显示功能,但在实际使用中发现了一个新问题:
1. tooltip 内容中的 JSON 字符串显示不正确,特别是引号 `"` 和其他特殊字符导致了 HTML 属性解析问题
2. 这是因为 tooltip 内容被直接放入了 HTML 属性中,而没有正确转义
修复内容:
1. 修复 tooltip 内容的 HTML 转义问题
- 修改前:
```php
if(!empty($info_f)) $info_f = "class=\"{$info_f}\"";
if(!empty($info_tp)) $info_tp = "{$ttypes}=\"{$info_tp}\"";
$info = "<span {$info_f} {$info_tp}>{$info}</span>";
```
- 修改后:
```php
if(!empty($info_f)) $info_f = "class=\"{$info_f}\"";
// 对 tooltip 内容进行 HTML 转义
if(!empty($info_tp)) {
// 使用 htmlspecialchars 进行 HTML 转义
$escaped_tp = htmlspecialchars($info_tp, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$info_tp = "{$ttypes}=\"{$escaped_tp}\"";
}
$info = "<span {$info_f} {$info_tp}>{$info}</span>";
```
2. 修复 JSON 解析和显示问题
- 在 `parse_itmpara_tooltip` 函数中,添加了安全处理 JSON 输出的代码
- 修改前:
```php
// 初始化调试信息
$debug_info = "\r\n---------- DEBUG INFO ----------";
$debug_info .= "\r\nFunction: parse_itmpara_tooltip";
$debug_info .= "\r\nInput type: " . gettype($itmpara);
$debug_info .= "\r\nInput value: " . (is_array($itmpara) ? json_encode($itmpara) : $itmpara);
$debug_info .= "\r\nItem type: {$item_type}";
```
- 修改后:
```php
// 初始化调试信息
$debug_info = "\r\n---------- DEBUG INFO ----------";
$debug_info .= "\r\nFunction: parse_itmpara_tooltip";
$debug_info .= "\r\nInput type: " . gettype($itmpara);
// 安全地处理 JSON 输出
if(is_array($itmpara)) {
// 使用 JSON_UNESCAPED_UNICODE 确保中文显示正常
$json_str = json_encode($itmpara, JSON_UNESCAPED_UNICODE);
$debug_info .= "\r\nInput value: " . $json_str;
} else {
$debug_info .= "\r\nInput value: " . $itmpara;
}
$debug_info .= "\r\nItem type: {$item_type}";
```
3. 修复 `foreach` 循环中的值输出
- 修改前:
```php
foreach($itmpara as $key => $value) {
$debug_info .= "\r\nProcessing key: {$key} = " . (is_array($value) ? json_encode($value) : $value);
```
- 修改后:
```php
foreach($itmpara as $key => $value) {
// 安全地处理值的输出
if(is_array($value)) {
$value_str = json_encode($value, JSON_UNESCAPED_UNICODE);
} else {
$value_str = $value;
}
$debug_info .= "\r\nProcessing key: {$key} = " . $value_str;
```
这些修改确保了 tooltip 内容中的特殊字符(如引号、尖括号等)能够正确显示,不会导致 HTML 解析错误。同时,使用 `JSON_UNESCAPED_UNICODE` 确保中文字符能够正确显示。
2024年7月19日 $itmpara 字段 tooltip 配置问题修复记录(第八次)
在2024年7月19日,我们实现了 $itmpara 字段在 tooltip 中的显示功能,但在实际使用中发现了一个新问题:
1. tooltip 内容中显示 "No tooltip config found for key: AddDamageRaw" 和 "No tooltip config found for key: AddDamagePercentage"
2. 这表明系统无法找到 AddDamageRaw 和 AddDamagePercentage 这两个键的配置信息
3. 经过检查,发现问题是键名大小写不匹配:在 tooltip 配置中,键名是 "AddDamageRaw" 和 "AddDamagePercentage",但在 JSON 数据中,键名是 "adddamageraw" 和 "adddamagepercentage"(小写)
修复内容:
1. 修复键名大小写不匹配问题
- 添加了多种键名匹配方式,包括直接匹配、首字母大写、全大写、全小写和驼峰式
- 修改前:
```php
// 检查是否有对应的 tooltip 配置
if(isset($itmpara_tooltip[$key])) {
$debug_info .= "\r\n - Found tooltip config for key: {$key}";
$config = $itmpara_tooltip[$key];
```
- 修改后:
```php
// 检查是否有对应的 tooltip 配置
// 先尝试直接匹配
if(isset($itmpara_tooltip[$key])) {
$debug_info .= "\r\n - Found tooltip config for key: {$key}";
$config = $itmpara_tooltip[$key];
}
// 如果没有找到,尝试将键名转换为首字母大写的形式
elseif(isset($itmpara_tooltip[ucfirst($key)])) {
$debug_info .= "\r\n - Found tooltip config for key (case-insensitive): {$key} -> " . ucfirst($key);
$config = $itmpara_tooltip[ucfirst($key)];
}
// 如果还是没有找到,尝试将键名转换为全大写的形式
elseif(isset($itmpara_tooltip[strtoupper($key)])) {
$debug_info .= "\r\n - Found tooltip config for key (uppercase): {$key} -> " . strtoupper($key);
$config = $itmpara_tooltip[strtoupper($key)];
}
// 如果还是没有找到,尝试将键名转换为全小写的形式
elseif(isset($itmpara_tooltip[strtolower($key)])) {
$debug_info .= "\r\n - Found tooltip config for key (lowercase): {$key} -> " . strtolower($key);
$config = $itmpara_tooltip[strtolower($key)];
}
// 如果还是没有找到,尝试将键名转换为驼峰式的形式
else {
// 尝试将键名转换为驼峰式
$camelKey = preg_replace_callback('/(^|_)([a-z])/', function($matches) {
return strtoupper($matches[2]);
}, $key);
if(isset($itmpara_tooltip[$camelKey])) {
$debug_info .= "\r\n - Found tooltip config for key (camelCase): {$key} -> {$camelKey}";
$config = $itmpara_tooltip[$camelKey];
} else {
$debug_info .= "\r\n - No tooltip config found for key: {$key}";
continue;
}
}
```
2. 修复代码结构问题
- 修复了代码缩进和结构问题,确保代码逻辑清晰
- 移除了多余的 else 语句,避免代码嵌套过深
这些修改确保了系统能够正确匹配 itmpara 字段中的键名,即使键名的大小写不一致。这样,AddDamageRaw 和 AddDamagePercentage 等属性就能够正确显示在 tooltip 中。
2024年7月19日 $itmpara 字段 tooltip 配置问题修复记录(第九次)
在2024年7月19日,我们实现了 $itmpara 字段在 tooltip 中的显示功能,但在实际使用中发现了一个新问题:
1. 之前的修复似乎没有生效,tooltip 内容中仍然显示 "No tooltip config found for key: AddDamageRaw" 和 "No tooltip config found for key: AddDamagePercentage"
2. 这表明系统仍然无法找到 AddDamageRaw 和 AddDamagePercentage 这两个键的配置信息
修复内容:
1. 添加更详细的调试信息,以便更好地理解问题
- 输出每个键的类型和值
- 修改前:
```php
// 安全地处理 JSON 输出
if(is_array($itmpara)) {
// 使用 JSON_UNESCAPED_UNICODE 确保中文显示正常
$json_str = json_encode($itmpara, JSON_UNESCAPED_UNICODE);
$debug_info .= "\r\nInput value: " . $json_str;
} else {
$debug_info .= "\r\nInput value: " . $itmpara;
}
```
- 修改后:
```php
// 安全地处理 JSON 输出
if(is_array($itmpara)) {
// 使用 JSON_UNESCAPED_UNICODE 确保中文显示正常
$json_str = json_encode($itmpara, JSON_UNESCAPED_UNICODE);
$debug_info .= "\r\nInput value: " . $json_str;
// 输出每个键的类型和值
$debug_info .= "\r\nDetailed key info:";
foreach($itmpara as $k => $v) {
$debug_info .= "\r\n - Key: '{$k}' (" . gettype($k) . ")";
$debug_info .= "\r\n Value: '" . (is_array($v) ? json_encode($v, JSON_UNESCAPED_UNICODE) : $v) . "' (" . gettype($v) . ")";
}
} else {
$debug_info .= "\r\nInput value: " . $itmpara;
}
```
2. 改进键名匹配逻辑,添加更多调试信息
- 输出所有可用的配置键
- 输出每种匹配方式的结果
- 添加大小写不敏感的匹配(使用 strcasecmp)
- 修改前:
```php
// 检查是否有对应的 tooltip 配置
// 先尝试直接匹配
if(isset($itmpara_tooltip[$key])) {
$debug_info .= "\r\n - Found tooltip config for key: {$key}";
$config = $itmpara_tooltip[$key];
}
// 如果没有找到,尝试将键名转换为首字母大写的形式
elseif(isset($itmpara_tooltip[ucfirst($key)])) {
$debug_info .= "\r\n - Found tooltip config for key (case-insensitive): {$key} -> " . ucfirst($key);
$config = $itmpara_tooltip[ucfirst($key)];
}
// 如果还是没有找到,尝试将键名转换为全大写的形式
elseif(isset($itmpara_tooltip[strtoupper($key)])) {
$debug_info .= "\r\n - Found tooltip config for key (uppercase): {$key} -> " . strtoupper($key);
$config = $itmpara_tooltip[strtoupper($key)];
}
// 如果还是没有找到,尝试将键名转换为全小写的形式
elseif(isset($itmpara_tooltip[strtolower($key)])) {
$debug_info .= "\r\n - Found tooltip config for key (lowercase): {$key} -> " . strtolower($key);
$config = $itmpara_tooltip[strtolower($key)];
}
// 如果还是没有找到,尝试将键名转换为驼峰式的形式
else {
// 尝试将键名转换为驼峰式
$camelKey = preg_replace_callback('/(^|_)([a-z])/', function($matches) {
return strtoupper($matches[2]);
}, $key);
if(isset($itmpara_tooltip[$camelKey])) {
$debug_info .= "\r\n - Found tooltip config for key (camelCase): {$key} -> {$camelKey}";
$config = $itmpara_tooltip[$camelKey];
} else {
$debug_info .= "\r\n - No tooltip config found for key: {$key}";
continue;
}
}
```
- 修改后:
```php
// 检查是否有对应的 tooltip 配置
// 输出所有可用的配置键
$debug_info .= "\r\n - Available tooltip config keys: " . implode(', ', array_keys($itmpara_tooltip));
// 先尝试直接匹配
$debug_info .= "\r\n - Direct match check: isset(\$itmpara_tooltip['{$key}']) = " . (isset($itmpara_tooltip[$key]) ? 'true' : 'false');
if(isset($itmpara_tooltip[$key])) {
$debug_info .= "\r\n - Found tooltip config for key: {$key}";
$config = $itmpara_tooltip[$key];
}
// 如果没有找到,尝试将键名转换为首字母大写的形式
else {
$ucfirstKey = ucfirst($key);
$debug_info .= "\r\n - Ucfirst match check: isset(\$itmpara_tooltip['{$ucfirstKey}']) = " . (isset($itmpara_tooltip[$ucfirstKey]) ? 'true' : 'false');
if(isset($itmpara_tooltip[$ucfirstKey])) {
$debug_info .= "\r\n - Found tooltip config for key (ucfirst): {$key} -> {$ucfirstKey}";
$config = $itmpara_tooltip[$ucfirstKey];
}
// 如果还是没有找到,尝试将键名转换为全大写的形式
else {
$upperKey = strtoupper($key);
$debug_info .= "\r\n - Uppercase match check: isset(\$itmpara_tooltip['{$upperKey}']) = " . (isset($itmpara_tooltip[$upperKey]) ? 'true' : 'false');
if(isset($itmpara_tooltip[$upperKey])) {
$debug_info .= "\r\n - Found tooltip config for key (uppercase): {$key} -> {$upperKey}";
$config = $itmpara_tooltip[$upperKey];
}
// 如果还是没有找到,尝试将键名转换为全小写的形式
else {
$lowerKey = strtolower($key);
$debug_info .= "\r\n - Lowercase match check: isset(\$itmpara_tooltip['{$lowerKey}']) = " . (isset($itmpara_tooltip[$lowerKey]) ? 'true' : 'false');
if(isset($itmpara_tooltip[$lowerKey])) {
$debug_info .= "\r\n - Found tooltip config for key (lowercase): {$key} -> {$lowerKey}";
$config = $itmpara_tooltip[$lowerKey];
}
// 如果还是没有找到,尝试将键名转换为驼峰式的形式
else {
// 尝试将键名转换为驼峰式
$camelKey = preg_replace_callback('/(^|_)([a-z])/', function($matches) {
return strtoupper($matches[2]);
}, $key);
$debug_info .= "\r\n - CamelCase match check: isset(\$itmpara_tooltip['{$camelKey}']) = " . (isset($itmpara_tooltip[$camelKey]) ? 'true' : 'false');
if(isset($itmpara_tooltip[$camelKey])) {
$debug_info .= "\r\n - Found tooltip config for key (camelCase): {$key} -> {$camelKey}";
$config = $itmpara_tooltip[$camelKey];
}
// 如果还是没有找到,尝试在所有键中进行大小写不敏感的匹配
else {
$found = false;
foreach(array_keys($itmpara_tooltip) as $configKey) {
if(strcasecmp($configKey, $key) === 0) {
$debug_info .= "\r\n - Found tooltip config for key (strcasecmp): {$key} -> {$configKey}";
$config = $itmpara_tooltip[$configKey];
$found = true;
break;
}
}
if(!$found) {
$debug_info .= "\r\n - No tooltip config found for key: {$key}";
continue;
}
}
}
}
}
}
```
这些修改添加了更详细的调试信息,以便更好地理解问题。通过输出每个键的类型和值,以及每种匹配方式的结果,我们可以更清楚地看到问题所在。此外,我们还添加了大小写不敏感的匹配(使用 strcasecmp),以便更灵活地匹配键名。
2024年7月19日 $itmpara 字段 tooltip 显示实现记录
在2024年7月19日,游戏中的物品添加了新的字段$itmpara,该字段为一数组,可让物品有着数组中定义的键值的属性。
现在,我们实现了 $itmpara 字段在 tooltip 中的显示功能,使玩家可以直观地了解物品的特殊属性。
以下是对应此功能的实现记录:
1. 创建 itmpara 的 tooltip 配置文件
- 创建了 gamedata\cache\itmpara_tooltip.php 文件,定义了 $itmpara 字段中各个键值对应的 tooltip 显示内容
- 配置文件使用数组格式,每个键值对应一个数组,包含标题、格式、后缀、颜色和条件函数
- 条件函数用于判断是否显示该键值,例如只在武器上显示伤害增加属性
2. 创建处理 itmpara tooltip 的函数
- 创建了 include\game\itmpara_tooltip.func.php 文件,定义了 parse_itmpara_tooltip 和 add_itmpara_tooltip_to_item 函数
- parse_itmpara_tooltip 函数用于解析 itmpara 字段,生成 tooltip 内容
- add_itmpara_tooltip_to_item 函数用于将 itmpara tooltip 添加到物品名称上
3. 修改 parse_nameinfo_desc 函数
- 修改了 include\global.func.php 文件中的 parse_nameinfo_desc 函数,使其支持 itmpara tooltip
- 添加了 itmpara 和 itmk 参数,用于传递 itmpara 字段和物品类型
- 在函数中引入 itmpara_tooltip.func.php 和 itmpara_tooltip.php 文件,解析 itmpara 字段
4. 修改调用 parse_nameinfo_desc 函数的地方
- 修改了 include\game.func.php 文件中的 init_profile 函数
- 修改了 include\game\battle.func.php 文件中的 findcorpse 函数
- 修改了 include\game\itemplace.func.php 文件中的 get_npc_helpinfo 函数
- 修改了 include\vnworld\vnmix.func.php 文件中的 parse_queue_vnmix_info 函数
- 确保在调用 parse_nameinfo_desc 函数时传递 itmpara 参数
5. 实现的功能
- 根据 itmpara 中的键值,显示反应其用途的对应文本
- 例如:{"AddDamageRaw":100,"AddDamagePercentage":10} 会显示为:
最终伤害增加:100
最终伤害增加:10%
- 如果一个物品的 itmpara 中有 lore 值,则直接输出该键值中的字符串到 tooltip
6. 配置文件的扩展性
- 由于 itmpara 键值必然会在之后不断增多,配置文件设计为易于扩展
- 可以通过简单地添加新的键值配置,来支持新的 itmpara 键值
- 配置文件中详细注释了每个配置项的作用和格式
这些修改确保了当物品具有 itmpara 字段时,其特殊属性会在 tooltip 中显示,使玩家可以直观地了解物品的特殊属性。
2024年7月19日 $itmpara 字段 tooltip 功能实现总结
## 功能概述
实现了 $itmpara 字段在 tooltip 中的显示功能,使玩家能够看到物品的特殊属性,如伤害增加、防御增加等。
## 实现细节
1. 创建了 `itmpara_tooltip.func.php` 文件,包含以下函数:
- `parse_itmpara_tooltip($itmpara, $item_type = '')` - 解析 itmpara 字段并生成 tooltip 内容
- `add_itmpara_tooltip_to_item($item_name, $itmpara, $item_type = '', $existing_tooltip = '')` - 为物品名称添加 tooltip
- `get_itmpara($para)` - 将 itmpara 字符串转换为数组
2. 创建了 `itmpara_tooltip.php` 配置文件,包含各种 itmpara 键的显示配置:
- 每个键对应一个配置数组,包含标题、格式、后缀、颜色和条件
- 支持的键包括 AddDamageRaw、AddDamagePercentage、lore 等
3. 修改了 `global.func.php` 文件,在 `parse_nameinfo_desc` 函数中添加了对 itmpara tooltip 的支持
4. 添加了调试功能:
- 详细的调试信息,显示 itmpara 的解析过程和结果
- 调试信息仅在玩家的 $clbpara['SetItmparaDebug'] 为 true 时显示
- 添加了 "itmpara调试开关" 物品,用于切换调试模式
## 遇到的问题和解决方案
1. JSON 解析问题:
- 问题:itmpara 字段中的 JSON 字符串可能被截断或格式不正确
- 解决方案:添加了更健壮的 JSON 解析逻辑,包括手动解析和错误处理
2. 键名大小写问题:
- 问题:配置文件中的键名和 JSON 数据中的键名大小写不一致
- 解决方案:添加了多种键名匹配方式,包括直接匹配、首字母大写、全大写、全小写和驼峰式
3. HTML 转义问题:
- 问题:tooltip 内容中的特殊字符(如引号、尖括号)导致 HTML 解析错误
- 解决方案:使用 htmlspecialchars 函数对 tooltip 内容进行 HTML 转义
4. 配置文件加载问题:
- 问题:$itmpara_tooltip 数组没有被正确加载
- 解决方案:直接在函数中定义默认的 $itmpara_tooltip 数组,确保它始终有值
## 使用方法
1. 为物品添加 itmpara 字段:
```php
$itmpara = '{"AddDamageRaw":100,"AddDamagePercentage":10,"lore":"这是一件测试用的物品"}';
```
2. 在物品名称中显示 tooltip:
```php
$item_name = add_itmpara_tooltip_to_item($item_name, $itmpara, $item_type);
```
3. 开启/关闭调试模式:
- 使用 "itmpara调试开关" 物品切换调试模式
- 调试模式下,tooltip 中会显示详细的调试信息
## 后续改进
1. 添加更多的 itmpara 键支持,如防御增加、属性抗性等
2. 优化 tooltip 显示效果,如添加图标、颜色等
3. 添加更多的调试功能,如显示物品的所有属性
4. 考虑将 itmpara 字段的处理逻辑移到专门的文件中,以便更好地组织代码
<?php
if(!defined('IN_GAME')) exit('Access Denied');
/**
* itmpara 字段的 tooltip 配置文件
*
* 本文件定义了 itmpara 字段中各个键值对应的 tooltip 显示内容
*
* 格式说明:
* $itmpara_tooltip 数组的键为 itmpara 中的键名
* 值为一个数组,包含以下元素:
* - 'title':显示的标题,如果为空则不显示标题
* - 'format':显示的格式,使用 {value} 作为占位符,会被实际值替换
* - 'suffix':值的后缀,如 '%'、'点' 等
* - 'color':显示的颜色,可选,默认为空
* - 'condition':条件函数,接收 $item_type 和 $value 两个参数,返回 true 表示显示,false 表示不显示
*
* 示例:
* 'AddDamageRaw' => [
* 'title' => '最终伤害增加',
* 'format' => '{value}',
* 'suffix' => '',
* 'color' => 'red',
* 'condition' => function($item_type, $value) {
* return $item_type == 'W' || $item_type == 'D';
* }
* ]
*/
$itmpara_tooltip = [
// 伤害相关
'AddDamageRaw' => [
'title' => '最终伤害增加',
'format' => '{value}',
'suffix' => '',
'color' => 'red',
'condition' => function($item_type, $value) {
// 如果是测试物品,则始终显示
if(strpos($item_type, '测试') !== false) {
return true;
}
return $item_type == 'W' || $item_type == 'D';
}
],
'AddDamagePercentage' => [
'title' => '最终伤害增加',
'format' => '{value}',
'suffix' => '%',
'color' => 'red',
'condition' => function($item_type, $value) {
// 如果是测试物品,则始终显示
if(strpos($item_type, '测试') !== false) {
return true;
}
return $item_type == 'W' || $item_type == 'D';
}
],
'DecreaseDamageRaw' => [
'title' => '最终伤害减少',
'format' => '{value}',
'suffix' => '',
'color' => 'blue',
'condition' => function($item_type, $value) {
return $item_type == 'A' || $item_type == 'D';
}
],
'DecreaseDamagePercentage' => [
'title' => '最终伤害减少',
'format' => '{value}',
'suffix' => '%',
'color' => 'blue',
'condition' => function($item_type, $value) {
return $item_type == 'A' || $item_type == 'D';
}
],
// 战斗中属性增加
'AddPlayerMhpInCombat' => [
'title' => '战斗中生命上限增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerMspInCombat' => [
'title' => '战斗中体力上限增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerMssInCombat' => [
'title' => '战斗中灵力上限增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerAttInCombat' => [
'title' => '战斗中攻击力增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerDefInCombat' => [
'title' => '战斗中防御力增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerWpInCombat' => [
'title' => '战斗中殴系熟练度增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerWkInCombat' => [
'title' => '战斗中斩系熟练度增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerWgInCombat' => [
'title' => '战斗中射系熟练度增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerWcInCombat' => [
'title' => '战斗中投系熟练度增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerWdInCombat' => [
'title' => '战斗中爆系熟练度增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerWfInCombat' => [
'title' => '战斗中灵系熟练度增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerMoneyInCombat' => [
'title' => '战斗中金钱增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerRageInCombat' => [
'title' => '战斗中怒气增加',
'format' => '{value}',
'suffix' => '',
'color' => 'yellow',
'condition' => function($item_type, $value) {
return true;
}
],
// 搜索/移动中属性增加
'AddPlayerMhpInSearchMove' => [
'title' => '搜索/移动中生命上限增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerMspInSearchMove' => [
'title' => '搜索/移动中体力上限增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerMssInSearchMove' => [
'title' => '搜索/移动中灵力上限增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerAttInSearchMove' => [
'title' => '搜索/移动中攻击力增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerDefInSearchMove' => [
'title' => '搜索/移动中防御力增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerWpInSearchMove' => [
'title' => '搜索/移动中殴系熟练度增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerWkInSearchMove' => [
'title' => '搜索/移动中斩系熟练度增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerWgInSearchMove' => [
'title' => '搜索/移动中射系熟练度增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerWcInSearchMove' => [
'title' => '搜索/移动中投系熟练度增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerWdInSearchMove' => [
'title' => '搜索/移动中爆系熟练度增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerWfInSearchMove' => [
'title' => '搜索/移动中灵系熟练度增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerMoneyInSearchMove' => [
'title' => '搜索/移动中金钱增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
'AddPlayerRageInSearchMove' => [
'title' => '搜索/移动中怒气增加',
'format' => '{value}',
'suffix' => '',
'color' => 'green',
'condition' => function($item_type, $value) {
return true;
}
],
// 平台物品相关
'IsPlatformItem' => [
'title' => '平台物品',
'format' => '此物品可以变身为特定角色',
'suffix' => '',
'color' => 'purple',
'condition' => function($item_type, $value) {
return $value == 1;
}
],
'PlatformIsTimed' => [
'title' => '限时变身',
'format' => '变身效果会随着时间消失',
'suffix' => '',
'color' => 'purple',
'condition' => function($item_type, $value) {
return $value == 1;
}
],
'PlatformChargeBaseValue' => [
'title' => '变身持续时间',
'format' => '{value}',
'suffix' => '回合',
'color' => 'purple',
'condition' => function($item_type, $value) {
return true;
}
],
// 任务物品相关
'IsQuestItem' => [
'title' => '任务物品',
'format' => '此物品与任务相关',
'suffix' => '',
'color' => 'orange',
'condition' => function($item_type, $value) {
return $value == 1;
}
],
// lore 特殊处理,直接显示内容
'lore' => [
'title' => '',
'format' => '{value}',
'suffix' => '',
'color' => 'lore',
'condition' => function($item_type, $value) {
return true;
}
],
];
......@@ -19,10 +19,10 @@ function init_playerdata($data=NULL)
$upexp = round(($lvl*$baseexp)+(($lvl+1)*$baseexp));
$lvlupexp = $upexp - $exp;
$iconImg = $gd.'_'.$icon.'.gif';
if(file_exists('img/'.$gd.'_'.$icon.'a.gif')) $iconImgB = $gd.'_'.$icon.'a.gif';
$iconImg = $gd.'_'.$icon.'.gif';
if(file_exists('img/'.$gd.'_'.$icon.'a.gif')) $iconImgB = $gd.'_'.$icon.'a.gif';
if(($weather == 8)||($weather == 9)||($weather == 12))
if(($weather == 8)||($weather == 9)||($weather == 12))
{
$fog = true;
}
......@@ -42,7 +42,7 @@ function init_profile($data=NULL)
}
extract($data,EXTR_REFS);
foreach (Array('wep','arb','arh','ara','arf','art','itm0','itm1','itm2','itm3','itm4','itm5','itm6') as $value)
foreach (Array('wep','arb','arh','ara','arf','art','itm0','itm1','itm2','itm3','itm4','itm5','itm6') as $value)
{
if(strpos($value,'itm')!==false)
{
......@@ -50,7 +50,7 @@ function init_profile($data=NULL)
$s_value = str_replace('itm','itms',$value);
$sk_value = str_replace('itm','itmsk',$value);
}
else
else
{
$k_value = $value.'k';
$s_value = $value.'s';
......@@ -60,7 +60,15 @@ function init_profile($data=NULL)
global ${$value.'_words'},${$k_value.'_words'},${$s_value.'_words'},${$sk_value.'_words'};
# 初始化名称样式
${$value.'_words'} = parse_nameinfo_desc($$value,$horizon);
// 判断是背包栏物品还是装备栏物品
if(strpos($value,'itm')!==false) {
// 背包栏物品的 itmpara 字段名称为 itmpara0、itmpara1 等
$para_value = 'itmpara'.substr($value, 3);
} else {
// 装备栏物品的 itmpara 字段名称为 weppara、arbpara 等
$para_value = $value.'para';
}
${$value.'_words'} = parse_nameinfo_desc($$value, $horizon, '', '', isset($$para_value) ? $$para_value : '', $$k_value);
# 初始化类别样式
${$k_value.'_words'} = parse_kinfo_desc($$k_value,$$sk_value);
# 初始化属性样式
......@@ -77,7 +85,7 @@ function init_profile($data=NULL)
} elseif($hp <= $mhp*0.5){
$hpcolor = 'yellow';
}
if($sp <= $msp*0.2){
$spcolor = 'grey';
} elseif($sp <= $msp*0.5){
......@@ -85,7 +93,7 @@ function init_profile($data=NULL)
} else {
$spcolor = 'clan';
}
$newhppre = 5+floor(151*(1-$hp/$mhp));
$newhpimg = '<img src="img/red2.gif" style="position:absolute; clip:rect('.$newhppre.'px,55px,160px,0px);">';
$newsppre = 5+floor(151*(1-$sp/$msp));
......@@ -125,7 +133,7 @@ function init_bgm($force_update=0)
{
global $command,$gamecfg,$bgmname;
global $default_volume,$event_bgm,$pls_bgm,$parea_bgm,$regular_bgm,$bgmbook,$bgmlist;
global $pdata;
extract($pdata,EXTR_REFS);
$clbpara = get_clbpara($clbpara);
......@@ -170,7 +178,7 @@ function init_bgm($force_update=0)
# 刷新页面或输入强制重载参数时,重载播放器
if($command == 'enter' || $force_update)
{
$booklist = $bgmarr = Array();
$booklist = $bgmarr = Array();
# 为播放列表中的曲集关联对应BGM名、链接与种类
foreach($clbpara['bgmbook'] as $book)
{
......@@ -240,7 +248,7 @@ function init_mapdata(){
$mpp[$position[0]][$position[1]]=$i;
}
$mapcontent = '<TABLE border="1" cellspacing="0" cellpadding="0" background="map/neomap.jpg" style="background-size:478px 418px;position:relative;background-repeat:no-repeat;background-position:right bottom;">';
$mapcontent = '<TABLE border="1" cellspacing="0" cellpadding="0" background="map/neomap.jpg" style="background-size:478px 418px;position:relative;background-repeat:no-repeat;background-position:right bottom;">';
$mapcontent .= '<TR align="center"><TD colspan="11" height="24" class=b1 align=center>战场地图</TD></TR>';
$mapcontent .= '<TR align="center">
<TD width="42" height="36" class=map align=center><div class=nttx>坐标</div></TD>';
......@@ -312,15 +320,15 @@ function check_add_searchmemory($id,$itp,$nm,&$data=NULL)
{
if($sm[0] == $id && $sm[1] == $itp)
{
$log .= "<span class='grey'>{$nm_desc}本来就在你的视野里,不过这回你对它的印象更深了。</span><br>";
$log .= "<span class='grey'>{$nm_desc}本来就在你的视野里,不过这回你对它的印象更深了。</span><br>";
lost_searchmemory($sid,$data);
$flag = 1;
break;
}
}
}
}
array_push($data['clbpara']['smeo'], Array($id,$itp,$nm));
if(!$flag) $log .= "<span class='grey'>你设法将{$nm_desc}保持在视野范围内。</span><br>";
if(!$flag) $log .= "<span class='grey'>你设法将{$nm_desc}保持在视野范围内。</span><br>";
}
return;
}
......@@ -365,7 +373,7 @@ function get_remaincdtime($pid){
return floor($rmtime);
}else{
return 0;
}
}
}
// 检查时效性技能是否达到时限
......@@ -388,7 +396,7 @@ function check_skilllasttimes(&$data)
{
$log.="<span class='yellow'>「{$sk_name}」</span>的效果结束了!<br>";
}
else
else
{
$log.="{$nm}从<span class='yellow'>「{$sk_name}」</span>状态中恢复了!<br>";
}
......@@ -509,7 +517,7 @@ function get_safe_plslist($mode=1)
/*function w_save($id){
global $db,$tablepre,$w_name,$w_pass,$w_type,$w_endtime,$w_deathtime,$w_gd,$w_sNo,$w_icon,$w_club,$w_hp,$w_mhp,$w_sp,$w_msp,$w_att,$w_def,$w_pls,$w_lvl,$w_exp,$w_money,$w_bid,$w_inf,$w_rage,$w_pose,$w_tactic,$w_killnum,$w_state,$w_wp,$w_wk,$w_wg,$w_wc,$w_wd,$w_wf,$w_teamID,$w_teamPass,$w_wep,$w_wepk,$w_wepe,$w_weps,$w_arb,$w_arbk,$w_arbe,$w_arbs,$w_arh,$w_arhk,$w_arhe,$w_arhs,$w_ara,$w_arak,$w_arae,$w_aras,$w_arf,$w_arfk,$w_arfe,$w_arfs,$w_art,$w_artk,$w_arte,$w_arts,$w_itm0,$w_itmk0,$w_itme0,$w_itms0,$w_itm1,$w_itmk1,$w_itme1,$w_itms1,$w_itm2,$w_itmk2,$w_itme2,$w_itms2,$w_itm3,$w_itmk3,$w_itme3,$w_itms3,$w_itm4,$w_itmk4,$w_itme4,$w_itms4,$w_itm5,$w_itmk5,$w_itme5,$w_itms5,$w_itm6,$w_itmk6,$w_itme6,$w_itms6,$w_wepsk,$w_arbsk,$w_arhsk,$w_arask,$w_arfsk,$w_artsk,$w_itmsk0,$w_itmsk1,$w_itmsk2,$w_itmsk3,$w_itmsk4,$w_itmsk5,$w_itmsk6,$w_rp,$w_action,$w_achievement,$w_skillpoint;
$db->query("UPDATE {$tablepre}players SET name='$w_name',pass='$w_pass',type='$w_type',endtime='$w_endtime',deathtime='$w_deathtime',gd='$w_gd',sNo='$w_sNo',icon='$w_icon',club='$w_club',hp='$w_hp',mhp='$w_mhp',sp='$w_sp',msp='$w_msp',att='$w_att',def='$w_def',pls='$w_pls',lvl='$w_lvl',exp='$w_exp',money='$w_money',bid='$w_bid',inf='$w_inf',rage='$w_rage',pose='$w_pose',tactic='$w_tactic',state='$w_state',killnum='$w_killnum',action='$w_action',wp='$w_wp',wk='$w_wk',wg='$w_wg',wc='$w_wc',wd='$w_wd',wf='$w_wf',teamID='$w_teamID',teamPass='$w_teamPass',wep='$w_wep',wepk='$w_wepk',wepe='$w_wepe',weps='$w_weps',wepsk='$w_wepsk',arb='$w_arb',arbk='$w_arbk',arbe='$w_arbe',arbs='$w_arbs',arbsk='$w_arbsk',arh='$w_arh',arhk='$w_arhk',arhe='$w_arhe',arhs='$w_arhs',arhsk='$w_arhsk',ara='$w_ara',arak='$w_arak',arae='$w_arae',aras='$w_aras',arask='$w_arask',arf='$w_arf',arfk='$w_arfk',arfe='$w_arfe',arfs='$w_arfs',arfsk='$w_arfsk',art='$w_art',artk='$w_artk',arte='$w_arte',arts='$w_arts',artsk='$w_artsk',itm0='$w_itm0',itmk0='$w_itmk0',itme0='$w_itme0',itms0='$w_itms0',itmsk0='$w_itmsk0',itm1='$w_itm1',itmk1='$w_itmk1',itme1='$w_itme1',itms1='$w_itms1',itmsk1='$w_itmsk1',itm2='$w_itm2',itmk2='$w_itmk2',itme2='$w_itme2',itms2='$w_itms2',itmsk2='$w_itmsk2',itm3='$w_itm3',itmk3='$w_itmk3',itme3='$w_itme3',itms3='$w_itms3',itmsk3='$w_itmsk3',itm4='$w_itm4',itmk4='$w_itmk4',itme4='$w_itme4',itms4='$w_itms4',itmsk4='$w_itmsk4',itm5='$w_itm5',itmk5='$w_itmk5',itme5='$w_itme5',itms5='$w_itms5',itmsk5='$w_itmsk5',itm6='$w_itm6',itmk6='$w_itmk6',itme6='$w_itme6',itms6='$w_itms6',itmsk6='$w_itmsk6',rp='$w_rp',achievement='$w_achievement',skillpoint='$w_skillpoint' WHERE pid='$id'");
//$db->query("UPDATE {$tablepre}players SET name='$w_name',pass='$w_pass',type='$w_type',endtime='$w_endtime',gd='$w_gd',sNo='$w_sNo',icon='$w_icon',club='$w_club',hp='$w_hp',mhp='$w_mhp',sp='$w_sp',msp='$w_msp',att='$w_att',def='$w_def',pls='$w_pls',lvl='$w_lvl',exp='$w_exp',money='$w_money',bid='$w_bid',inf='$w_inf',rage='$w_rage',pose='$w_pose',tactic='$w_tactic',state='$w_state',killnum='$w_killnum',wp='$w_wp',wk='$w_wk',wg='$w_wg',wc='$w_wc',wd='$w_wd',wf='$w_wf',teamID='$w_teamID',teamPass='$w_teamPass',wep='$w_wep',wepk='$w_wepk',wepe='$w_wepe',weps='$w_weps',wepsk='$w_wepsk',arb='$w_arb',arbk='$w_arbk',arbe='$w_arbe',arbs='$w_arbs',arbsk='$w_arbsk',arh='$w_arh',arhk='$w_arhk',arhe='$w_arhe',arhs='$w_arhs',arhsk='$w_arhsk',ara='$w_ara',arak='$w_arak',arae='$w_arae',aras='$w_aras',arask='$w_arask',arf='$w_arf',arfk='$w_arfk',arfe='$w_arfe',arfs='$w_arfs',arfsk='$w_arfsk',art='$w_art',artk='$w_artk',arte='$w_arte',arts='$w_arts',artsk='$w_artsk',itm0='$w_itm0',itmk0='$w_itmk0',itme0='$w_itme0',itms0='$w_itms0',itmsk0='$w_itmsk0',itm1='$w_itm1',itmk1='$w_itmk1',itme1='$w_itme1',itms1='$w_itms1',itmsk1='$w_itmsk1',itm2='$w_itm2',itmk2='$w_itmk2',itme2='$w_itme2',itms2='$w_itms2',itmsk2='$w_itmsk2',itm3='$w_itm3',itmk3='$w_itmk3',itme3='$w_itme3',itms3='$w_itms3',itmsk3='$w_itmsk3',itm4='$w_itm4',itmk4='$w_itmk4',itme4='$w_itme4',itms4='$w_itms4',itmsk4='$w_itmsk4',itm5='$w_itm5',itmk5='$w_itmk5',itme5='$w_itme5',itms5='$w_itms5',itmsk5='$w_itmsk5',itm6='$w_itm6',itmk6='$w_itmk6',itme6='$w_itme6',itms6='$w_itms6',itmsk6='$w_itmsk6' WHERE pid='$id'");
......@@ -526,12 +534,12 @@ function w_save2(&$data){
return;
}*/
function addnoise($wp_kind, $wsk, $ntime, $npls, $nid1, $nid2, $nmode)
function addnoise($wp_kind, $wsk, $ntime, $npls, $nid1, $nid2, $nmode)
{
//在隐藏地图内不会传出声音信息
global $plsinfo;
if(!array_key_exists($npls,$plsinfo)) return;
if ((($wp_kind == 'G') && (strpos ( $wsk, 'S' ) === false)) || ($wp_kind == 'F')) {
global $noisetime, $noisepls, $noiseid, $noiseid2, $noisemode;
$noisetime = $ntime;
......@@ -585,7 +593,7 @@ function npc_changewep_rev(&$pa,&$pd,$acitve)
if(!$pa['type'] || $pa['club'] != 98) return;
$dice = diceroll(99);
if($dice > 50)
{
$weplist = Array();
......@@ -640,15 +648,15 @@ function npc_changewep_rev(&$pa,&$pd,$acitve)
}
if(count($minus) < count($weplist)){
$weplist = array_diff($weplist,$minus);
}
}
}
}
else
else
{
//没有获取到可换装列表,直接返回
return;
}
if(!empty($weplist))
{
$oldwep = $pa['wep'];
......@@ -673,28 +681,28 @@ function npc_changewep_rev(&$pa,&$pd,$acitve)
# NPC喊话
# pa指npc pd指另一视角
function npc_chat_rev(&$pa,&$pd,$mode='')
function npc_chat_rev(&$pa,&$pd,$mode='')
{
global $npcchat;
if(!empty($npcchat[$pa['type']][$pa['name']]))
if(!empty($npcchat[$pa['type']][$pa['name']]))
{
$nchat = $npcchat[$pa['type']][$pa['name']];
$chatcolor = $nchat['color'];
$npcwords = !empty($chatcolor) ? "<span class = \"{$chatcolor}\">" : '<span>';
switch ($mode)
switch ($mode)
{
case 'attack' :
if (empty($pa['itmsk0']))
if (empty($pa['itmsk0']))
{
$npcwords .= "{$nchat[0]}";
$pa['itmsk0'] = 1;
}
elseif ($pa['hp'] > ($pa['mhp'] / 2))
elseif ($pa['hp'] > ($pa['mhp'] / 2))
{
$dice = rand ( 1, 2 );
$npcwords .= "{$nchat[$dice]}";
}
else
}
else
{
$dice = rand ( 3, 4 );
$npcwords .= "{$nchat[$dice]}";
......@@ -706,12 +714,12 @@ function npc_chat_rev(&$pa,&$pd,$mode='')
$npcwords .= "{$nchat[0]}";
$pa['itmsk0'] = 1;
}
elseif($pa['hp'] > ($pa['mhp'] / 2))
elseif($pa['hp'] > ($pa['mhp'] / 2))
{
$dice = rand ( 5, 6 );
$npcwords .= "{$nchat[$dice]}";
}
else
}
else
{
$dice = rand ( 7, 8 );
$npcwords .= "{$nchat[$dice]}";
......@@ -735,22 +743,22 @@ function npc_chat_rev(&$pa,&$pd,$mode='')
}
$npcwords .= '</span><br>';
return $npcwords;
}
elseif ($mode == 'death')
}
elseif ($mode == 'death')
{
global $lwinfo;
if (is_array($lwinfo[$pa['type']]))
if (is_array($lwinfo[$pa['type']]))
{
$lastword = $lwinfo[$pa['type']][$pa['name']];
}
else
}
else
{
$lastword = $lwinfo[$pa['type']];
}
$npcwords = "<span class=\"yellow\">“{$lastword}”</span><br>";
return $npcwords;
}
else
else
{
return;
}
......
......@@ -20,7 +20,7 @@ function findteam(&$w_pdata)
extract($pdata,EXTR_REFS);
extract($w_pdata,EXTR_PREFIX_ALL,'w');
init_battle_rev($pdata,$w_pdata);
$main = 'battle_rev';
$log .= "你发现了队友<span class=\"yellow\">$w_name</span>!<br>";
......@@ -42,12 +42,12 @@ function findcorpse(&$w_pdata)
extract($w_pdata,EXTR_PREFIX_ALL,'w');
init_battle_rev($pdata,$w_pdata,1);
$main = 'battle_rev';
$log .= '你发现了<span class="red">'.$w_name.'</span>的尸体!<br>';
# 初始化尸体tooltip
foreach (Array('wep','wep2','arb','arh','ara','arf','art','itm0','itm1','itm2','itm3','itm4','itm5','itm6') as $value)
foreach (Array('wep','wep2','arb','arh','ara','arf','art','itm0','itm1','itm2','itm3','itm4','itm5','itm6') as $value)
{
$value = 'w_'.$value;
if(strpos($value,'itm')!==false)
......@@ -56,7 +56,7 @@ function findcorpse(&$w_pdata)
$s_value = str_replace('itm','itms',$value);
$sk_value = str_replace('itm','itmsk',$value);
}
else
else
{
$k_value = $value.'k';
$s_value = $value.'s';
......@@ -66,7 +66,15 @@ function findcorpse(&$w_pdata)
global ${$value.'_words'},${$k_value.'_words'},${$s_value.'_words'},${$sk_value.'_words'};
# 初始化名称样式
${$value.'_words'} = parse_nameinfo_desc($$value,$w_horizon);
// 判断是背包栏物品还是装备栏物品
if(strpos($value,'itm')!==false) {
// 背包栏物品的 itmpara 字段名称为 itmpara0、itmpara1 等
$para_value = 'w_itmpara'.substr($value, 5);
} else {
// 装备栏物品的 itmpara 字段名称为 weppara、arbpara 等
$para_value = $value.'para';
}
${$value.'_words'} = parse_nameinfo_desc($$value, $w_horizon, '', '', isset($$para_value) ? $$para_value : '', $$k_value);
# 初始化类别样式
${$k_value.'_words'} = parse_kinfo_desc($$k_value,$$sk_value);
# 初始化属性样式
......@@ -81,11 +89,11 @@ function findcorpse(&$w_pdata)
// 初始化抡尸数据
$cstick_flag = 0;
if(!check_skill_unlock('tl_cstick',$pdata) && !check_skill_cost('tl_cstick',$pdata)) $cstick_flag = in_array($w_type,get_skillvars('tl_cstick','notype')) ? 0 : 1;
// 初始化妙手数据
$pickpocket_flag = 0;
if(!check_skill_unlock('tl_pickpocket',$pdata) && !check_skill_cost('tl_pickpocket',$pdata)) $pickpocket_flag = 1;
// 保存发现过女主尸体的记录
if($w_pdata['type'] == 14) $clbpara['achvars']['corpse_n14'] += 1;
......@@ -129,7 +137,7 @@ function senditem()
}
$edata = $db->fetch_array($result);
if($edata['pls'] != $pls)
if($edata['pls'] != $pls)
{
//登记非功能性地点信息时合并隐藏地点
foreach($hplsinfo as $hgroup=>$hpls) $plsinfo += $hpls;
......@@ -155,7 +163,7 @@ function senditem()
$w_log = "<span class=\"lime\">{$name}对你说:“{$message}”</span><br>";
if(!$edata['type']){logsave($edata['pid'],$now,$w_log,'c');}
}
if($command != 'back')
{
$itmn = substr($command, 3);
......@@ -186,7 +194,7 @@ function senditem()
for($i = 1;$i <= 6; $i++)
{
if(!$edata['itms'.$i])
if(!$edata['itms'.$i])
{
$edata['itm'.$i] = $itm;
$edata['itmk'.$i] = $itmk;
......@@ -197,7 +205,7 @@ function senditem()
$log .= "你将<span class=\"yellow\">{$edata['itm'.$i]}</span>送给了<span class=\"yellow\">$w_name</span>。<br>";
$w_log = "<span class=\"yellow\">$name</span>将<span class=\"yellow\">{$edata['itm'.$i]}</span>送给了你。";
if(!$w_type){logsave($w_pid,$now,$w_log,'t');}
addnews($now,'senditem',$name,$w_name,$itm,$nick);
//w_save($w_pid);
player_save($edata);
......
......@@ -206,6 +206,15 @@ function item_test($itmn, &$data) {
//global $rp;
$rp = 0;
$log .= "你使用了<span class=\"yellow\">$itm</span>。你的RP归零了。<br>";
} elseif ($itm == 'itmpara调试开关') {
// 切换 itmpara 调试模式
if(isset($clbpara['SetItmparaDebug']) && $clbpara['SetItmparaDebug'] === true) {
$clbpara['SetItmparaDebug'] = false;
$log .= "你关闭了 itmpara 调试模式。<br>现在物品的 tooltip 中不会显示调试信息。<br>";
} else {
$clbpara['SetItmparaDebug'] = true;
$log .= "你开启了 itmpara 调试模式。<br>现在物品的 tooltip 中会显示详细的调试信息。<br>";
}
} elseif ($itm == '对话选择测试器') {
// 带选择的对话测试
$clbpara['dialogue'] = 'choiceTestingDialog';
......
......@@ -23,7 +23,7 @@ function smartmix_create_recipe_quest($itm,$tp=0,&$data=NULL)
function smartmix_find_recipe($itm, $tp=0)
{
include_once GAME_ROOT.'./include/game/itemmix.func.php';
$mix_res = array();
$mix_res = array();
$itm = htmlspecialchars_decode(itemmix_name_proc($itm));
$mixinfo = get_mixinfo();
foreach ($mixinfo as $ma)
......@@ -52,7 +52,7 @@ function smartmix_check_available($data)
}
//生成道具序号的全组合
$fc = full_combination($packn, 2);
//所有的组合全部判断一遍是否可以合成,最简单粗暴和兼容
$mix_available = $mix_overlay_available = $mix_sync_available = array();
foreach($fc as $fcval){
......@@ -102,7 +102,7 @@ function init_itemmix_tips($itemindex='',&$data=NULL)
$mhint = ''; $smhint = '';
if(!empty($itemindex))
{
$mix_res = smartmix_find_recipe($itemindex, 1 + 2);
$mix_res = smartmix_find_recipe($itemindex, 1 + 2);
if($mix_res){
$smhint .= '<span class="blueseed b">'.$itemindex.'</span>涉及的合成公式:<br><ul>';
foreach($mix_res as $mval){
......@@ -119,7 +119,7 @@ function init_itemmix_tips($itemindex='',&$data=NULL)
}
$smhint .= "</ul>";
}
else
else
{
$smhint .= '没有找到<span class="blueseed b">'.$itemindex.'</span>的相关合成公式<span class="grey">(不会显示隐藏公式)</span>';
}
......@@ -146,8 +146,8 @@ function init_itemmix_tips($itemindex='',&$data=NULL)
$mstuff = $mresult = '';
}
$o_type = $mval['type'];
if(!$mstuff) {//配方只显示1次
sort($mval['stuff']);
if(!$mstuff) {//配方只显示1次
sort($mval['stuff']);
foreach($mval['stuff'] as $ms){
$mstuff .= parse_smartmix_recipelink($ms).' + ';
}
......@@ -167,7 +167,7 @@ function init_itemmix_tips($itemindex='',&$data=NULL)
for($i=0;$i<=6;$i++)
{
$itemindex = ${'itm'.$i};
$mix_res = smartmix_find_recipe($itemindex, 1 + 2);
$mix_res = smartmix_find_recipe($itemindex, 1 + 2);
if($mix_res){
$smhint .= '<span class="blueseed b">'.$itemindex.'</span>涉及的合成公式:<br><ul>';
foreach($mix_res as $mval){
......@@ -185,7 +185,7 @@ function init_itemmix_tips($itemindex='',&$data=NULL)
$smhint .= "</ul>";
}
}
if(!empty($smhint))
if(!empty($smhint))
{
//$smhint = "<span class=\"b\">素材不足:</span><br>".$smhint;
$mhint .= $smhint;
......@@ -215,7 +215,7 @@ function get_npc_helpinfo($nlist,$tooltip=1)
$tnlist = $nlist;
foreach ($tnlist as $i => $npcs)
{
if(!empty($npcs))
if(!empty($npcs))
{
foreach(Array('sub','asub','esub') as $tsub)
{
......@@ -234,7 +234,7 @@ function get_npc_helpinfo($nlist,$tooltip=1)
{
$snpc['skill'] .= '(?)';
}
else
else
{
$snpc['skill'] = '不定';
}
......@@ -245,7 +245,7 @@ function get_npc_helpinfo($nlist,$tooltip=1)
{
$snpc['gd'] = $snpc['gd']=='m' ? '男' : '女';
}
else
else
{
$snpc['gd'] = '未知';
}
......@@ -266,17 +266,17 @@ function get_npc_helpinfo($nlist,$tooltip=1)
{
$snpc['pls'] = '原地';
}
else
else
{
$snpc['pls'] = $snpc['pls']==99 ? '随机' : $plsinfo[$snpc['pls']];
}
}
}
}
if(isset($snpc['pose']))$snpc['poseinfo'] = "<span tooltip=\"{$posetips[$snpc['pose']]}\">".$poseinfo[$snpc['pose']]."</span>";
if(isset($snpc['tactic']))$snpc['tacinfo'] = "<span tooltip=\"{$tactips[$snpc['tactic']]}\">".$tacinfo[$snpc['tactic']]."</span>";
if(isset($snpc['club'])) $snpc['club'] = $snpc['club']==99 ? '第一形态' : $clubinfo[$snpc['club']];
//格式化装备、道具名
foreach (Array('wep','arb','arh','ara','arf','art','itm0','itm1','itm2','itm3','itm4','itm5','itm6') as $value)
foreach (Array('wep','arb','arh','ara','arf','art','itm0','itm1','itm2','itm3','itm4','itm5','itm6') as $value)
{
if(strpos($value,'itm')!==false)
{
......@@ -285,7 +285,7 @@ function get_npc_helpinfo($nlist,$tooltip=1)
$s_value = str_replace('itm','itms',$value);
$sk_value = str_replace('itm','itmsk',$value);
}
else
else
{
$e_value = $value.'e';
$k_value = $value.'k';
......@@ -297,7 +297,10 @@ function get_npc_helpinfo($nlist,$tooltip=1)
//添加tooltip效果
if($tooltip)
{
if(!empty($snpc[$value])) $snpc[$value] = parse_nameinfo_desc($snpc[$value]);
if(!empty($snpc[$value])) {
$para_value = $value.'para';
$snpc[$value] = parse_nameinfo_desc($snpc[$value], '', '', '', isset($snpc[$para_value]) ? $snpc[$para_value] : '', $snpc[$k_value]);
}
if(!empty($snpc[$sk_value])) $snpc[$sk_value.'_words'] = parse_skinfo_desc($snpc[$sk_value],$snpc[$k_value]);
if(!empty($snpc[$k_value])) $snpc[$k_value] = parse_kinfo_desc($snpc[$k_value]);
}
......@@ -323,7 +326,7 @@ function get_item_place($which)
$file = config('mapitem',$gamecfg);
$itemlist = openfile($file);
$in = sizeof($itemlist);
for($i = 1; $i < $in; $i++)
for($i = 1; $i < $in; $i++)
if(!empty($itemlist[$i]) && strpos($itemlist[$i],',')!==false)
{
list($iarea,$imap,$inum,$iname,$ikind,$ieff,$ista,$iskind) = explode(',',$itemlist[$i]);
......@@ -421,7 +424,7 @@ function get_item_place($which)
break;
}
}
}
}
}
}*/
//NPC掉落
......@@ -470,7 +473,7 @@ function get_item_npcdrop($which)
{
foreach(array('wep','arb','arh','ara','arf','art','itm1','itm2','itm3','itm4','itm5','itm6') as $nipval)
{
if(!empty($npcs['sub']))
if(!empty($npcs['sub']))
{
foreach($npcs['sub'] as $npc)
{
......
<?php
if(!defined('IN_GAME')) exit('Access Denied');
/**
* 处理 itmpara 的 tooltip 显示
*
* @param string|array $itmpara itmpara 字段的值
* @param string $item_type 物品类型的第一个字符,如 W(武器)、A(防具)等
* @return string 处理后的 tooltip 字符串,如果没有需要显示的内容则返回空字符串
*/
function parse_itmpara_tooltip($itmpara, $item_type = '')
{
global $itmpara_tooltip;
// 确保 $itmpara_tooltip 已经加载
if(!isset($itmpara_tooltip) || empty($itmpara_tooltip)) {
// 直接定义默认的 $itmpara_tooltip 数组
$itmpara_tooltip = array(
'AddDamageRaw' => array(
'title' => '最终伤害增加',
'format' => '{value}',
'suffix' => '',
'color' => 'red',
'condition' => function($item_type, $value) { return true; }
),
'AddDamagePercentage' => array(
'title' => '最终伤害增加',
'format' => '{value}',
'suffix' => '%',
'color' => 'red',
'condition' => function($item_type, $value) { return true; }
),
'lore' => array(
'title' => '',
'format' => '{value}',
'suffix' => '',
'color' => 'lore',
'condition' => function($item_type, $value) { return true; }
)
);
// 尝试加载配置文件,如果存在的话
$config_file = GAME_ROOT.'./gamedata/cache/itmpara_tooltip.php';
if(file_exists($config_file)) {
include $config_file;
}
}
// 初始化调试信息
$debug_info = "\r\n---------- DEBUG INFO ----------";
$debug_info .= "\r\nFunction: parse_itmpara_tooltip";
$debug_info .= "\r\nInput type: " . gettype($itmpara);
// 安全地处理 JSON 输出
if(is_array($itmpara)) {
// 使用 JSON_UNESCAPED_UNICODE 确保中文显示正常
$json_str = json_encode($itmpara, JSON_UNESCAPED_UNICODE);
$debug_info .= "\r\nInput value: " . $json_str;
// 输出每个键的类型和值
$debug_info .= "\r\nDetailed key info:";
foreach($itmpara as $k => $v) {
$debug_info .= "\r\n - Key: '{$k}' (" . gettype($k) . ")";
$debug_info .= "\r\n Value: '" . (is_array($v) ? json_encode($v, JSON_UNESCAPED_UNICODE) : $v) . "' (" . gettype($v) . ")";
}
} else {
$debug_info .= "\r\nInput value: " . $itmpara;
}
$debug_info .= "\r\nItem type: {$item_type}";
// 如果 itmpara 为空,直接返回调试信息
if(empty($itmpara)) {
$debug_info .= "\r\nEmpty itmpara detected";
return $debug_info;
}
// 如果 itmpara 不是数组,尝试将其转换为数组
if(!is_array($itmpara)) {
$debug_info .= "\r\nConverting itmpara to array using get_itmpara()";
$itmpara = get_itmpara($itmpara);
$debug_info .= "\r\nAfter conversion:";
$debug_info .= "\r\n - Type: " . gettype($itmpara);
// 安全地处理 JSON 输出
if(is_array($itmpara)) {
$json_str = json_encode($itmpara, JSON_UNESCAPED_UNICODE);
$debug_info .= "\r\n - Value: " . $json_str;
} else {
$debug_info .= "\r\n - Value: " . $itmpara;
}
$debug_info .= "\r\n - Empty: " . (empty($itmpara) ? 'true' : 'false');
if(empty($itmpara)) {
$debug_info .= "\r\nEmpty result after conversion";
return $debug_info;
}
// 确保 $itmpara 是数组
if(!is_array($itmpara)) {
$debug_info .= "\r\nWarning: itmpara is still not an array after conversion";
$debug_info .= "\r\nForcing conversion to empty array";
$itmpara = array();
}
}
// 获取物品类型的第一个字符
if(!empty($item_type)) {
$item_type = substr($item_type, 0, 1);
}
// 处理 tooltip
$tooltip = '';
// 先处理非 lore 的键值,再处理 lore
// 处理 lore 将放到其他键值处理后
// 处理其他键值
$debug_info .= "\r\nProcessing itmpara keys:";
$debug_info .= "\r\n - itmpara type: " . gettype($itmpara);
$debug_info .= "\r\n - itmpara empty: " . (empty($itmpara) ? 'true' : 'false');
// 确保 $itmpara 是数组并且不为空
if(is_array($itmpara) && !empty($itmpara)) {
$debug_info .= "\r\n - Keys: " . implode(', ', array_keys($itmpara));
foreach($itmpara as $key => $value) {
// 安全地处理值的输出
if(is_array($value)) {
$value_str = json_encode($value, JSON_UNESCAPED_UNICODE);
} else {
$value_str = $value;
}
$debug_info .= "\r\nProcessing key: {$key} = " . $value_str;
// 跳过 lore,单独处理
if($key === 'lore') {
$debug_info .= "\r\n - Skipping lore key for later processing";
continue;
}
// 检查是否有对应的 tooltip 配置
// 输出所有可用的配置键
$debug_info .= "\r\n - itmpara_tooltip is " . (isset($itmpara_tooltip) ? 'set' : 'not set');
$debug_info .= "\r\n - itmpara_tooltip is " . (empty($itmpara_tooltip) ? 'empty' : 'not empty');
$debug_info .= "\r\n - itmpara_tooltip type: " . gettype($itmpara_tooltip);
// 确保 $itmpara_tooltip 是数组
if(!is_array($itmpara_tooltip)) {
$itmpara_tooltip = array(
'AddDamageRaw' => array(
'title' => '最终伤害增加',
'format' => '{value}',
'suffix' => '',
'color' => 'red',
'condition' => function($item_type, $value) { return true; }
),
'AddDamagePercentage' => array(
'title' => '最终伤害增加',
'format' => '{value}',
'suffix' => '%',
'color' => 'red',
'condition' => function($item_type, $value) { return true; }
),
'lore' => array(
'title' => '',
'format' => '{value}',
'suffix' => '',
'color' => 'lore',
'condition' => function($item_type, $value) { return true; }
)
);
$debug_info .= "\r\n - Created default itmpara_tooltip array";
}
$debug_info .= "\r\n - Available tooltip config keys: " . implode(', ', array_keys($itmpara_tooltip));
// 先尝试直接匹配
$debug_info .= "\r\n - Direct match check: isset(\$itmpara_tooltip['{$key}']) = " . (isset($itmpara_tooltip[$key]) ? 'true' : 'false');
if(isset($itmpara_tooltip[$key])) {
$debug_info .= "\r\n - Found tooltip config for key: {$key}";
$config = $itmpara_tooltip[$key];
}
// 如果没有找到,尝试将键名转换为首字母大写的形式
else {
$ucfirstKey = ucfirst($key);
$debug_info .= "\r\n - Ucfirst match check: isset(\$itmpara_tooltip['{$ucfirstKey}']) = " . (isset($itmpara_tooltip[$ucfirstKey]) ? 'true' : 'false');
if(isset($itmpara_tooltip[$ucfirstKey])) {
$debug_info .= "\r\n - Found tooltip config for key (ucfirst): {$key} -> {$ucfirstKey}";
$config = $itmpara_tooltip[$ucfirstKey];
}
// 如果还是没有找到,尝试将键名转换为全大写的形式
else {
$upperKey = strtoupper($key);
$debug_info .= "\r\n - Uppercase match check: isset(\$itmpara_tooltip['{$upperKey}']) = " . (isset($itmpara_tooltip[$upperKey]) ? 'true' : 'false');
if(isset($itmpara_tooltip[$upperKey])) {
$debug_info .= "\r\n - Found tooltip config for key (uppercase): {$key} -> {$upperKey}";
$config = $itmpara_tooltip[$upperKey];
}
// 如果还是没有找到,尝试将键名转换为全小写的形式
else {
$lowerKey = strtolower($key);
$debug_info .= "\r\n - Lowercase match check: isset(\$itmpara_tooltip['{$lowerKey}']) = " . (isset($itmpara_tooltip[$lowerKey]) ? 'true' : 'false');
if(isset($itmpara_tooltip[$lowerKey])) {
$debug_info .= "\r\n - Found tooltip config for key (lowercase): {$key} -> {$lowerKey}";
$config = $itmpara_tooltip[$lowerKey];
}
// 如果还是没有找到,尝试将键名转换为驼峰式的形式
else {
// 尝试将键名转换为驼峰式
$camelKey = preg_replace_callback('/(^|_)([a-z])/', function($matches) {
return strtoupper($matches[2]);
}, $key);
$debug_info .= "\r\n - CamelCase match check: isset(\$itmpara_tooltip['{$camelKey}']) = " . (isset($itmpara_tooltip[$camelKey]) ? 'true' : 'false');
if(isset($itmpara_tooltip[$camelKey])) {
$debug_info .= "\r\n - Found tooltip config for key (camelCase): {$key} -> {$camelKey}";
$config = $itmpara_tooltip[$camelKey];
}
// 如果还是没有找到,尝试在所有键中进行大小写不敏感的匹配
else {
$found = false;
foreach(array_keys($itmpara_tooltip) as $configKey) {
if(strcasecmp($configKey, $key) === 0) {
$debug_info .= "\r\n - Found tooltip config for key (strcasecmp): {$key} -> {$configKey}";
$config = $itmpara_tooltip[$configKey];
$found = true;
break;
}
}
if(!$found) {
$debug_info .= "\r\n - No tooltip config found for key: {$key}";
continue;
}
}
}
}
}
}
// 检查条件
if(isset($config['condition']) && is_callable($config['condition'])) {
$condition_result = call_user_func($config['condition'], $item_type, $value);
$debug_info .= "\r\n - Condition check result: " . ($condition_result ? 'true' : 'false');
if(!$condition_result) {
$debug_info .= "\r\n - Skipping due to condition check";
continue;
}
}
// 格式化显示内容
$display = str_replace('{value}', $value, $config['format']) . $config['suffix'];
$debug_info .= "\r\n - Formatted display: {$display}";
// 添加颜色
if(!empty($config['color'])) {
$display = "<span class=\"{$config['color']}\">{$display}</span>";
$debug_info .= "\r\n - Added color";
}
// 添加标题
if(!empty($config['title'])) {
$display = "{$config['title']}: {$display}";
$debug_info .= "\r\n - Added title";
}
// 添加到 tooltip
$tooltip .= $display . "\r";
$debug_info .= "\r\n - Added to tooltip";
}
} else {
$debug_info .= "\r\nSkipping key processing: itmpara is not a valid array or is empty";
}
// 最后处理 lore,如果存在则显示
if(is_array($itmpara) && isset($itmpara['lore'])) {
$debug_info .= "\r\nProcessing lore key:";
$debug_info .= "\r\n - Value: {$itmpara['lore']}";
$tooltip .= $itmpara['lore'] . "\r";
$debug_info .= "\r\n - Added lore to tooltip";
} else {
$debug_info .= "\r\nNo lore key found or itmpara is not an array";
}
// 添加调试信息到返回的 tooltip
$debug_info .= "\r\n---------- END DEBUG INFO ----------";
// 检查玩家是否开启了调试模式
global $clbpara;
$show_debug = false;
if(isset($clbpara) && is_array($clbpara) && isset($clbpara['SetItmparaDebug']) && $clbpara['SetItmparaDebug'] === true) {
$show_debug = true;
}
// 如果 tooltip 为空
if(empty($tooltip)) {
// 如果开启了调试模式,返回调试信息
if($show_debug) {
$debug_info .= "\r\nNo tooltip content generated";
return $debug_info;
} else {
// 否则返回空字符串
return '';
}
}
// 如果开启了调试模式,返回 tooltip 加上调试信息
if($show_debug) {
$tooltip .= $debug_info;
}
return rtrim($tooltip, "\r");
}
/**
* 为物品名称添加 itmpara tooltip
*
* @param string $item_name 物品名称
* @param string|array $itmpara itmpara 字段的值
* @param string $item_type 物品类型
* @param string $existing_tooltip 已有的 tooltip 内容
* @return string 处理后的物品名称,带有 tooltip
*/
function add_itmpara_tooltip_to_item($item_name, $itmpara, $item_type = '', $existing_tooltip = '')
{
// 解析 itmpara tooltip
$itmpara_tooltip = parse_itmpara_tooltip($itmpara, $item_type);
// 如果没有 itmpara tooltip,直接返回原始名称
if(empty($itmpara_tooltip)) {
return $item_name;
}
// 如果已有 tooltip,合并两者
$tooltip = empty($existing_tooltip) ? $itmpara_tooltip : $existing_tooltip . "\r" . $itmpara_tooltip;
// 返回带有 tooltip 的物品名称
return "<span tooltip=\"{$tooltip}\">{$item_name}</span>";
}
......@@ -58,7 +58,7 @@ function gstrfilter($str) {
foreach($str as $key => $val) {
$str[$key] = gstrfilter($val);
}
} else {
} else {
if($GLOBALS['magic_quotes_gpc']) {
$str = stripslashes($str);
}
......@@ -173,12 +173,12 @@ function writeover($filename,$data,$method="rb+",$iflock=1,$check=1,$chmod=1){
if(flock($handle,LOCK_EX)){
fwrite($handle,$data);
if($method=="rb+") ftruncate($handle,strlen($data));
fclose($handle);
fclose($handle);
} else {var_dump($filename);exit ('Write file error.');}
} else {
fwrite($handle,$data);
if($method=="rb+") ftruncate($handle,strlen($data));
fclose($handle);
fclose($handle);
}
$chmod && chmod($filename,0777);
return;
......@@ -203,7 +203,7 @@ function compatible_json_encode($data){ //自动选择使用内置函数或者
} else{
$jdata = json_encode($data);
}
return $jdata;
return $jdata;
}
//----------------------------------------
......@@ -242,7 +242,7 @@ function logsave($pid,$time,$log = '',$type = 's'){
$ldata['log']=$log;
//$db->query("INSERT INTO {$tablepre}log (toid,type,`time`,log) VALUES ('$pid','$type','$time','$log')");
$db->array_insert("{$tablepre}log", $ldata);
return;
return;
}
function load_gameinfo() {
......@@ -260,12 +260,12 @@ function load_gameinfo() {
return Array($gamestate,$gamevars);
}
function save_gameinfo()
function save_gameinfo()
{
global $now,$db,$gtablepre,$tablepre;
global $groomid,$gamenum,$gamestate,$lastupdate,$starttime,$winmode,$winner,$arealist,$areanum,$areatime,$areawarn,$validnum,$alivenum,$deathnum,$afktime,$optime,$weather,$hack,$combonum,$gamevars;
if(!isset($gamenum)||!isset($gamestate)){return;}
if($gamestate > 10)
{
$result = $db->query("SELECT pid FROM {$tablepre}players WHERE type=0");
......@@ -275,18 +275,18 @@ function save_gameinfo()
$result = $db->query("SELECT pid FROM {$tablepre}players WHERE hp<=0 OR state>=10");
$deathnum = $db->num_rows($result);
}
else
else
{
$validnum = $alivenum = $deathnum = 0;
}
if(empty($afktime)){$afktime = $now;}
if(empty($optime)){$optime = $now;}
$gameinfo = Array();
$gameinfo['gamenum'] = $gamenum;
$gameinfo['gamestate'] = $gamestate;
//$gameinfo['lastupdate'] = $now;//注意此处
$gameinfo['starttime'] = $starttime;
$gameinfo['starttime'] = $starttime;
$gameinfo['winmode'] = $winmode;
$gameinfo['winner'] = $winner;
$gameinfo['arealist'] = implode(',',$arealist);
......@@ -344,7 +344,7 @@ function getchat($last,$team='',$limit=0) {
//登记非功能性地点信息时合并隐藏地点
$tplsinfo = $plsinfo;
foreach($hplsinfo as $hgroup=>$hpls) $tplsinfo += $hpls;
while($chat = $db->fetch_array($result)) {
//if(!$chatdata['lastcid']){$chatdata['lastcid'] = $chat['cid'];}
if($chatdata['lastcid'] < $chat['cid']){$chatdata['lastcid'] = $chat['cid'];}
......@@ -409,7 +409,7 @@ function storyputchat($time,$type){
$chat = $syschatinfo[$type];
$list = Array('r' => 0, 'b' => 0, 'l' => 0, 'k'=> 0);
if($rdown){$list['r'] = 1;}
if($bdown){$list['b'] = 1;}
if($bdown){$list['b'] = 1;}
if($ldown){$list['l'] = 1;}
if($kdown){$list['k'] = 1;}
foreach($chat as $val){
......@@ -431,7 +431,7 @@ function storyputchat($time,$type){
$send = $msgs[1];
$msg = $msgs[2];
$db->query("INSERT INTO {$tablepre}chat (type,`time`,send,msg) VALUES ('2','$time','$send','$msg')");
}
}
return;
}
......@@ -481,14 +481,14 @@ function update_db_player_structure($type=0)
{
global $db,$gtablepre,$tablepre,$checkstr;
$db_player_structure = $db_player_structure_types = $tpldata = Array();
$dps_need_update = 0;//判定是否需要更新玩家字段
$dps_file = GAME_ROOT.'./gamedata/bak/db_player_structure.config.php';
$sql_file = GAME_ROOT.'./gamedata/sql/players.sql';
if(!file_exists($dps_file) || filemtime($sql_file) > filemtime($dps_file)){
$dps_need_update = 1;
}
if($dps_need_update){//如果要更新,直接新建一个表,不需要依赖已有的players表
$sql = file_get_contents($sql_file);
$sql = str_replace("\r", "\n", str_replace(' bra_', ' '.$gtablepre.'tmp_', $sql));
......@@ -496,7 +496,7 @@ function update_db_player_structure($type=0)
$result = $db->query("DESCRIBE {$gtablepre}tmp_players");
while ($sttdata = $db->fetch_array($result))
{
global ${$sttdata['Field']};
global ${$sttdata['Field']};
$db_player_structure[] = $sttdata['Field'];
$db_player_structure_types[$sttdata['Field']] = $sttdata['Type'];
//array_push($db_player_structure,$pdata['Field']);
......@@ -505,7 +505,7 @@ function update_db_player_structure($type=0)
$dps_cont .= '$db_player_structure = ' . var_export($db_player_structure,1).";\r\n".'$db_player_structure_types = ' . var_export($db_player_structure_types,1).";\r\n?>";
writeover($dps_file, $dps_cont);
chmod($dps_file,0777);
}else{//若不需要更新,则直接读文件就好
include $dps_file ;
}
......@@ -526,9 +526,9 @@ function player_format_with_db_structure($data){
}
# 处理道具名的显示信息
function parse_nameinfo_desc($info,$subinfo='',$short='',$tiptype='')
function parse_nameinfo_desc($info, $subinfo='', $short='', $tiptype='', $itmpara='', $itmk='')
{
global $tps_name,$tps_names,$tps_name_lore,$noitm;
global $tps_name, $tps_names, $tps_name_lore, $noitm;
global $horizon;
if(empty($info)) return $noitm;
......@@ -542,7 +542,7 @@ function parse_nameinfo_desc($info,$subinfo='',$short='',$tiptype='')
{
$tinfo = preg_replace('/锋利的|电气|毒性|\[\+.*\]|-改/', '', $info);
}
else
else
{
$tinfo = $info;
}
......@@ -566,8 +566,35 @@ function parse_nameinfo_desc($info,$subinfo='',$short='',$tiptype='')
$info_tp .= $tps_name_lore[$tinfo]['title'];
}
# 处理 itmpara 字段的 tooltip
if(!empty($itmpara))
{
// 引入 itmpara_tooltip 函数
if(!function_exists('parse_itmpara_tooltip'))
{
include_once GAME_ROOT.'./include/game/itmpara_tooltip.func.php';
include_once GAME_ROOT.'./gamedata/cache/itmpara_tooltip.php';
}
// 解析 itmpara tooltip
$tooltip_content = parse_itmpara_tooltip($itmpara, $itmk);
// 如果有 itmpara tooltip,添加到现有 tooltip
if(!empty($tooltip_content))
{
if(!empty($info_tp)) $info_tp .= "\r";
$info_tp .= $tooltip_content;
}
}
if(!empty($info_f)) $info_f = "class=\"{$info_f}\"";
if(!empty($info_tp)) $info_tp = "{$ttypes}=\"{$info_tp}\"";
// 对 tooltip 内容进行 HTML 转义
if(!empty($info_tp)) {
// 使用 htmlspecialchars 进行 HTML 转义
$escaped_tp = htmlspecialchars($info_tp, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$info_tp = "{$ttypes}=\"{$escaped_tp}\"";
}
$info = "<span {$info_f} {$info_tp}>{$info}</span>";
return $info;
......@@ -586,7 +613,7 @@ function parse_kinfo_desc($info,$subinfo='',$short='',$tiptype='')
# 如果该道具类别没有特殊介绍,则直接使用通用类别
foreach($iteminfo as $info_key => $info_value)
{
if(strpos($info,$info_key)===0)
if(strpos($info,$info_key)===0)
{
$v_info = $info_key;
break;
......@@ -605,7 +632,7 @@ function parse_kinfo_desc($info,$subinfo='',$short='',$tiptype='')
elseif(!empty($subinfo))
{
if(!empty($info_tp)) $info_tp .= "\r";
if(!is_array($subinfo)) $subinfo = get_itmsk_array($subinfo);
if(!is_array($subinfo)) $subinfo = get_itmsk_array($subinfo);
if($info == 'WG' || $info == 'WGK' || $info == 'WDG')
{
if(in_array('e',$subinfo) || in_array('w',$subinfo)) $info_tp.= "需装填「能源弹药」";
......@@ -617,7 +644,7 @@ function parse_kinfo_desc($info,$subinfo='',$short='',$tiptype='')
{
if($info == 'WG' || $info == 'WGK' || $info == 'WDG') $info_tp.= "需装填「手枪弹药」";
}
if(!empty($info_f)) $info_f = "class=\"{$info_f}\"";
if(!empty($info_tp)) $info_tp = "{$ttypes}=\"{$info_tp}\"";
......@@ -655,9 +682,9 @@ function parse_skinfo_desc($info,$subinfo='',$short='',$tiptype='')
else
{
# 数组化
if(!is_array($info)) $info = get_itmsk_array($info);
if(!is_array($info)) $info = get_itmsk_array($info);
# 计数
$sk_max = count($info); $sk_nums = 0;
$sk_max = count($info); $sk_nums = 0;
$sk_info = ''; $sk_tp = '';
# 属性中是否有奇迹属性?
if(in_array('x',$info)) $xflag = 1;
......@@ -669,10 +696,10 @@ function parse_skinfo_desc($info,$subinfo='',$short='',$tiptype='')
# 如果不是第一个属性 显示一个 + 号
if($sk_nums>0) $sk_info .= '+';
# 检查属性有没有特殊样式
if(isset($tps_isk[$sk]['class'])) $csk = "<span class=\"".$tps_isk[$sk]['class']."\">".$csk."</span>";
if(isset($tps_isk[$sk]['class'])) $csk = "<span class=\"".$tps_isk[$sk]['class']."\">".$csk."</span>";
# 将属性加入显示队列
$sk_info .= $csk;
# 检查属性有没有tooltip
if(isset($tps_isk[$sk]['title']))
{
......@@ -685,7 +712,7 @@ function parse_skinfo_desc($info,$subinfo='',$short='',$tiptype='')
# 换行
if($sk_nums<$sk_max-1) $sk_tp .= "\r";
}
else
else
{
$sk_tp = !empty($xflag) && isset($tps_isk[$sk]['x-title']) ? $tps_isk[$sk]['x-title'] : $tps_isk[$sk]['title'];
}
......@@ -694,7 +721,7 @@ function parse_skinfo_desc($info,$subinfo='',$short='',$tiptype='')
}
if(!empty($sk_info)) $ret = $sk_info;
if($sk_max > $short_nums && $short) $ret = $itemspkinfo[$info[0]]."+...+".$itemspkinfo[end($info)];
if(!empty($sk_tp))
if(!empty($sk_tp))
{
$ret = "<span {$ttypes}=\"{$sk_tp}\">{$ret}</span>";
}
......@@ -733,7 +760,7 @@ function parse_info_desc($info,$type,$vars='',$short=0,$tiptype=0)
{
foreach($iteminfo as $info_key => $info_value)
{
if(strpos($info,$info_key)===0)
if(strpos($info,$info_key)===0)
{
$v_info = $info_key;
break;
......@@ -747,7 +774,7 @@ function parse_info_desc($info,$type,$vars='',$short=0,$tiptype=0)
if(!empty($vars))
{
if(!empty($info_tp)) $info_tp .= "\r";
if(!is_array($vars)) $vars = get_itmsk_array($vars);
if(!is_array($vars)) $vars = get_itmsk_array($vars);
if($v_info == 'WG' || $v_info == 'WGK' || $v_info == 'WDG')
{
if(in_array('e',$vars) || in_array('w',$vars)) $info_tp.= "需装填「能源弹药」";
......@@ -761,7 +788,7 @@ function parse_info_desc($info,$type,$vars='',$short=0,$tiptype=0)
if($v_info == 'WG' || $v_info == 'WGK' || $v_info == 'WDG') $info_tp.= "需装填「手枪弹药」";
if($v_info == 'WJ') $info_tp.= "需装填「重型弹药」";
}
if(!empty($info_f)) $info_f = "class=\"{$info_f}\"";
if(!empty($info_tp)) $info_tp = "{$ttypes}=\"{$info_tp}\"";
if(!isset($iteminfo[$info])) $info = $v_info;
......@@ -787,9 +814,9 @@ function parse_info_desc($info,$type,$vars='',$short=0,$tiptype=0)
else
{
# 数组化
if(!is_array($info)) $info = get_itmsk_array($info);
if(!is_array($info)) $info = get_itmsk_array($info);
# 计数
$sk_max = count($info); $sk_nums = 0;
$sk_max = count($info); $sk_nums = 0;
$sk_info = ''; $sk_tp = '';
# 属性中是否有奇迹属性?
if(in_array('x',$info)) $xflag = 1;
......@@ -797,7 +824,7 @@ function parse_info_desc($info,$type,$vars='',$short=0,$tiptype=0)
{
$csk = $itemspkinfo[$sk];
# 检查属性有没有特殊样式
if(isset($tps_isk[$sk]['class'])) $csk = "<span class=\"".$tps_isk[$sk]['class']."\">".$csk."</span>";
if(isset($tps_isk[$sk]['class'])) $csk = "<span class=\"".$tps_isk[$sk]['class']."\">".$csk."</span>";
# 将属性加入显示队列
$sk_info .= $csk;
# 如果不是最后一个属性 显示一个 + 号
......@@ -814,7 +841,7 @@ function parse_info_desc($info,$type,$vars='',$short=0,$tiptype=0)
# 换行
if($sk_nums<$sk_max-1) $sk_tp .= "\r";
}
else
else
{
$sk_tp = !empty($xflag) && isset($tps_isk[$sk]['x-title']) ? $tps_isk[$sk]['x-title'] : $tps_isk[$sk]['title'];
}
......@@ -823,7 +850,7 @@ function parse_info_desc($info,$type,$vars='',$short=0,$tiptype=0)
}
if(!empty($sk_info)) $ret = $sk_info;
if($sk_max > $short_nums && $short) $ret = $itemspkinfo[$info[0]]."+...+".$itemspkinfo[end($info)];
if(!empty($sk_tp))
if(!empty($sk_tp))
{
$ret = "<span {$ttypes}=\"{$sk_tp}\">{$ret}</span>";
}
......@@ -862,14 +889,14 @@ function get_itmsk_array($sk_value)
$i = 0;
while ($i < strlen($sk_value))
{
$sub = mb_substr($sk_value,$i,1,'utf-8');
$sub = mb_substr($sk_value,$i,1,'utf-8');
$i++;
if(!empty($sub) && array_key_exists($sub,$itemspkinfo)) array_push($ret,$sub);
}
return $ret;
return $ret;
}
//还原itmsk为字符串 $max_length:字符串长度上限
//还原itmsk为字符串 $max_length:字符串长度上限
function get_itmsk_strlen($sk_value,$max_length=30)
{
global $itemspkinfo;
......@@ -919,10 +946,129 @@ function set_clbpara($para,$key,$value)
//将itmpara转为数组
function get_itmpara($para)
{
//echo $para, "is a ", gettype($para);
if(empty($para)) $para = Array();
if(!is_array($para)) return json_decode($para,true);
else return $para;
// 记录调试信息
$debug = "get_itmpara debug:\n";
$debug .= "Input type: " . gettype($para) . "\n";
$debug .= "Input value: " . (is_string($para) ? $para : (is_array($para) ? json_encode($para) : gettype($para))) . "\n";
if(empty($para)) {
$debug .= "Empty input, returning empty array\n";
//error_log($debug);
return Array();
}
if(!is_array($para)) {
// 如果是字符串,尝试解析为 JSON
if(is_string($para)) {
$debug .= "Processing string input\n";
// 去除空白字符
$para = trim($para);
$debug .= "After trim: " . $para . "\n";
// 检查是否是 JSON 格式
if(substr($para, 0, 1) == '{' && substr($para, -1) == '}') {
$debug .= "Detected JSON format\n";
// 尝试修复可能的 JSON 格式问题
// 有时候 JSON 字符串可能被截断或损坏
// 先尝试直接解析
$result = json_decode($para, true);
$error = json_last_error();
$debug .= "First decode attempt: " . ($error === JSON_ERROR_NONE ? "success" : "failed") . "\n";
$debug .= "Error code: " . $error . "\n";
$debug .= "Error message: " . json_last_error_msg() . "\n";
// 如果解析失败,尝试修复
if($result === null && $error !== JSON_ERROR_NONE) {
$debug .= "Attempting to fix JSON string\n";
// 尝试修复常见问题
// 1. 如果是被截断的 JSON,尝试添加右花括号
if(substr_count($para, '{') > substr_count($para, '}')) {
$para .= str_repeat('}', substr_count($para, '{') - substr_count($para, '}'));
$debug .= "Added missing closing braces\n";
}
// 2. 如果有引号不匹配,尝试修复
if(substr_count($para, '"') % 2 != 0) {
$para .= '"';
$debug .= "Added missing quote\n";
}
// 3. 尝试使用替代方法解析
// 如果是简单的键值对,手动解析
if(strpos($para, '{"') === 0) {
$debug .= "Attempting manual parsing\n";
// 去除花括号
$content = substr($para, 1, -1);
$debug .= "Content without braces: " . $content . "\n";
// 尝试手动解析键值对
$manual_result = array();
// 尝试使用正则表达式提取键值对
preg_match_all('/"([^"]+)"\s*:\s*([^,}]+)/', $content, $matches);
if(!empty($matches[1]) && !empty($matches[2])) {
for($i = 0; $i < count($matches[1]); $i++) {
$key = $matches[1][$i];
$value = trim($matches[2][$i]);
// 如果值是数字
if(is_numeric($value)) {
$value = strpos($value, '.') !== false ? (float)$value : (int)$value;
}
// 如果值是字符串(带引号)
elseif(substr($value, 0, 1) == '"' && substr($value, -1) == '"') {
$value = substr($value, 1, -1);
}
$manual_result[$key] = $value;
}
}
$debug .= "Manual parsing result: " . json_encode($manual_result) . "\n";
// 如果手动解析成功,使用手动解析的结果
if(!empty($manual_result)) {
$result = $manual_result;
} else {
// 再次尝试使用 json_decode
$result = json_decode($para, true);
$debug .= "Second decode attempt: " . (json_last_error() === JSON_ERROR_NONE ? "success" : "failed") . "\n";
}
}
}
// 如果解析结果为空,返回空数组
if($result === null) {
$debug .= "Failed to parse JSON, returning empty array\n";
//error_log($debug);
return array();
}
$debug .= "Final result: " . json_encode($result) . "\n";
//error_log($debug);
return $result;
} else {
$debug .= "Not a JSON string, returning as is\n";
//error_log($debug);
return $para;
}
} else {
$debug .= "Not a string or array, returning empty array\n";
//error_log($debug);
return array();
}
} else {
$debug .= "Already an array, returning as is\n";
//error_log($debug);
return $para;
}
}
//获取itmpara中指定键
function get_single_itmpara($para,$key)
......@@ -947,12 +1093,12 @@ function set_itmpara($para,$key,$value)
}
// 正态分布
function generate_ndnumbers($min, $max, $count = 10)
function generate_ndnumbers($min, $max, $count = 10)
{
$numbers = array();
$mu = ($min + $max) / 2; // 计算区间均值
$sigma = ($max - $min) / 6; // 计算区间标准差
for ($i = 0; $i < $count; $i++)
for ($i = 0; $i < $count; $i++)
{
$u1 = rand() / getrandmax();
$u2 = rand() / getrandmax();
......@@ -977,28 +1123,28 @@ function full_combination($a, $min) {
}
}
return $r;
}
}
function combination($a, $m) {
$r = array();
$n = count($a);
if ($m <= 0 || $m > $n) {
return $r;
function combination($a, $m) {
$r = array();
$n = count($a);
if ($m <= 0 || $m > $n) {
return $r;
}
for ($i=0; $i<$n; $i++) {
$t = array($a[$i]);
if ($m == 1) {
$r[] = $t;
} else {
$b = array_slice($a, $i+1);
$c = combination($b, $m-1);
foreach ($c as $v) {
$r[] = array_merge($t, $v);
}
}
}
for ($i=0; $i<$n; $i++) {
$t = array($a[$i]);
if ($m == 1) {
$r[] = $t;
} else {
$b = array_slice($a, $i+1);
$c = combination($b, $m-1);
foreach ($c as $v) {
$r[] = array_merge($t, $v);
}
}
}
return $r;
}
return $r;
}
function mgzdecode($data)
{
......@@ -1032,17 +1178,17 @@ function json_encode_comp($par){
return urldecode(json_encode(url_encode($par)));
}
}
function url_encode($str) {
if(is_array($str)) {
foreach($str as $key=>$value) {
$str[urlencode($key)] = url_encode($value);
}
} else {
$str = urlencode($str);
}
return $str;
}
function url_encode($str) {
if(is_array($str)) {
foreach($str as $key=>$value) {
$str[urlencode($key)] = url_encode($value);
}
} else {
$str = urlencode($str);
}
return $str;
}
//mb_strlen()兼容替代函数,直接照抄的网络
if ( !function_exists('mb_strlen') ) {
......
......@@ -21,7 +21,7 @@ function parse_queue_vnmix_info($carr)
}
}
// 格式化名称
$carr['itm_desc'] = parse_nameinfo_desc($carr['itm']);
$carr['itm_desc'] = parse_nameinfo_desc($carr['itm'], '', '', '', isset($carr['itmpara']) ? $carr['itmpara'] : '', $carr['itmk']);
// 格式化类别
$carr['itmk_desc'] = parse_kinfo_desc($carr['itmk'],$carr['itmsk']);
// 合并显示类
......@@ -48,13 +48,13 @@ function get_queue_vnmix_list($id=NULL)
return $db->fetch_array($result);
}
}
else
else
{
$result = $db->query("SELECT * FROM {$gtablepre}vnmixitem ");
if($db->num_rows($result))
{
{
while($t = $db->fetch_array($result,MYSQLI_ASSOC))
{
{
$carr[$t['iid']] = $t;
unset($carr[$t['iid']]['iid']);
}
......@@ -212,7 +212,7 @@ function writeover_vn_mixilst($varr=Array())
if($key == 'itms') $narr['result'][3] = $arr;
if($key == 'itmsk') $narr['result'][4] = $arr;
}
else
else
{
$narr[$key] = $arr;
}
......@@ -237,11 +237,11 @@ function edit_vn_mixilst($varr,$t)
global $checkstr,$gamecfg;
//先加锁
$lock_file = GAME_ROOT.'./gamedata/bak/vnmix2.lock';
if(file_exists($lock_file))
if(file_exists($lock_file))
{
return '有其他管理员正在进行编辑操作,请稍等一会儿再试!';
}
else
else
{
$cache_file = config('vnmixitem',$gamecfg);
if(file_exists($cache_file))
......@@ -251,7 +251,7 @@ function edit_vn_mixilst($varr,$t)
include_once($cache_file);
global $vn_mixinfo;
}
else
else
{
return '合成配方文件不存在!不能进行编辑操作。';
}
......
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