背包和物品列表增强:支持显示法术的计算方式和基础数值
新增功能:
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
c065e19113
commit
ab90eb8435
|
|
@ -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,18 +269,30 @@ class ItemDisplay
|
|||
$parts[] = self::$gray . "[{$typeName}]" . self::$reset;
|
||||
}
|
||||
|
||||
// 主属性(简洁版)
|
||||
// 主属性(简洁版)或法术信息
|
||||
$type = $item['type'] ?? '';
|
||||
if ($type === 'spell') {
|
||||
// 显示法术的计算方式和基础数值
|
||||
$spellInfo = self::formatSpellCompact($item);
|
||||
if ($spellInfo) {
|
||||
$parts[] = $spellInfo;
|
||||
}
|
||||
} else {
|
||||
// 显示装备的属性
|
||||
$statsStr = self::formatStatsCompact($item);
|
||||
if ($statsStr) {
|
||||
$parts[] = $statsStr;
|
||||
}
|
||||
}
|
||||
|
||||
// 词条数量提示
|
||||
// 词条数量提示(仅限装备)
|
||||
if ($type !== 'spell') {
|
||||
$affixes = $item['affixes'] ?? [];
|
||||
if (!empty($affixes)) {
|
||||
$count = count($affixes);
|
||||
$parts[] = self::$cyan . implode(',',$affixes);
|
||||
}
|
||||
}
|
||||
|
||||
return implode(" ", $parts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user