Commit eb466c00 authored by Nemo Ma's avatar Nemo Ma

Revert "Merge pull request #217 from amarillonmc/feature/game-resource-management"

This reverts commit 6886e617, reversing
changes made to 54000ed2.
parent 16d71a63
......@@ -22,11 +22,6 @@ $admin_cmd_list = Array(
'roommng' => 5,
'antiAFKmng' => 4,
'templates_clean' => 4,
'resourcemng' => 6,
'mapitemsmng' => 7,
'shopitemsmng' => 7,
'startitemsmng' => 6,
'startnpcsmng' => 8,
);
if(!$cuser||!$cpass) { gexit($_ERROR['no_login'],__file__,__line__); }
......
NOUVEAU DAY 72 - 游戏资源管理功能实装记录
时间:2025-06-18
操作:实装游戏资源管理功能
=== 实装概述 ===
为了方便管理员直观地管理游戏各个模式的资源文件,在管理后台新增了"游戏资源"分区,包含以下功能:
1. 游戏资源管理总览
2. 地图物品管理 (权限7)
3. 商店物品管理 (权限7)
4. 开局物品管理 (权限6)
5. 开局NPC管理 (权限8)
=== 修改的文件 ===
1. admin.php
- 添加新的管理命令到 $admin_cmd_list 数组
- 新增命令:resourcemng, mapitemsmng, shopitemsmng, startitemsmng, startnpcsmng
2. include/admin/admin.lang.php
- 添加相关语言定义
- 包括各功能的名称和说明文字
3. templates/default/admin_menu.htm
- 添加"游戏资源"分区到管理菜单
- 新增第三列显示资源管理相关按钮
=== 新增的文件 ===
1. include/admin/resourcemng.php
- 游戏资源管理主控制器
- 提供RuleSet选择和资源文件状态检查功能
2. templates/default/admin_resourcemng.htm
- 资源管理主界面模板
- 显示可用RuleSet和各资源文件状态
3. include/admin/mapitemsmng.php
- 地图物品管理功能
- 解析mapitem_1.php文件,提供CRUD操作
4. templates/default/admin_mapitemsmng.htm
- 地图物品管理界面模板
- 支持搜索、分页、编辑、删除功能
5. include/admin/shopitemsmng.php
- 商店物品管理功能
- 解析shopitem_1.php文件,处理分隔符行
6. templates/default/admin_shopitemsmng.htm
- 商店物品管理界面模板
- 区分普通物品和分类分隔符
7. include/admin/startitemsmng.php
- 开局物品管理功能
- 同时管理stitem_1.php和stwep_1.php文件
8. templates/default/admin_startitemsmng.htm
- 开局物品管理界面模板
- 支持物品/武器文件切换
9. include/admin/startnpcsmng.php
- 开局NPC管理功能
- 解析npc_1.php的复杂数组结构
10. templates/default/admin_startnpcsmng.htm
- 开局NPC管理界面模板
- 显示NPC基本信息和子NPC列表
=== 功能特性 ===
1. RuleSet支持
- 支持默认资源和各RuleSet资源的切换管理
- 自动检测可用的RuleSet目录
- 路径自动适配:gamedata/cache/ 或 gamedata/ruleset/*/cache/
2. 文件格式解析
- 地图物品:禁数,地图,数量,名称,类别,效果,耐久,子类别,itmpara
- 商店物品:类别,数量,价格,开始禁,名称,类别,效果,耐久,子类别,itmpara
- 开局物品:名称,类别,效果,耐久,子类别
- 开局NPC:复杂的PHP数组结构
3. 管理功能
- 搜索:支持按名称、类型等字段搜索
- 分页:大量数据时的分页显示
- 编辑:在线编辑物品属性
- 删除:安全删除确认
- 新增:添加新的物品或配置
4. 权限控制
- 不同功能需要不同的管理员权限等级
- 权限不足时显示相应提示
5. 用户体验
- 直观的表格显示
- 详细的字段说明
- 操作确认对话框
- 错误信息提示
=== 技术实现 ===
1. 文件解析
- 使用explode()解析CSV格式的配置文件
- 特殊处理商店物品的分隔符行
- NPC文件使用include方式加载PHP数组
2. 数据保存
- 重新生成完整的配置文件
- 保持原有的文件格式和注释
- 使用file_put_contents()安全写入
3. 模板系统
- 复用现有的模板引擎
- 条件显示和循环渲染
- 表单数据绑定
4. 安全性
- 权限验证
- 输入过滤
- 文件路径验证
=== 后续扩展 ===
1. 可以考虑添加批量导入/导出功能
2. 支持更多资源文件类型的管理
3. 添加配置文件的备份和恢复功能
4. 实现更复杂的NPC编辑功能
=== 注意事项 ===
1. 由于mapitemmng.php文件已存在且用于其他目的,使用了mapitemsmng.php等新文件名
2. NPC管理功能相对简化,复杂编辑建议使用现有的NPC管理功能
3. 所有修改都会记录到管理员日志中
4. 文件操作失败时会显示相应的错误信息
此功能的实装大大提升了游戏资源管理的便利性,管理员可以直观地管理各种游戏资源文件,支持多RuleSet环境,为游戏运营提供了强有力的工具支持。
......@@ -270,17 +270,6 @@ $lang = array
'antiAFKmng_comment' => '手动清除一定时间内未行动的玩家',
'sttimemng' => '开始时间管理',
'sttimemng_comment' => '设定下局游戏的开始时间',
'resourcemng' => '游戏资源管理',
'resourcemng_comment' => '管理游戏各模式的资源文件',
'mapitemsmng' => '地图物品管理',
'mapitemsmng_comment' => '管理地图物品刷新配置<br>对应mapitem_1.php',
'shopitemsmng' => '商店物品管理',
'shopitemsmng_comment' => '管理商店物品销售配置<br>对应shopitem_1.php',
'startitemsmng' => '开局物品管理',
'startitemsmng_comment' => '管理玩家开局物品配置<br>对应stitem_1.php和stwep_1.php',
'startnpcsmng' => '开局NPC管理',
'startnpcsmng_comment' => '管理开局NPC配置<br>对应npc_1.php',
'on' => '开启',
'off' => '关闭',
......
<?php
if(!defined('IN_ADMIN')) {
exit('Access Denied');
}
// 引入资源管理公共函数
require_once GAME_ROOT.'./include/admin/resourcemng.php';
if(!isset($command)){$command = 'list';}
if(!isset($start)){$start = 0;}
if(!isset($search_term)){$search_term = '';}
if(!isset($pagemode)){$pagemode = '';}
if(!isset($ruleset)){$ruleset = 'default';}
$cmd_info = '';
$start = getstart($start,$pagemode);
$current_ruleset = $ruleset;
$available_rulesets = getRulesetList();
// 获取资源文件路径
$resource_path = getCurrentRulesetPath($current_ruleset);
$mapitem_file = $resource_path . 'mapitem_1.php';
// 加载地图信息
$plsinfo = array();
if(file_exists(GAME_ROOT.'./gamedata/cache/resources_1.php')) {
include GAME_ROOT.'./gamedata/cache/resources_1.php';
}
// 解析地图物品文件
function parseMapItemFile($file_path) {
$items = array();
if(!file_exists($file_path)) {
return $items;
}
$content = file_get_contents($file_path);
$lines = explode("\n", $content);
foreach($lines as $line_num => $line) {
$line = trim($line);
if(empty($line) || strpos($line, '<?') === 0 || strpos($line, '//') === 0) {
continue;
}
$parts = explode(',', $line);
if(count($parts) >= 8) {
$items[] = array(
'line_num' => $line_num + 1,
'ban_time' => trim($parts[0]),
'location' => trim($parts[1]),
'quantity' => trim($parts[2]),
'name' => trim($parts[3]),
'type' => trim($parts[4]),
'effect' => trim($parts[5]),
'durability' => trim($parts[6]),
'subtype' => trim($parts[7]),
'itmpara' => isset($parts[8]) ? trim($parts[8]) : '',
'raw_line' => $line
);
}
}
return $items;
}
// 保存地图物品文件
function saveMapItemFile($file_path, $items) {
$content = "<? if(!defined('IN_GAME')) exit('Access Denied'); \n";
$content .= "//道具出现时间(0=开局,1=1禁,2=2禁,以此类推。99=每禁都刷。)\n";
$content .= "//道具所在地图(数字=地区位置,99=全图随机掉落)\n";
$content .= "?>\n";
foreach($items as $item) {
$line = $item['ban_time'] . ',' . $item['location'] . ',' . $item['quantity'] . ',' .
$item['name'] . ',' . $item['type'] . ',' . $item['effect'] . ',' .
$item['durability'] . ',' . $item['subtype'] . ',' . $item['itmpara'];
$content .= $line . "\n";
}
return file_put_contents($file_path, $content);
}
// 处理命令
$mapitems = parseMapItemFile($mapitem_file);
$total_items = count($mapitems);
if($command == 'search' && !empty($search_term)) {
$filtered_items = array();
foreach($mapitems as $item) {
if(stripos($item['name'], $search_term) !== false ||
stripos($item['type'], $search_term) !== false ||
stripos($item['location'], $search_term) !== false) {
$filtered_items[] = $item;
}
}
$mapitems = $filtered_items;
$total_items = count($mapitems);
}
// 分页处理
$showlimit = 20;
$page_items = array_slice($mapitems, $start, $showlimit);
if($command == 'delete' && isset($delete_line)) {
$delete_line = (int)$delete_line;
$new_items = array();
$deleted = false;
foreach($mapitems as $item) {
if($item['line_num'] != $delete_line) {
$new_items[] = $item;
} else {
$deleted = true;
$deleted_item_name = $item['name'];
}
}
if($deleted && saveMapItemFile($mapitem_file, $new_items)) {
$cmd_info = "物品 {$deleted_item_name} 已删除";
adminlog('delete_mapitem', $deleted_item_name, $current_ruleset);
$mapitems = parseMapItemFile($mapitem_file);
$page_items = array_slice($mapitems, $start, $showlimit);
} else {
$cmd_info = "删除失败";
}
} elseif($command == 'edit' && isset($edit_line)) {
$edit_line = (int)$edit_line;
$edit_item = null;
foreach($mapitems as $item) {
if($item['line_num'] == $edit_line) {
$edit_item = $item;
break;
}
}
if(!$edit_item) {
$cmd_info = "找不到指定的物品";
} else {
$command = 'edit_form';
}
} elseif($command == 'save_edit') {
$edit_line = (int)$edit_line;
$new_items = array();
$updated = false;
foreach($mapitems as $item) {
if($item['line_num'] == $edit_line) {
$item['ban_time'] = trim($ban_time);
$item['location'] = trim($location);
$item['quantity'] = trim($quantity);
$item['name'] = trim($name);
$item['type'] = trim($type);
$item['effect'] = trim($effect);
$item['durability'] = trim($durability);
$item['subtype'] = trim($subtype);
$item['itmpara'] = trim($itmpara);
$updated = true;
}
$new_items[] = $item;
}
if($updated && saveMapItemFile($mapitem_file, $new_items)) {
$cmd_info = "物品 {$name} 已更新";
adminlog('edit_mapitem', $name, $current_ruleset);
$mapitems = parseMapItemFile($mapitem_file);
$page_items = array_slice($mapitems, $start, $showlimit);
} else {
$cmd_info = "更新失败";
}
} elseif($command == 'add') {
$command = 'add_form';
} elseif($command == 'save_add') {
$new_item = array(
'ban_time' => trim($ban_time),
'location' => trim($location),
'quantity' => trim($quantity),
'name' => trim($name),
'type' => trim($type),
'effect' => trim($effect),
'durability' => trim($durability),
'subtype' => trim($subtype),
'itmpara' => trim($itmpara)
);
$mapitems[] = $new_item;
if(saveMapItemFile($mapitem_file, $mapitems)) {
$cmd_info = "物品 {$name} 已添加";
adminlog('add_mapitem', $name, $current_ruleset);
$mapitems = parseMapItemFile($mapitem_file);
$page_items = array_slice($mapitems, $start, $showlimit);
} else {
$cmd_info = "添加失败";
}
}
include template('admin_mapitemsmng');
?>
<?php
if(!defined('IN_ADMIN')) {
exit('Access Denied');
}
// 获取可用的RuleSet列表
function getRulesetList() {
$rulesets = array();
$rulesets['default'] = '默认资源 (gamedata/cache)';
$ruleset_dir = GAME_ROOT.'./gamedata/ruleset/';
if(is_dir($ruleset_dir)) {
$dirs = scandir($ruleset_dir);
foreach($dirs as $dir) {
if($dir != '.' && $dir != '..' && is_dir($ruleset_dir.$dir)) {
if(file_exists($ruleset_dir.$dir.'/cache/')) {
$rulesets[$dir] = 'RuleSet: '.$dir;
}
}
}
}
return $rulesets;
}
// 获取当前选择的RuleSet路径
function getCurrentRulesetPath($ruleset = 'default') {
if($ruleset == 'default') {
return GAME_ROOT.'./gamedata/cache/';
} else {
return GAME_ROOT.'./gamedata/ruleset/'.$ruleset.'/cache/';
}
}
// 检查文件是否存在
function checkResourceFile($ruleset, $filename) {
$path = getCurrentRulesetPath($ruleset);
return file_exists($path.$filename);
}
$cmd_info = '';
$current_ruleset = isset($ruleset) ? $ruleset : 'default';
$available_rulesets = getRulesetList();
// 检查各资源文件状态
$resource_status = array(
'mapitem_1.php' => array(
'name' => '地图物品配置',
'exists' => checkResourceFile($current_ruleset, 'mapitem_1.php'),
'manage_cmd' => 'mapitemsmng',
'permission' => 7
),
'shopitem_1.php' => array(
'name' => '商店物品配置',
'exists' => checkResourceFile($current_ruleset, 'shopitem_1.php'),
'manage_cmd' => 'shopitemsmng',
'permission' => 7
),
'stitem_1.php' => array(
'name' => '开局物品配置',
'exists' => checkResourceFile($current_ruleset, 'stitem_1.php'),
'manage_cmd' => 'startitemsmng',
'permission' => 6
),
'stwep_1.php' => array(
'name' => '开局武器配置',
'exists' => checkResourceFile($current_ruleset, 'stwep_1.php'),
'manage_cmd' => 'startitemsmng',
'permission' => 6
),
'npc_1.php' => array(
'name' => '开局NPC配置',
'exists' => checkResourceFile($current_ruleset, 'npc_1.php'),
'manage_cmd' => 'startnpcsmng',
'permission' => 8
)
);
include template('admin_resourcemng');
?>
<?php
if(!defined('IN_ADMIN')) {
exit('Access Denied');
}
// 引入资源管理公共函数
require_once GAME_ROOT.'./include/admin/resourcemng.php';
if(!isset($command)){$command = 'list';}
if(!isset($start)){$start = 0;}
if(!isset($search_term)){$search_term = '';}
if(!isset($pagemode)){$pagemode = '';}
if(!isset($ruleset)){$ruleset = 'default';}
$cmd_info = '';
$start = getstart($start,$pagemode);
$current_ruleset = $ruleset;
$available_rulesets = getRulesetList();
// 获取资源文件路径
$resource_path = getCurrentRulesetPath($current_ruleset);
$shopitem_file = $resource_path . 'shopitem_1.php';
// 解析商店物品文件
function parseShopItemFile($file_path) {
$items = array();
if(!file_exists($file_path)) {
return $items;
}
$content = file_get_contents($file_path);
$lines = explode("\n", $content);
foreach($lines as $line_num => $line) {
$line = trim($line);
if(empty($line) || strpos($line, '<?') === 0) {
continue;
}
$parts = explode(',', $line);
if(count($parts) >= 5) {
// 检查是否是分隔符行 (如 0,2,,,补给,,,,,)
if(count($parts) >= 9 && empty($parts[2]) && empty($parts[3]) && !empty($parts[4])) {
$items[] = array(
'line_num' => $line_num + 1,
'is_separator' => true,
'category_id' => trim($parts[0]),
'sub_category' => trim($parts[1]),
'category_name' => trim($parts[4]),
'raw_line' => $line
);
} elseif(count($parts) >= 9) {
$items[] = array(
'line_num' => $line_num + 1,
'is_separator' => false,
'category' => trim($parts[0]),
'quantity' => trim($parts[1]),
'price' => trim($parts[2]),
'start_ban' => trim($parts[3]),
'name' => trim($parts[4]),
'type' => trim($parts[5]),
'effect' => trim($parts[6]),
'durability' => trim($parts[7]),
'subtype' => trim($parts[8]),
'itmpara' => isset($parts[9]) ? trim($parts[9]) : '',
'raw_line' => $line
);
}
}
}
return $items;
}
// 保存商店物品文件
function saveShopItemFile($file_path, $items) {
$content = "<? if(!defined('IN_GAME')) exit('Access Denied'); ?>\n";
foreach($items as $item) {
if($item['is_separator']) {
$line = $item['category_id'] . ',' . $item['sub_category'] . ',,,' .
$item['category_name'] . ',,,,,';
} else {
$line = $item['category'] . ',' . $item['quantity'] . ',' . $item['price'] . ',' .
$item['start_ban'] . ',' . $item['name'] . ',' . $item['type'] . ',' .
$item['effect'] . ',' . $item['durability'] . ',' . $item['subtype'] . ',' .
$item['itmpara'];
}
$content .= $line . "\n";
}
return file_put_contents($file_path, $content);
}
// 处理命令
$shopitems = parseShopItemFile($shopitem_file);
$total_items = count($shopitems);
if($command == 'search' && !empty($search_term)) {
$filtered_items = array();
foreach($shopitems as $item) {
if($item['is_separator']) {
if(stripos($item['category_name'], $search_term) !== false) {
$filtered_items[] = $item;
}
} else {
if(stripos($item['name'], $search_term) !== false ||
stripos($item['type'], $search_term) !== false) {
$filtered_items[] = $item;
}
}
}
$shopitems = $filtered_items;
$total_items = count($shopitems);
}
// 分页处理
$showlimit = 20;
$page_items = array_slice($shopitems, $start, $showlimit);
if($command == 'delete' && isset($delete_line)) {
$delete_line = (int)$delete_line;
$new_items = array();
$deleted = false;
foreach($shopitems as $item) {
if($item['line_num'] != $delete_line) {
$new_items[] = $item;
} else {
$deleted = true;
$deleted_item_name = $item['is_separator'] ? $item['category_name'] : $item['name'];
}
}
if($deleted && saveShopItemFile($shopitem_file, $new_items)) {
$cmd_info = "项目 {$deleted_item_name} 已删除";
adminlog('delete_shopitem', $deleted_item_name, $current_ruleset);
$shopitems = parseShopItemFile($shopitem_file);
$page_items = array_slice($shopitems, $start, $showlimit);
} else {
$cmd_info = "删除失败";
}
}
include template('admin_shopitemsmng');
?>
<?php
if(!defined('IN_ADMIN')) {
exit('Access Denied');
}
// 引入资源管理公共函数
require_once GAME_ROOT.'./include/admin/resourcemng.php';
if(!isset($command)){$command = 'list';}
if(!isset($start)){$start = 0;}
if(!isset($search_term)){$search_term = '';}
if(!isset($pagemode)){$pagemode = '';}
if(!isset($ruleset)){$ruleset = 'default';}
if(!isset($file_type)){$file_type = 'items';}
$cmd_info = '';
$start = getstart($start,$pagemode);
$current_ruleset = $ruleset;
$available_rulesets = getRulesetList();
// 获取资源文件路径
$resource_path = getCurrentRulesetPath($current_ruleset);
$stitem_file = $resource_path . 'stitem_1.php';
$stwep_file = $resource_path . 'stwep_1.php';
// 解析开局物品文件
function parseStartItemFile($file_path) {
$items = array();
if(!file_exists($file_path)) {
return $items;
}
$content = file_get_contents($file_path);
$lines = explode("\n", $content);
foreach($lines as $line_num => $line) {
$line = trim($line);
if(empty($line) || strpos($line, '<?') === 0) {
continue;
}
$parts = explode(',', $line);
if(count($parts) >= 5) {
$items[] = array(
'line_num' => $line_num + 1,
'name' => trim($parts[0]),
'type' => trim($parts[1]),
'effect' => trim($parts[2]),
'durability' => trim($parts[3]),
'subtype' => trim($parts[4]),
'raw_line' => $line
);
}
}
return $items;
}
// 保存开局物品文件
function saveStartItemFile($file_path, $items) {
$content = "<? if(!defined('IN_GAME')) exit('Access Denied'); ?>\n";
foreach($items as $item) {
$line = $item['name'] . ',' . $item['type'] . ',' . $item['effect'] . ',' .
$item['durability'] . ',' . $item['subtype'] . ',';
$content .= $line . "\n";
}
return file_put_contents($file_path, $content);
}
// 根据文件类型选择文件
$current_file = ($file_type == 'weapons') ? $stwep_file : $stitem_file;
$current_file_name = ($file_type == 'weapons') ? 'stwep_1.php' : 'stitem_1.php';
$current_type_name = ($file_type == 'weapons') ? '武器' : '物品';
// 处理命令
$startitems = parseStartItemFile($current_file);
$total_items = count($startitems);
if($command == 'search' && !empty($search_term)) {
$filtered_items = array();
foreach($startitems as $item) {
if(stripos($item['name'], $search_term) !== false ||
stripos($item['type'], $search_term) !== false) {
$filtered_items[] = $item;
}
}
$startitems = $filtered_items;
$total_items = count($startitems);
}
// 分页处理
$showlimit = 20;
$page_items = array_slice($startitems, $start, $showlimit);
if($command == 'delete' && isset($delete_line)) {
$delete_line = (int)$delete_line;
$new_items = array();
$deleted = false;
foreach($startitems as $item) {
if($item['line_num'] != $delete_line) {
$new_items[] = $item;
} else {
$deleted = true;
$deleted_item_name = $item['name'];
}
}
if($deleted && saveStartItemFile($current_file, $new_items)) {
$cmd_info = "{$current_type_name} {$deleted_item_name} 已删除";
adminlog('delete_startitem', $deleted_item_name, $current_ruleset);
$startitems = parseStartItemFile($current_file);
$page_items = array_slice($startitems, $start, $showlimit);
} else {
$cmd_info = "删除失败";
}
} elseif($command == 'edit' && isset($edit_line)) {
$edit_line = (int)$edit_line;
$edit_item = null;
foreach($startitems as $item) {
if($item['line_num'] == $edit_line) {
$edit_item = $item;
break;
}
}
if(!$edit_item) {
$cmd_info = "找不到指定的{$current_type_name}";
} else {
$command = 'edit_form';
}
} elseif($command == 'save_edit') {
$edit_line = (int)$edit_line;
$new_items = array();
$updated = false;
foreach($startitems as $item) {
if($item['line_num'] == $edit_line) {
$item['name'] = trim($name);
$item['type'] = trim($type);
$item['effect'] = trim($effect);
$item['durability'] = trim($durability);
$item['subtype'] = trim($subtype);
$updated = true;
}
$new_items[] = $item;
}
if($updated && saveStartItemFile($current_file, $new_items)) {
$cmd_info = "{$current_type_name} {$name} 已更新";
adminlog('edit_startitem', $name, $current_ruleset);
$startitems = parseStartItemFile($current_file);
$page_items = array_slice($startitems, $start, $showlimit);
} else {
$cmd_info = "更新失败";
}
} elseif($command == 'add') {
$command = 'add_form';
} elseif($command == 'save_add') {
$new_item = array(
'name' => trim($name),
'type' => trim($type),
'effect' => trim($effect),
'durability' => trim($durability),
'subtype' => trim($subtype)
);
$startitems[] = $new_item;
if(saveStartItemFile($current_file, $startitems)) {
$cmd_info = "{$current_type_name} {$name} 已添加";
adminlog('add_startitem', $name, $current_ruleset);
$startitems = parseStartItemFile($current_file);
$page_items = array_slice($startitems, $start, $showlimit);
} else {
$cmd_info = "添加失败";
}
}
include template('admin_startitemsmng');
?>
<?php
if(!defined('IN_ADMIN')) {
exit('Access Denied');
}
// 引入资源管理公共函数
require_once GAME_ROOT.'./include/admin/resourcemng.php';
if(!isset($command)){$command = 'list';}
if(!isset($start)){$start = 0;}
if(!isset($search_term)){$search_term = '';}
if(!isset($pagemode)){$pagemode = '';}
if(!isset($ruleset)){$ruleset = 'default';}
$cmd_info = '';
$start = getstart($start,$pagemode);
$current_ruleset = $ruleset;
$available_rulesets = getRulesetList();
// 获取资源文件路径
$resource_path = getCurrentRulesetPath($current_ruleset);
$npc_file = $resource_path . 'npc_1.php';
// 解析NPC文件
function parseNPCFile($file_path) {
$npcs = array();
if(!file_exists($file_path)) {
return $npcs;
}
// 包含NPC文件
include $file_path;
if(isset($npcinfo) && is_array($npcinfo)) {
foreach($npcinfo as $npc_id => $npc_data) {
$npc_summary = array(
'id' => $npc_id,
'mode' => isset($npc_data['mode']) ? $npc_data['mode'] : 1,
'num' => isset($npc_data['num']) ? $npc_data['num'] : 1,
'club' => isset($npc_data['club']) ? $npc_data['club'] : 0,
'pls' => isset($npc_data['pls']) ? $npc_data['pls'] : 0,
'mhp' => isset($npc_data['mhp']) ? $npc_data['mhp'] : 100,
'msp' => isset($npc_data['msp']) ? $npc_data['msp'] : 100,
'att' => isset($npc_data['att']) ? $npc_data['att'] : 10,
'def' => isset($npc_data['def']) ? $npc_data['def'] : 10,
'lvl' => isset($npc_data['lvl']) ? $npc_data['lvl'] : 1,
'money' => isset($npc_data['money']) ? $npc_data['money'] : 0,
'sub_count' => 0,
'sub_names' => array()
);
// 统计子NPC
if(isset($npc_data['sub']) && is_array($npc_data['sub'])) {
$npc_summary['sub_count'] = count($npc_data['sub']);
foreach($npc_data['sub'] as $sub_npc) {
if(isset($sub_npc['name'])) {
$npc_summary['sub_names'][] = $sub_npc['name'];
}
}
}
$npcs[] = $npc_summary;
}
}
return $npcs;
}
// 获取NPC详细信息
function getNPCDetail($file_path, $npc_id) {
if(!file_exists($file_path)) {
return null;
}
include $file_path;
if(isset($npcinfo[$npc_id])) {
return $npcinfo[$npc_id];
}
return null;
}
// 保存NPC文件
function saveNPCFile($file_path, $npcinfo) {
$content = "<?php\n\n";
$content .= "\tif(!defined('IN_GAME')) exit('Access Denied');\n\n";
$content .= "\t\$npcinit = array\n\t(\n";
$content .= "\t\t'name' => '',\t'pass' => 'bra', 'gd' => 'm',\t'icon' => 0,\t'club' => 0,\t\n";
$content .= "\t\t'mhp' => 0,\t'msp' => 0,\t'att' => 0,\t'def' => 0,\t'pls' => 0,\t'lvl' => 0,\n";
$content .= "\t\t'money' => 0,\t'inf' => '',\t'rage' => 0,\t'pose' => 0,\t'tactic' => 0,\t\n";
$content .= "\t\t'killnum' => 0,\t'state' => 1,\t'teamID' => '',\t'teamPass' => '','bid' => 0,\n";
$content .= "\t\t'horizon' => 0, 'clbpara' => Array(),\n";
$content .= "\t\t'wp' => 0, 'wk' => 0, 'wc' => 0, 'wg' => 0, 'wd' => 0, 'wf' => 0, 'skills' => 0, 'rp' => 0,\n";
$content .= "\t\t'wep' => '',\t'wepk' => '',\t'wepe' => 0,\t'weps' => 0,\t'wepsk' => '',\n";
$content .= "\t\t'arb' => '',\t'arbk' => '',\t'arbe' => 0,\t'arbs' => 0,\t'arbsk' => '',\n";
$content .= "\t\t'arh' => '',\t'arhk' => '',\t'arhe' => 0,\t'arhs' => 0,\t'arhsk' => '',\n";
$content .= "\t\t'arf' => '',\t'arfk' => '',\t'arfe' => 0,\t'arfs' => 0,\t'arfsk' => '',\n";
$content .= "\t\t'ara' => '',\t'arak' => '',\t'arae' => 0,\t'aras' => 0,\t'arask' => '',\n";
$content .= "\t\t'art' => '',\t'artk' => '',\t'arte' => 0,\t'arts' => 0,\t'artsk' => '',\n";
for($i = 0; $i <= 6; $i++) {
$content .= "\t\t'itm{$i}' => '',\t'itmk{$i}' => '',\t'itme{$i}' => 0,\t'itms{$i}' => 0,\t'itmsk{$i}' => '',\n";
}
$content .= "\t);\n";
$content .= "\t\$npcinfo = array\n\t( \n";
foreach($npcinfo as $npc_id => $npc_data) {
$content .= "\t//{$npc_id}\n";
$content .= "\t{$npc_id} => " . var_export($npc_data, true) . ",\n\n";
}
$content .= "\t);\n?>";
return file_put_contents($file_path, $content);
}
// 处理命令
$npcs = parseNPCFile($npc_file);
$total_npcs = count($npcs);
if($command == 'search' && !empty($search_term)) {
$filtered_npcs = array();
foreach($npcs as $npc) {
$found = false;
foreach($npc['sub_names'] as $name) {
if(stripos($name, $search_term) !== false) {
$found = true;
break;
}
}
if($found || stripos($npc['id'], $search_term) !== false) {
$filtered_npcs[] = $npc;
}
}
$npcs = $filtered_npcs;
$total_npcs = count($npcs);
}
// 分页处理
$showlimit = 10;
$page_npcs = array_slice($npcs, $start, $showlimit);
if($command == 'edit' && isset($edit_id)) {
$edit_id = (int)$edit_id;
$edit_npc = getNPCDetail($npc_file, $edit_id);
if(!$edit_npc) {
$cmd_info = "找不到指定的NPC";
} else {
$command = 'edit_form';
}
}
include template('admin_startnpcsmng');
?>
<div class="subtitle">地图物品管理</div>
<div style="margin: 10px 0;">
<strong>当前资源:</strong>
<!--{if $current_ruleset == 'default'}-->
默认资源 (gamedata/cache/mapitem_1.php)
<!--{else}-->
RuleSet: $current_ruleset (gamedata/ruleset/$current_ruleset/cache/mapitem_1.php)
<!--{/if}-->
</div>
<!--{if $cmd_info}-->
<div style="color: red; margin: 10px 0;">$cmd_info</div>
<!--{/if}-->
<!--{if $command == 'edit_form'}-->
<div class="subtitle">编辑物品</div>
<form method="post" action="admin.php">
<input type="hidden" name="mode" value="mapitemsmng">
<input type="hidden" name="command" value="save_edit">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="edit_line" value="$edit_item['line_num']">
<table class="admin">
<tr><td>禁数:</td><td><input type="text" name="ban_time" value="$edit_item['ban_time']" size="10"></td></tr>
<tr><td>地图:</td><td><input type="text" name="location" value="$edit_item['location']" size="10"></td></tr>
<tr><td>数量:</td><td><input type="text" name="quantity" value="$edit_item['quantity']" size="10"></td></tr>
<tr><td>物品名称:</td><td><input type="text" name="name" value="$edit_item['name']" size="30"></td></tr>
<tr><td>类别:</td><td><input type="text" name="type" value="$edit_item['type']" size="10"></td></tr>
<tr><td>效果:</td><td><input type="text" name="effect" value="$edit_item['effect']" size="10"></td></tr>
<tr><td>耐久:</td><td><input type="text" name="durability" value="$edit_item['durability']" size="10"></td></tr>
<tr><td>子类别:</td><td><input type="text" name="subtype" value="$edit_item['subtype']" size="10"></td></tr>
<tr><td>itmpara:</td><td><input type="text" name="itmpara" value="$edit_item['itmpara']" size="20"></td></tr>
<tr><td colspan="2">
<input type="submit" value="保存修改">
<input type="button" value="取消" onclick="history.back();">
</td></tr>
</table>
</form>
<!--{elseif $command == 'add_form'}-->
<div class="subtitle">添加新物品</div>
<form method="post" action="admin.php">
<input type="hidden" name="mode" value="mapitemsmng">
<input type="hidden" name="command" value="save_add">
<input type="hidden" name="ruleset" value="$current_ruleset">
<table class="admin">
<tr><td>禁数:</td><td><input type="text" name="ban_time" value="0" size="10"></td></tr>
<tr><td>地图:</td><td><input type="text" name="location" value="99" size="10"></td></tr>
<tr><td>数量:</td><td><input type="text" name="quantity" value="1" size="10"></td></tr>
<tr><td>物品名称:</td><td><input type="text" name="name" value="" size="30"></td></tr>
<tr><td>类别:</td><td><input type="text" name="type" value="" size="10"></td></tr>
<tr><td>效果:</td><td><input type="text" name="effect" value="1" size="10"></td></tr>
<tr><td>耐久:</td><td><input type="text" name="durability" value="1" size="10"></td></tr>
<tr><td>子类别:</td><td><input type="text" name="subtype" value="" size="10"></td></tr>
<tr><td>itmpara:</td><td><input type="text" name="itmpara" value="" size="20"></td></tr>
<tr><td colspan="2">
<input type="submit" value="添加物品">
<input type="button" value="取消" onclick="history.back();">
</td></tr>
</table>
</form>
<!--{else}-->
<form method="post" name="search_form" action="admin.php">
<input type="hidden" name="mode" value="mapitemsmng">
<input type="hidden" name="command" value="search">
<input type="hidden" name="ruleset" value="$current_ruleset">
<div style="margin: 10px 0;">
<label>搜索物品:</label>
<input type="text" name="search_term" value="$search_term" placeholder="输入物品名称、类型或地点">
<input type="submit" value="搜索">
<!--{if $search_term}-->
<a href="admin.php?mode=mapitemsmng&ruleset=$current_ruleset">清除搜索</a>
<!--{/if}-->
</div>
</form>
<!--{if !file_exists($mapitem_file)}-->
<div style="color: red; margin: 20px 0;">
<strong>错误:</strong>地图物品配置文件不存在!<br>
文件路径:$mapitem_file
</div>
<!--{else}-->
<div style="margin: 10px 0;">
<strong>总计:</strong>$total_items 个物品
<!--{if $search_term}-->
(搜索结果)
<!--{/if}-->
</div>
<table class="admin" style="width: 100%;">
<tr>
<td colspan="11" class="tdtitle">地图物品列表</td>
</tr>
<tr>
<th width="50">行号</th>
<th width="60">禁数</th>
<th width="60">地图</th>
<th width="60">数量</th>
<th width="150">物品名称</th>
<th width="60">类别</th>
<th width="60">效果</th>
<th width="60">耐久</th>
<th width="60">子类别</th>
<th width="100">itmpara</th>
<th width="80">操作</th>
</tr>
<!--{if empty($page_items)}-->
<tr>
<td colspan="11" style="text-align: center; color: gray;">
<!--{if $search_term}-->
没有找到匹配的物品
<!--{else}-->
没有物品数据
<!--{/if}-->
</td>
</tr>
<!--{else}-->
<!--{loop $page_items $item}-->
<tr>
<td>$item['line_num']</td>
<td>
<!--{if $item['ban_time'] == '99'}-->
每禁
<!--{else}-->
$item['ban_time']禁
<!--{/if}-->
</td>
<td>
<!--{if $item['location'] == '99'}-->
全图
<!--{elseif isset($plsinfo[$item['location']])}-->
$plsinfo[$item['location']]
<!--{else}-->
$item['location']
<!--{/if}-->
</td>
<td>$item['quantity']</td>
<td><strong>$item['name']</strong></td>
<td>$item['type']</td>
<td>$item['effect']</td>
<td>$item['durability']</td>
<td>$item['subtype']</td>
<td>
<!--{if $item['itmpara']}-->
<span title="$item['itmpara']">$item['itmpara']</span>
<!--{else}-->
-
<!--{/if}-->
</td>
<td>
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="mapitemsmng">
<input type="hidden" name="command" value="edit">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="edit_line" value="$item['line_num']">
<input type="submit" value="编辑" style="width: 40px; font-size: 11px;">
</form>
<form method="post" action="admin.php" style="display: inline;" onsubmit="return confirm('确定要删除物品 $item[name] 吗?');">
<input type="hidden" name="mode" value="mapitemsmng">
<input type="hidden" name="command" value="delete">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="delete_line" value="$item['line_num']">
<input type="submit" value="删除" style="width: 40px; font-size: 11px; color: red;">
</form>
</td>
</tr>
<!--{/loop}-->
<!--{/if}-->
</table>
<!--{if $total_items > $showlimit}-->
<div style="margin: 10px 0;">
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="mapitemsmng">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="search_term" value="$search_term">
<input type="hidden" name="pagemode" value="up">
<input type="hidden" name="start" value="$start">
<input type="submit" value="上一页" <!--{if $start <= 0}-->disabled<!--{/if}-->>
</form>
<span style="margin: 0 10px;">
<!--{echo $start + 1}--><!--{echo min($start + $showlimit, $total_items)--> 项,共 $total_items 项
</span>
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="mapitemsmng">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="search_term" value="$search_term">
<input type="hidden" name="pagemode" value="down">
<input type="hidden" name="start" value="$start">
<input type="submit" value="下一页" <!--{if $start + $showlimit >= $total_items}-->disabled<!--{/if}-->>
</form>
</div>
<!--{/if}-->
<div style="margin: 20px 0;">
<form method="post" action="admin.php">
<input type="hidden" name="mode" value="mapitemsmng">
<input type="hidden" name="command" value="add">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="submit" value="添加新物品" style="padding: 5px 15px;">
</form>
</div>
<!--{/if}-->
<!--{/if}-->
<div style="margin: 20px 0;">
<h3>字段说明</h3>
<ul>
<li><strong>禁数</strong>:物品出现时间(0=开局,1=1禁,2=2禁,99=每禁都刷)</li>
<li><strong>地图</strong>:物品所在地图(数字=地区位置,99=全图随机掉落)</li>
<li><strong>数量</strong>:每次刷新的物品数量</li>
<li><strong>类别</strong>:物品类型代码(如WG=枪械,WK=刀具,HS=体力药等)</li>
<li><strong>子类别</strong>:物品特殊属性代码</li>
<li><strong>itmpara</strong>:物品参数,用于特殊物品的额外配置</li>
</ul>
</div>
......@@ -98,43 +98,6 @@
</tr>
</table>
</td>
<td valign="top">
<table class="admin">
<tr>
<td colspan=3 class="tdtitle">游戏资源</td>
</tr>
<tr>
<th>$lang['options']</th>
<th width="240">$lang['comments']</th>
<th width="30">$lang['groups']</th>
</tr>
<tr height="45px">
<td><input type="submit" style="width:100;height:40;" value="$lang['resourcemng']" onclick="$('command').value='resourcemng'" <!--{if $mygroup < $admin_cmd_list['resourcemng']}-->disabled="true"<!--{/if}-->></td>
<td>$lang['resourcemng_comment']</td>
<td>$admin_cmd_list['resourcemng']</td>
</tr>
<tr height="45px">
<td><input type="submit" style="width:100;height:40;" value="$lang['mapitemsmng']" onclick="$('command').value='mapitemsmng'" <!--{if $mygroup < $admin_cmd_list['mapitemsmng']}-->disabled="true"<!--{/if}-->></td>
<td>$lang['mapitemsmng_comment']</td>
<td>$admin_cmd_list['mapitemsmng']</td>
</tr>
<tr height="45px">
<td><input type="submit" style="width:100;height:40;" value="$lang['shopitemsmng']" onclick="$('command').value='shopitemsmng'" <!--{if $mygroup < $admin_cmd_list['shopitemsmng']}-->disabled="true"<!--{/if}-->></td>
<td>$lang['shopitemsmng_comment']</td>
<td>$admin_cmd_list['shopitemsmng']</td>
</tr>
<tr height="45px">
<td><input type="submit" style="width:100;height:40;" value="$lang['startitemsmng']" onclick="$('command').value='startitemsmng'" <!--{if $mygroup < $admin_cmd_list['startitemsmng']}-->disabled="true"<!--{/if}-->></td>
<td>$lang['startitemsmng_comment']</td>
<td>$admin_cmd_list['startitemsmng']</td>
</tr>
<tr height="45px">
<td><input type="submit" style="width:100;height:40;" value="$lang['startnpcsmng']" onclick="$('command').value='startnpcsmng'" <!--{if $mygroup < $admin_cmd_list['startnpcsmng']}-->disabled="true"<!--{/if}-->></td>
<td>$lang['startnpcsmng_comment']</td>
<td>$admin_cmd_list['startnpcsmng']</td>
</tr>
</table>
</td>
</tr>
</table>
......
<div class="subtitle">游戏资源管理</div>
<form method="post" name="resourcemng" action="admin.php">
<input type="hidden" name="mode" value="resourcemng">
<div style="margin: 10px 0;">
<label for="ruleset">选择资源模式:</label>
<select name="ruleset" id="ruleset" onchange="this.form.submit();">
<!--{loop $available_rulesets $key $name}-->
<option value="$key" <!--{if $current_ruleset == $key}-->selected<!--{/if}-->>$name</option>
<!--{/loop}-->
</select>
</div>
</form>
<div style="margin: 20px 0;">
<strong>当前资源路径:</strong>
<!--{if $current_ruleset == 'default'}-->
gamedata/cache/
<!--{else}-->
gamedata/ruleset/$current_ruleset/cache/
<!--{/if}-->
</div>
<table class="admin" style="width: 100%;">
<tr>
<td colspan="5" class="tdtitle">资源文件状态</td>
</tr>
<tr>
<th width="200">资源文件</th>
<th width="150">文件名</th>
<th width="80">状态</th>
<th width="80">所需权限</th>
<th width="120">操作</th>
</tr>
<!--{loop $resource_status $filename $info}-->
<tr>
<td>$info['name']</td>
<td>$filename</td>
<td>
<!--{if $info['exists']}-->
<span style="color: green;">存在</span>
<!--{else}-->
<span style="color: red;">不存在</span>
<!--{/if}-->
</td>
<td>$info['permission']</td>
<td>
<!--{if $mygroup >= $info['permission'] && $info['exists']}-->
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="admin_menu">
<input type="hidden" name="command" value="$info['manage_cmd']">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="submit" value="管理" style="width: 60px;">
</form>
<!--{elseif $mygroup < $info['permission']}-->
<span style="color: gray;">权限不足</span>
<!--{else}-->
<span style="color: red;">文件不存在</span>
<!--{/if}-->
</td>
</tr>
<!--{/loop}-->
</table>
<div style="margin: 20px 0;">
<h3>使用说明</h3>
<ul>
<li><strong>地图物品管理</strong>:管理各地图区域的物品刷新配置,包括刷新时间、位置、数量等</li>
<li><strong>商店物品管理</strong>:管理商店中销售的物品,包括价格、上架时间、库存等</li>
<li><strong>开局物品管理</strong>:管理玩家开局时获得的物品和武器</li>
<li><strong>开局NPC管理</strong>:管理游戏开始时出现的NPC配置</li>
</ul>
<h3>RuleSet说明</h3>
<ul>
<li><strong>默认资源</strong>:使用 gamedata/cache/ 目录下的资源文件,适用于所有房间</li>
<li><strong>RuleSet资源</strong>:使用特定RuleSet的资源文件,仅适用于对应的RuleSet房间</li>
<li>修改RuleSet资源不会影响默认资源和其他RuleSet</li>
</ul>
</div>
<div class="subtitle">商店物品管理</div>
<div style="margin: 10px 0;">
<strong>当前资源:</strong>
<!--{if $current_ruleset == 'default'}-->
默认资源 (gamedata/cache/shopitem_1.php)
<!--{else}-->
RuleSet: $current_ruleset (gamedata/ruleset/$current_ruleset/cache/shopitem_1.php)
<!--{/if}-->
</div>
<!--{if $cmd_info}-->
<div style="color: red; margin: 10px 0;">$cmd_info</div>
<!--{/if}-->
<form method="post" name="search_form" action="admin.php">
<input type="hidden" name="mode" value="shopitemsmng">
<input type="hidden" name="command" value="search">
<input type="hidden" name="ruleset" value="$current_ruleset">
<div style="margin: 10px 0;">
<label>搜索物品:</label>
<input type="text" name="search_term" value="$search_term" placeholder="输入物品名称、类型或分类">
<input type="submit" value="搜索">
<!--{if $search_term}-->
<a href="admin.php?mode=shopitemsmng&ruleset=$current_ruleset">清除搜索</a>
<!--{/if}-->
</div>
</form>
<!--{if !file_exists($shopitem_file)}-->
<div style="color: red; margin: 20px 0;">
<strong>错误:</strong>商店物品配置文件不存在!<br>
文件路径:$shopitem_file
</div>
<!--{else}-->
<div style="margin: 10px 0;">
<strong>总计:</strong>$total_items 个项目
<!--{if $search_term}-->
(搜索结果)
<!--{/if}-->
</div>
<table class="admin" style="width: 100%;">
<tr>
<td colspan="12" class="tdtitle">商店物品列表</td>
</tr>
<tr>
<th width="50">行号</th>
<th width="60">类型</th>
<th width="60">类别</th>
<th width="60">数量</th>
<th width="60">价格</th>
<th width="60">开始禁</th>
<th width="150">物品名称</th>
<th width="60">类别码</th>
<th width="60">效果</th>
<th width="60">耐久</th>
<th width="60">子类别</th>
<th width="80">操作</th>
</tr>
<!--{if empty($page_items)}-->
<tr>
<td colspan="12" style="text-align: center; color: gray;">
<!--{if $search_term}-->
没有找到匹配的项目
<!--{else}-->
没有商店数据
<!--{/if}-->
</td>
</tr>
<!--{else}-->
<!--{loop $page_items $item}-->
<tr <!--{if $item['is_separator']}-->style="background-color: #f0f0f0; font-weight: bold;"<!--{/if}-->>
<td>$item['line_num']</td>
<!--{if $item['is_separator']}-->
<td colspan="6" style="text-align: center;">
<strong>分类:$item['category_name']</strong>
</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
<!--{else}-->
<td>物品</td>
<td>$item['category']</td>
<td>$item['quantity']</td>
<td>$item['price']</td>
<td>$item['start_ban']</td>
<td><strong>$item['name']</strong></td>
<td>$item['type']</td>
<td>$item['effect']</td>
<td>$item['durability']</td>
<td>$item['subtype']</td>
<!--{/if}-->
<td>
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="shopitemsmng">
<input type="hidden" name="command" value="edit">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="edit_line" value="$item['line_num']">
<input type="submit" value="编辑" style="width: 40px; font-size: 11px;">
</form>
<form method="post" action="admin.php" style="display: inline;" onsubmit="return confirm('确定要删除这个项目吗?');">
<input type="hidden" name="mode" value="shopitemsmng">
<input type="hidden" name="command" value="delete">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="delete_line" value="$item['line_num']">
<input type="submit" value="删除" style="width: 40px; font-size: 11px; color: red;">
</form>
</td>
</tr>
<!--{/loop}-->
<!--{/if}-->
</table>
<!--{if $total_items > $showlimit}-->
<div style="margin: 10px 0;">
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="shopitemsmng">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="search_term" value="$search_term">
<input type="hidden" name="pagemode" value="up">
<input type="hidden" name="start" value="$start">
<input type="submit" value="上一页" <!--{if $start <= 0}-->disabled<!--{/if}-->>
</form>
<span style="margin: 0 10px;">
<!--{echo $start + 1}--><!--{echo min($start + $showlimit, $total_items)--> 项,共 $total_items 项
</span>
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="shopitemsmng">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="search_term" value="$search_term">
<input type="hidden" name="pagemode" value="down">
<input type="hidden" name="start" value="$start">
<input type="submit" value="下一页" <!--{if $start + $showlimit >= $total_items}-->disabled<!--{/if}-->>
</form>
</div>
<!--{/if}-->
<div style="margin: 20px 0;">
<form method="post" action="admin.php" style="display: inline; margin-right: 10px;">
<input type="hidden" name="mode" value="shopitemsmng">
<input type="hidden" name="command" value="add_item">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="submit" value="添加新物品" style="padding: 5px 15px;">
</form>
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="shopitemsmng">
<input type="hidden" name="command" value="add_category">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="submit" value="添加新分类" style="padding: 5px 15px;">
</form>
</div>
<!--{/if}-->
<div style="margin: 20px 0;">
<h3>字段说明</h3>
<ul>
<li><strong>分类行</strong>:用于分隔不同类别的商品,格式为 "类别ID,子类别,,,分类名称,,,,,"</li>
<li><strong>类别</strong>:商品所属的类别编号</li>
<li><strong>数量</strong>:每禁上架的商品数量</li>
<li><strong>价格</strong>:商品的售价</li>
<li><strong>开始禁</strong>:从第几禁开始上架(0=开局就有)</li>
<li><strong>类别码</strong>:物品类型代码(如WG=枪械,WK=刀具等)</li>
</ul>
</div>
<div class="subtitle">开局物品管理</div>
<div style="margin: 10px 0;">
<strong>当前资源:</strong>
<!--{if $current_ruleset == 'default'}-->
默认资源 (gamedata/cache/$current_file_name)
<!--{else}-->
RuleSet: $current_ruleset (gamedata/ruleset/$current_ruleset/cache/$current_file_name)
<!--{/if}-->
</div>
<!--{if $cmd_info}-->
<div style="color: red; margin: 10px 0;">$cmd_info</div>
<!--{/if}-->
<!--{if $command == 'edit_form'}-->
<div class="subtitle">编辑$current_type_name</div>
<form method="post" action="admin.php">
<input type="hidden" name="mode" value="startitemsmng">
<input type="hidden" name="command" value="save_edit">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="file_type" value="$file_type">
<input type="hidden" name="edit_line" value="$edit_item['line_num']">
<table class="admin">
<tr><td>名称:</td><td><input type="text" name="name" value="$edit_item['name']" size="30"></td></tr>
<tr><td>类别:</td><td><input type="text" name="type" value="$edit_item['type']" size="10"></td></tr>
<tr><td>效果:</td><td><input type="text" name="effect" value="$edit_item['effect']" size="10"></td></tr>
<tr><td>耐久:</td><td><input type="text" name="durability" value="$edit_item['durability']" size="10"></td></tr>
<tr><td>子类别:</td><td><input type="text" name="subtype" value="$edit_item['subtype']" size="10"></td></tr>
<tr><td colspan="2">
<input type="submit" value="保存修改">
<input type="button" value="取消" onclick="history.back();">
</td></tr>
</table>
</form>
<!--{elseif $command == 'add_form'}-->
<div class="subtitle">添加新$current_type_name</div>
<form method="post" action="admin.php">
<input type="hidden" name="mode" value="startitemsmng">
<input type="hidden" name="command" value="save_add">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="file_type" value="$file_type">
<table class="admin">
<tr><td>名称:</td><td><input type="text" name="name" value="" size="30"></td></tr>
<tr><td>类别:</td><td><input type="text" name="type" value="" size="10"></td></tr>
<tr><td>效果:</td><td><input type="text" name="effect" value="1" size="10"></td></tr>
<tr><td>耐久:</td><td><input type="text" name="durability" value="1" size="10"></td></tr>
<tr><td>子类别:</td><td><input type="text" name="subtype" value="" size="10"></td></tr>
<tr><td colspan="2">
<input type="submit" value="添加$current_type_name">
<input type="button" value="取消" onclick="history.back();">
</td></tr>
</table>
</form>
<!--{else}-->
<div style="margin: 10px 0;">
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="startitemsmng">
<input type="hidden" name="ruleset" value="$current_ruleset">
<label>文件类型:</label>
<select name="file_type" onchange="this.form.submit();">
<option value="items" <!--{if $file_type == 'items'}-->selected<!--{/if}-->>物品 (stitem_1.php)</option>
<option value="weapons" <!--{if $file_type == 'weapons'}-->selected<!--{/if}-->>武器 (stwep_1.php)</option>
</select>
</form>
</div>
<form method="post" name="search_form" action="admin.php">
<input type="hidden" name="mode" value="startitemsmng">
<input type="hidden" name="command" value="search">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="file_type" value="$file_type">
<div style="margin: 10px 0;">
<label>搜索$current_type_name:</label>
<input type="text" name="search_term" value="$search_term" placeholder="输入名称或类型">
<input type="submit" value="搜索">
<!--{if $search_term}-->
<a href="admin.php?mode=startitemsmng&ruleset=$current_ruleset&file_type=$file_type">清除搜索</a>
<!--{/if}-->
</div>
</form>
<!--{if !file_exists($current_file)}-->
<div style="color: red; margin: 20px 0;">
<strong>错误:</strong>开局$current_type_name 配置文件不存在!<br>
文件路径:$current_file
</div>
<!--{else}-->
<div style="margin: 10px 0;">
<strong>总计:</strong>$total_items 个$current_type_name
<!--{if $search_term}-->
(搜索结果)
<!--{/if}-->
</div>
<table class="admin" style="width: 100%;">
<tr>
<td colspan="7" class="tdtitle">开局$current_type_name 列表</td>
</tr>
<tr>
<th width="50">行号</th>
<th width="200">名称</th>
<th width="80">类别</th>
<th width="80">效果</th>
<th width="80">耐久</th>
<th width="80">子类别</th>
<th width="100">操作</th>
</tr>
<!--{if empty($page_items)}-->
<tr>
<td colspan="7" style="text-align: center; color: gray;">
<!--{if $search_term}-->
没有找到匹配的$current_type_name
<!--{else}-->
没有$current_type_name 数据
<!--{/if}-->
</td>
</tr>
<!--{else}-->
<!--{loop $page_items $item}-->
<tr>
<td>$item['line_num']</td>
<td><strong>$item['name']</strong></td>
<td>$item['type']</td>
<td>$item['effect']</td>
<td>$item['durability']</td>
<td>$item['subtype']</td>
<td>
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="startitemsmng">
<input type="hidden" name="command" value="edit">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="file_type" value="$file_type">
<input type="hidden" name="edit_line" value="$item['line_num']">
<input type="submit" value="编辑" style="width: 40px; font-size: 11px;">
</form>
<form method="post" action="admin.php" style="display: inline;" onsubmit="return confirm('确定要删除$current_type_name $item[name] 吗?');">
<input type="hidden" name="mode" value="startitemsmng">
<input type="hidden" name="command" value="delete">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="file_type" value="$file_type">
<input type="hidden" name="delete_line" value="$item['line_num']">
<input type="submit" value="删除" style="width: 40px; font-size: 11px; color: red;">
</form>
</td>
</tr>
<!--{/loop}-->
<!--{/if}-->
</table>
<!--{if $total_items > $showlimit}-->
<div style="margin: 10px 0;">
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="startitemsmng">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="file_type" value="$file_type">
<input type="hidden" name="search_term" value="$search_term">
<input type="hidden" name="pagemode" value="up">
<input type="hidden" name="start" value="$start">
<input type="submit" value="上一页" <!--{if $start <= 0}-->disabled<!--{/if}-->>
</form>
<span style="margin: 0 10px;">
<!--{echo $start + 1}--><!--{echo min($start + $showlimit, $total_items)--> 项,共 $total_items 项
</span>
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="startitemsmng">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="file_type" value="$file_type">
<input type="hidden" name="search_term" value="$search_term">
<input type="hidden" name="pagemode" value="down">
<input type="hidden" name="start" value="$start">
<input type="submit" value="下一页" <!--{if $start + $showlimit >= $total_items}-->disabled<!--{/if}-->>
</form>
</div>
<!--{/if}-->
<div style="margin: 20px 0;">
<form method="post" action="admin.php">
<input type="hidden" name="mode" value="startitemsmng">
<input type="hidden" name="command" value="add">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="file_type" value="$file_type">
<input type="submit" value="添加新$current_type_name" style="padding: 5px 15px;">
</form>
</div>
<!--{/if}-->
<!--{/if}-->
<div style="margin: 20px 0;">
<h3>字段说明</h3>
<ul>
<li><strong>名称</strong>:物品或武器的显示名称</li>
<li><strong>类别</strong>:物品类型代码(如WG=枪械,WK=刀具,HS=体力药等)</li>
<li><strong>效果</strong>:物品的效果数值</li>
<li><strong>耐久</strong>:物品的耐久度数值</li>
<li><strong>子类别</strong>:物品的特殊属性代码</li>
</ul>
<h3>文件说明</h3>
<ul>
<li><strong>stitem_1.php</strong>:玩家开局获得的物品(非武器类)</li>
<li><strong>stwep_1.php</strong>:玩家开局获得的武器</li>
</ul>
</div>
<div class="subtitle">开局NPC管理</div>
<div style="margin: 10px 0;">
<strong>当前资源:</strong>
<!--{if $current_ruleset == 'default'}-->
默认资源 (gamedata/cache/npc_1.php)
<!--{else}-->
RuleSet: $current_ruleset (gamedata/ruleset/$current_ruleset/cache/npc_1.php)
<!--{/if}-->
</div>
<!--{if $cmd_info}-->
<div style="color: red; margin: 10px 0;">$cmd_info</div>
<!--{/if}-->
<!--{if $command == 'edit_form'}-->
<div class="subtitle">编辑NPC (ID: $edit_id)</div>
<div style="margin: 10px 0; padding: 10px; background-color: #f0f0f0;">
<strong>注意:</strong>NPC数据结构复杂,建议使用现有的NPC管理功能进行详细编辑。<br>
这里仅显示基本信息,完整编辑请使用"当前游戏管理"中的"NPC数据管理"功能。
</div>
<table class="admin">
<tr><td colspan="2" class="tdtitle">基本信息</td></tr>
<tr><td>NPC ID:</td><td>$edit_id</td></tr>
<tr><td>模式:</td><td>$edit_npc['mode']</td></tr>
<tr><td>数量:</td><td>$edit_npc['num']</td></tr>
<tr><td>社团:</td><td>$edit_npc['club']</td></tr>
<tr><td>位置:</td><td>$edit_npc['pls']</td></tr>
<tr><td>最大HP:</td><td>$edit_npc['mhp']</td></tr>
<tr><td>最大SP:</td><td>$edit_npc['msp']</td></tr>
<tr><td>攻击力:</td><td>$edit_npc['att']</td></tr>
<tr><td>防御力:</td><td>$edit_npc['def']</td></tr>
<tr><td>等级:</td><td>$edit_npc['lvl']</td></tr>
<tr><td>金钱:</td><td>$edit_npc['money']</td></tr>
</table>
<!--{if isset($edit_npc['sub']) && is_array($edit_npc['sub'])}-->
<table class="admin" style="margin-top: 20px;">
<tr><td colspan="4" class="tdtitle">子NPC列表</td></tr>
<tr>
<th>序号</th>
<th>名称</th>
<th>头像</th>
<th>武器</th>
</tr>
<!--{loop $edit_npc['sub'] $index $sub_npc}-->
<tr>
<td>$index</td>
<td><!--{if isset($sub_npc['name'])}-->$sub_npc['name']<!--{else}-->未设置<!--{/if}--></td>
<td><!--{if isset($sub_npc['icon'])}-->$sub_npc['icon']<!--{else}-->-<!--{/if}--></td>
<td><!--{if isset($sub_npc['wep'])}-->$sub_npc['wep']<!--{else}-->-<!--{/if}--></td>
</tr>
<!--{/loop}-->
</table>
<!--{/if}-->
<div style="margin: 20px 0;">
<input type="button" value="返回列表" onclick="history.back();">
</div>
<!--{else}-->
<form method="post" name="search_form" action="admin.php">
<input type="hidden" name="mode" value="startnpcsmng">
<input type="hidden" name="command" value="search">
<input type="hidden" name="ruleset" value="$current_ruleset">
<div style="margin: 10px 0;">
<label>搜索NPC:</label>
<input type="text" name="search_term" value="$search_term" placeholder="输入NPC ID或名称">
<input type="submit" value="搜索">
<!--{if $search_term}-->
<a href="admin.php?mode=startnpcsmng&ruleset=$current_ruleset">清除搜索</a>
<!--{/if}-->
</div>
</form>
<!--{if !file_exists($npc_file)}-->
<div style="color: red; margin: 20px 0;">
<strong>错误:</strong>开局NPC配置文件不存在!<br>
文件路径:$npc_file
</div>
<!--{else}-->
<div style="margin: 10px 0;">
<strong>总计:</strong>$total_npcs 个NPC配置
<!--{if $search_term}-->
(搜索结果)
<!--{/if}-->
</div>
<table class="admin" style="width: 100%;">
<tr>
<td colspan="9" class="tdtitle">开局NPC列表</td>
</tr>
<tr>
<th width="60">NPC ID</th>
<th width="60">模式</th>
<th width="60">数量</th>
<th width="60">社团</th>
<th width="60">位置</th>
<th width="80">HP/SP</th>
<th width="80">攻/防</th>
<th width="150">子NPC</th>
<th width="100">操作</th>
</tr>
<!--{if empty($page_npcs)}-->
<tr>
<td colspan="9" style="text-align: center; color: gray;">
<!--{if $search_term}-->
没有找到匹配的NPC
<!--{else}-->
没有NPC数据
<!--{/if}-->
</td>
</tr>
<!--{else}-->
<!--{loop $page_npcs $npc}-->
<tr>
<td><strong>$npc['id']</strong></td>
<td>$npc['mode']</td>
<td>$npc['num']</td>
<td>$npc['club']</td>
<td>$npc['pls']</td>
<td>$npc['mhp']/$npc['msp']</td>
<td>$npc['att']/$npc['def']</td>
<td>
<!--{if $npc['sub_count'] > 0}-->
$npc['sub_count']个:
<!--{loop $npc['sub_names'] $name}-->
$name<!--{if !$loop['last']}-->, <!--{/if}-->
<!--{/loop}-->
<!--{else}-->
<!--{/if}-->
</td>
<td>
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="startnpcsmng">
<input type="hidden" name="command" value="edit">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="edit_id" value="$npc['id']">
<input type="submit" value="查看" style="width: 40px; font-size: 11px;">
</form>
</td>
</tr>
<!--{/loop}-->
<!--{/if}-->
</table>
<!--{if $total_npcs > $showlimit}-->
<div style="margin: 10px 0;">
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="startnpcsmng">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="search_term" value="$search_term">
<input type="hidden" name="pagemode" value="up">
<input type="hidden" name="start" value="$start">
<input type="submit" value="上一页" <!--{if $start <= 0}-->disabled<!--{/if}-->>
</form>
<span style="margin: 0 10px;">
<!--{echo $start + 1}--><!--{echo min($start + $showlimit, $total_npcs)--> 项,共 $total_npcs 项
</span>
<form method="post" action="admin.php" style="display: inline;">
<input type="hidden" name="mode" value="startnpcsmng">
<input type="hidden" name="ruleset" value="$current_ruleset">
<input type="hidden" name="search_term" value="$search_term">
<input type="hidden" name="pagemode" value="down">
<input type="hidden" name="start" value="$start">
<input type="submit" value="下一页" <!--{if $start + $showlimit >= $total_npcs}-->disabled<!--{/if}-->>
</form>
</div>
<!--{/if}-->
<!--{/if}-->
<!--{/if}-->
<div style="margin: 20px 0;">
<h3>功能说明</h3>
<ul>
<li><strong>查看功能</strong>:显示NPC的基本信息和子NPC列表</li>
<li><strong>详细编辑</strong>:由于NPC数据结构复杂,建议使用"当前游戏管理"中的"NPC数据管理"功能</li>
<li><strong>复用逻辑</strong>:本功能复用现有的NPC管理逻辑,确保数据一致性</li>
</ul>
<h3>字段说明</h3>
<ul>
<li><strong>模式</strong>:NPC的行为模式(1=普通,2=特殊等)</li>
<li><strong>数量</strong>:该配置生成的NPC数量</li>
<li><strong>社团</strong>:NPC所属的社团编号</li>
<li><strong>位置</strong>:NPC的初始位置</li>
<li><strong>子NPC</strong>:该配置包含的具体NPC角色</li>
</ul>
</div>
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