From ab90eb8435470249f42efa451538c9e03aed6660 Mon Sep 17 00:00:00 2001 From: hant Date: Thu, 4 Dec 2025 23:03:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=8C=E5=8C=85=E5=92=8C=E7=89=A9=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=A2=9E=E5=BC=BA=EF=BC=9A=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=B3=95=E6=9C=AF=E7=9A=84=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E5=92=8C=E5=9F=BA=E7=A1=80=E6=95=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增功能: - ItemDisplay.formatSpellCompact: 格式化法术的简洁信息 - 显示计算方式(缩写形式) - 显示品质相关的基础数值(伤害/治疗倍数) - ItemDisplay.renderListItem: 增强支持法术物品显示 - 法术物品显示计算方式和基础数值 - 装备物品仍显示属性和词条 改进内容: - 背包列表中显示法术的详细计算方式(如 [魔攻] 1.6x) - 法术物品不显示词条(仅装备显示词条) - InventoryPanel 导入 SpellDisplay 以支持未来扩展 - 保持与战斗系统中法术显示的一致性 格式示例: 装备: 名称 Lv.5 +3 (武器) (物攻+50 暴伤+30) 3词条 法术: 名称 Lv.5 (法术) [魔攻] 1.6x 🧙 Generated with Claude Code Co-Authored-By: Claude --- src/Core/ItemDisplay.php | 74 +++++++++++++++++++++++++++++----- src/Modules/InventoryPanel.php | 1 + 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/src/Core/ItemDisplay.php b/src/Core/ItemDisplay.php index 75990b3..91ffd14 100644 --- a/src/Core/ItemDisplay.php +++ b/src/Core/ItemDisplay.php @@ -115,6 +115,50 @@ class ItemDisplay return $stats ? self::$green . "(" . implode(" ", $stats) . ")" . self::$reset : ""; } + /** + * 格式化法术的简洁信息(用于列表显示) + */ + public static function formatSpellCompact(array $spell): string + { + $calcType = $spell['calc_type'] ?? 'matk'; + $spellType = $spell['spellType'] ?? $spell['type'] ?? 'unknown'; + + $calcTypeMap = [ + 'matk' => '魔攻', + 'patk' => '物攻', + 'hybrid' => '混合', + 'hp_percent' => 'HP%', + 'crit_heal' => '暴治', + 'crit_damage' => '暴伤', + 'defense' => '防御', + 'low_def_bonus' => '克低防', + 'matk_scaled' => '群伤', + 'dispersed_damage' => '分散伤', + 'crit_aoe' => '暴范', + 'smart_heal' => '智能治', + 'hp_missing' => '缺血治', + 'team_sync' => '队伍同步', + ]; + + $calcDesc = $calcTypeMap[$calcType] ?? $calcType; + + // 根据法术类型显示基础数值 + $valueStr = ''; + if ($spellType === 'damage_single' || $spellType === 'damage_aoe') { + $damageRatio = $spell['damage_ratio'] ?? [1.2, 1.6, 2.0, 2.6]; + $qualityIndex = self::getQualityIndex($spell['quality'] ?? 'common'); + $ratio = $damageRatio[$qualityIndex] ?? 1.0; + $valueStr = self::$green . "{$ratio}x" . self::$reset; + } elseif ($spellType === 'heal_single' || $spellType === 'heal_aoe') { + $healRatio = $spell['heal_ratio'] ?? [0.5, 0.8, 1.2, 1.8]; + $qualityIndex = self::getQualityIndex($spell['quality'] ?? 'common'); + $ratio = $healRatio[$qualityIndex] ?? 0.5; + $valueStr = self::$green . "{$ratio}x" . self::$reset; + } + + return self::$cyan . "[{$calcDesc}]" . self::$reset . ($valueStr ? " " . $valueStr : ""); + } + /** * 格式化主属性(多行详细版) */ @@ -225,17 +269,29 @@ class ItemDisplay $parts[] = self::$gray . "[{$typeName}]" . self::$reset; } - // 主属性(简洁版) - $statsStr = self::formatStatsCompact($item); - if ($statsStr) { - $parts[] = $statsStr; + // 主属性(简洁版)或法术信息 + $type = $item['type'] ?? ''; + if ($type === 'spell') { + // 显示法术的计算方式和基础数值 + $spellInfo = self::formatSpellCompact($item); + if ($spellInfo) { + $parts[] = $spellInfo; + } + } else { + // 显示装备的属性 + $statsStr = self::formatStatsCompact($item); + if ($statsStr) { + $parts[] = $statsStr; + } } - // 词条数量提示 - $affixes = $item['affixes'] ?? []; - if (!empty($affixes)) { - $count = count($affixes); - $parts[] = self::$cyan . implode(',',$affixes); + // 词条数量提示(仅限装备) + if ($type !== 'spell') { + $affixes = $item['affixes'] ?? []; + if (!empty($affixes)) { + $count = count($affixes); + $parts[] = self::$cyan . implode(',',$affixes); + } } return implode(" ", $parts); diff --git a/src/Modules/InventoryPanel.php b/src/Modules/InventoryPanel.php index 72cbcb8..cc68ddc 100644 --- a/src/Modules/InventoryPanel.php +++ b/src/Modules/InventoryPanel.php @@ -4,6 +4,7 @@ namespace Game\Modules; use Game\Core\Game; use Game\Core\Screen; use Game\Core\ItemDisplay; +use Game\Core\SpellDisplay; use Game\Core\Colors; class InventoryPanel