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