This commit is contained in:
hant 2025-12-04 23:52:50 +08:00
parent ba273b2cdf
commit c2a2e93ff3
10 changed files with 959 additions and 227 deletions

556
save.json

File diff suppressed because one or more lines are too long

View File

@ -1,14 +1,25 @@
<?php
// Per-dungeon spell pools
/**
* 地牢法术掉落池配置 - 重构版本
* 参考装备的掉落方式
*
* 定义各地牢可以掉落的法术类型
* 在掉落时会根据品质概率从相应的法术类型中选择具体的法术ID
*
* 法术类型:
* - heal_single: 单体治疗
* - damage_single: 单体伤害
* - damage_aoe: 群体伤害
* - heal_aoe: 群体治疗
*/
return [
1 => [1, 10],
2 => [2, 3, 11],
3 => [20, 21],
4 => [12],
5 => [4],
6 => [5, 22],
7 => [13],
8 => [13, 22],
9 => [5, 13],
// others can be added later
1 => ['heal_single', 'damage_single', 'damage_aoe'], // 七玄门 (Lv.1-5)
2 => ['damage_single', 'damage_aoe', 'heal_aoe'], // 太南谷 (Lv.5-10)
3 => ['heal_single', 'heal_aoe'], // 血色禁地 (Lv.10-15)
4 => ['damage_single', 'damage_aoe'], // 黄枫谷 (Lv.15-20)
5 => ['damage_single', 'heal_aoe'], // 燕翎堡 (Lv.20-30)
6 => ['damage_single', 'heal_aoe'], // 越京皇宫 (Lv.30-40)
7 => ['damage_aoe'], // 乱星海-魁星岛 (Lv.40-50)
8 => ['damage_aoe', 'heal_single', 'heal_aoe'], // 虚天殿 (Lv.50-60)
9 => ['damage_single', 'damage_aoe', 'heal_single'], // 外星海 (Lv.60+)
];

View File

@ -1,138 +1,313 @@
<?php
/**
* 法术系统配置
* 定义所有可用的法术及其属性
* 法术系统配置 - 丰富版本
* 法术分为四类:单体治疗、单体伤害、群体伤害、群体治疗
* 每个法术有独立的计算方式和品质参数
* 参考装备的品质系统 (common, rare, epic, legendary)
*/
return [
// 单体伤害法术
'damage_single' => [
// ============ 单体治疗法术 (heal_single) ============
'heal_single' => [
// 1. 治愈术 - 魔攻型 (恢复 = 魔攻 × 倍数 + 基础值)
1 => [
'name' => '治愈术',
'type' => 'heal_single',
'calc_type' => 'matk', // 计算方式:纯魔攻
'cost' => 15,
'level_req' => 1,
'desc' => '恢复自己或队友的生命值,效果与魔攻相关',
// 品质参数:[common, rare, epic, legendary]
'heal_ratio' => [0.5, 0.8, 1.2, 1.8], // 魔攻倍数
'heal_base' => [20, 40, 70, 120], // 基础治疗值
],
// 2. 及时救难 - 生命值百分比型 (恢复 = 自己最大生命值 × 百分比)
2 => [
'name' => '及时救难',
'type' => 'heal_single',
'calc_type' => 'hp_percent', // 计算方式:最大生命值百分比
'cost' => 20,
'level_req' => 5,
'desc' => '将自己的部分生命值转移给队友',
'heal_ratio' => [0.3, 0.4, 0.5, 0.6], // 最大生命值百分比
],
// 3. 活力术 - 混合型 (恢复 = (魔攻 + 物攻) × 倍数 + 基础值)
3 => [
'name' => '活力术',
'type' => 'heal_single',
'calc_type' => 'hybrid', // 计算方式:魔攻 + 物攻混合
'cost' => 25,
'level_req' => 12,
'desc' => '结合物理和魔法的治疗法术',
'heal_ratio' => [0.3, 0.5, 0.7, 1.0], // (魔攻+物攻) 倍数
'heal_base' => [15, 30, 50, 80],
],
// 4. 生命之泉 - 基于当前生命值缺口 (恢复 = 缺失血量 × 百分比)
4 => [
'name' => '生命之泉',
'type' => 'heal_single',
'calc_type' => 'hp_missing', // 计算方式:缺失生命值百分比
'cost' => 30,
'level_req' => 18,
'desc' => '根据队友缺失的生命值比例进行治疗',
'heal_ratio' => [0.4, 0.55, 0.7, 0.85], // 缺失生命值百分比
],
// 5. 暴击治疗 - 与暴击率相关 (恢复 = 魔攻 × 倍数 × (1 + 暴击率×特殊系数))
5 => [
'name' => '暴击治疗',
'type' => 'heal_single',
'calc_type' => 'crit_heal', // 计算方式:与暴击率相关
'cost' => 28,
'level_req' => 22,
'desc' => '暴击率越高,治疗效果越强',
'heal_ratio' => [0.4, 0.65, 0.95, 1.4], // 基础魔攻倍数
'crit_bonus' => [0.5, 0.7, 1.0, 1.5], // 暴击率加成系数
],
// 6. 援护术 - 基于防御属性 (恢复 = (物防+魔防) × 倍数 + 固定值)
6 => [
'name' => '援护术',
'type' => 'heal_single',
'calc_type' => 'defense', // 计算方式:基于防御属性
'cost' => 22,
'level_req' => 15,
'desc' => '根据防御力进行治疗,防御越高效果越好',
'heal_ratio' => [0.8, 1.2, 1.8, 2.5], // (物防+魔防) 倍数
'heal_base' => [10, 20, 35, 60],
],
],
// ============ 单体伤害法术 (damage_single) ============
'damage_single' => [
// 10. 火球术 - 魔攻型 (伤害 = 魔攻 × 倍数)
10 => [
'name' => '火球术',
'type' => 'damage_single',
'quality' => 'common',
'calc_type' => 'matk',
'cost' => 20,
'damage' => 1.2, // 伤害倍数 = 魔攻 * damage
'level_req' => 1,
'desc' => '发出一团火球,攻击单个敌人',
'desc' => '发出一团火球,对单个敌人造成伤害',
'damage_ratio' => [1.2, 1.6, 2.0, 2.6],
],
2 => [
// 11. 冰锥术 - 魔攻型
11 => [
'name' => '冰锥术',
'type' => 'damage_single',
'quality' => 'rare',
'cost' => 25,
'damage' => 1.3,
'level_req' => 5,
'calc_type' => 'matk',
'cost' => 22,
'level_req' => 6,
'desc' => '凝聚寒冰之力,发出锐利冰锥',
'damage_ratio' => [1.3, 1.8, 2.2, 3.0],
],
3 => [
// 12. 雷击术 - 物攻型 (伤害 = 物攻 × 倍数)
12 => [
'name' => '雷击术',
'type' => 'damage_single',
'quality' => 'rare',
'cost' => 30,
'damage' => 1.5,
'calc_type' => 'patk',
'cost' => 24,
'level_req' => 10,
'desc' => '召唤雷电直击单个敌人',
'desc' => '召唤雷电直击单个敌人,与物攻相关',
'damage_ratio' => [1.4, 1.9, 2.3, 3.2],
],
4 => [
// 13. 烈焰焚天 - 混合型 (伤害 = (魔攻 + 物攻) × 倍数)
13 => [
'name' => '烈焰焚天',
'type' => 'damage_single',
'quality' => 'epic',
'cost' => 45,
'damage' => 1.8,
'level_req' => 20,
'desc' => '释放强大的火焰,对单个敌人造成巨大伤害',
'calc_type' => 'hybrid',
'cost' => 35,
'level_req' => 18,
'desc' => '释放强大的火焰,伤害与双攻相关',
'damage_ratio' => [0.8, 1.1, 1.5, 2.0],
],
5 => [
// 14. 诛仙剑气 - 物攻 + 暴击型 (伤害 = 物攻 × 倍数 × (1 + 暴击伤害系数))
14 => [
'name' => '诛仙剑气',
'type' => 'damage_single',
'quality' => 'legendary',
'cost' => 60,
'damage' => 2.2,
'level_req' => 35,
'desc' => '凝聚剑意,发出致命一击',
'calc_type' => 'crit_damage',
'cost' => 40,
'level_req' => 28,
'desc' => '凝聚剑意,暴击伤害系数越高效果越强',
'damage_ratio' => [1.5, 2.0, 2.6, 3.5],
'crit_dmg_bonus' => [0.3, 0.5, 0.8, 1.2], // 暴击伤害加成系数
],
// 15. 狂暴斩 - 低防御有加成 (伤害 = 物攻 × 倍数 × (1 + (100-敌人防御百分比)×系数))
15 => [
'name' => '狂暴斩',
'type' => 'damage_single',
'calc_type' => 'low_def_bonus',
'cost' => 32,
'level_req' => 20,
'desc' => '攻击防御低的敌人伤害更高',
'damage_ratio' => [1.1, 1.5, 2.0, 2.7],
],
],
// AOE伤害法术
// ============ 群体伤害法术 (damage_aoe) ============
'damage_aoe' => [
10 => [
// 20. 冰雹术 - 魔攻型 (每敌伤害 = 魔攻 × 倍数)
20 => [
'name' => '冰雹术',
'type' => 'damage_aoe',
'quality' => 'common',
'calc_type' => 'matk',
'cost' => 35,
'damage' => 0.8, // 对每个敌人的伤害倍数较低,但打全体
'level_req' => 8,
'level_req' => 5,
'desc' => '召唤冰雹,攻击所有敌人',
'damage_ratio' => [0.7, 1.0, 1.3, 1.7],
],
11 => [
// 21. 炎爆术 - 魔攻型,随敌人数量加成
21 => [
'name' => '炎爆术',
'type' => 'damage_aoe',
'quality' => 'rare',
'cost' => 45,
'damage' => 0.95,
'level_req' => 15,
'desc' => '引发连锁爆炸,对所有敌人造成伤害',
'calc_type' => 'matk_scaled',
'cost' => 40,
'level_req' => 12,
'desc' => '引发连锁爆炸,敌人越多伤害加成越高',
'damage_ratio' => [0.8, 1.1, 1.4, 1.9],
'enemy_count_bonus' => [0.1, 0.15, 0.2, 0.3], // 每增加一个敌人增加的伤害百分比
],
12 => [
// 22. 流星雨 - 混合型 (每敌伤害 = (魔攻 + 物攻) × 倍数)
22 => [
'name' => '流星雨',
'type' => 'damage_aoe',
'quality' => 'epic',
'cost' => 60,
'damage' => 1.1,
'level_req' => 25,
'calc_type' => 'hybrid',
'cost' => 50,
'level_req' => 20,
'desc' => '召唤流星坠落,轰击全体敌人',
'damage_ratio' => [0.6, 0.85, 1.15, 1.55],
],
13 => [
// 23. 灭世风暴 - 基于暴击率 (每敌伤害 = 魔攻 × 倍数 × (1 + 暴击率×系数))
23 => [
'name' => '灭世风暴',
'type' => 'damage_aoe',
'quality' => 'legendary',
'cost' => 80,
'damage' => 1.3,
'level_req' => 40,
'desc' => '引发天地异变,对所有敌人造成毁灭性伤害',
],
],
// 辅助法术(恢复、增益)
'support' => [
20 => [
'name' => '治愈术',
'type' => 'support',
'subtype' => 'heal',
'quality' => 'common',
'cost' => 15,
'heal' => 0.5, // 恢复量倍数 = 魔攻 * heal + 基础值
'heal_base' => 20,
'level_req' => 3,
'desc' => '恢复自己或队友的生命值',
],
21 => [
'name' => '神圣庇护',
'type' => 'support',
'subtype' => 'defend',
'quality' => 'rare',
'cost' => 25,
'defense_boost' => 30, // 增加固定防御值
'duration' => 3, // 持续回合数(如果支持的话)
'level_req' => 12,
'desc' => '增加自己或队友的防御力',
],
22 => [
'name' => '恢复光环',
'type' => 'support',
'subtype' => 'heal_all',
'quality' => 'epic',
'cost' => 50,
'heal' => 0.6,
'heal_base' => 40,
'calc_type' => 'crit_aoe',
'cost' => 60,
'level_req' => 30,
'desc' => '为所有队员恢复生命值',
'desc' => '引发天地异变,暴击率影响范围伤害',
'damage_ratio' => [0.9, 1.2, 1.6, 2.2],
'crit_bonus' => [0.4, 0.6, 0.9, 1.3],
],
// 24. 末日火雨 - 敌人越多伤害越低,但每个敌人都会受伤
24 => [
'name' => '末日火雨',
'type' => 'damage_aoe',
'calc_type' => 'dispersed_damage',
'cost' => 55,
'level_req' => 25,
'desc' => '魔法能量分散到所有敌人,敌人越多分散越严重',
'damage_ratio' => [1.8, 2.5, 3.2, 4.0],
'dispersion' => [0.8, 0.75, 0.7, 0.65], // 随敌人数量衰减系数
],
// 25. 狂风斩 - 基于物攻 (每敌伤害 = 物攻 × 倍数)
25 => [
'name' => '狂风斩',
'type' => 'damage_aoe',
'calc_type' => 'patk',
'cost' => 45,
'level_req' => 16,
'desc' => '挥出狂暴的风刃,基于物攻伤害',
'damage_ratio' => [0.9, 1.2, 1.6, 2.1],
],
],
// 法术品质对应的学习资源书数量
// ============ 群体治疗法术 (heal_aoe) ============
'heal_aoe' => [
// 30. 神圣庇护 - 魔攻型 (每人恢复 = 魔攻 × 倍数 + 基础值)
30 => [
'name' => '神圣庇护',
'type' => 'heal_aoe',
'calc_type' => 'matk',
'cost' => 30,
'level_req' => 8,
'desc' => '为所有队员增加防护,恢复生命值',
'heal_ratio' => [0.3, 0.5, 0.75, 1.0],
'heal_base' => [15, 30, 50, 75],
],
// 31. 恢复光环 - 生命值百分比型 (每人恢复 = 自己最大生命值 × 百分比)
31 => [
'name' => '恢复光环',
'type' => 'heal_aoe',
'calc_type' => 'hp_percent',
'cost' => 35,
'level_req' => 14,
'desc' => '释放温暖的光芒,基于自己的最大生命值恢复队员',
'heal_ratio' => [0.2, 0.3, 0.4, 0.5],
],
// 32. 圣灵之力 - 混合型 (每人恢复 = (魔攻 + 物攻) × 倍数)
32 => [
'name' => '圣灵之力',
'type' => 'heal_aoe',
'calc_type' => 'hybrid',
'cost' => 45,
'level_req' => 22,
'desc' => '强大的群体治疗,恢复所有队员',
'heal_ratio' => [0.25, 0.4, 0.6, 0.85],
'heal_base' => [10, 20, 35, 55],
],
// 33. 仙界救赎 - 智能治疗(优先治疗血量少的队员)
33 => [
'name' => '仙界救赎',
'type' => 'heal_aoe',
'calc_type' => 'smart_heal',
'cost' => 55,
'level_req' => 32,
'desc' => '至高的救赎之力,优先治疗血量较低的队员',
'heal_ratio' => [0.4, 0.6, 0.9, 1.3],
'heal_base' => [25, 45, 70, 110],
'priority_bonus' => [0.2, 0.3, 0.4, 0.5], // 血量越少加成越多
],
// 34. 护盾术 - 基于防御属性 (每人恢复 = (物防+魔防) × 倍数)
34 => [
'name' => '护盾术',
'type' => 'heal_aoe',
'calc_type' => 'defense',
'cost' => 40,
'level_req' => 18,
'desc' => '根据防御力为队员恢复生命值',
'heal_ratio' => [0.5, 0.75, 1.1, 1.5],
'heal_base' => [8, 16, 28, 45],
],
// 35. 团队共鸣 - 基于队伍状态 (每人恢复 = 魔攻 × 倍数 × (队员数量系数))
35 => [
'name' => '团队共鸣',
'type' => 'heal_aoe',
'calc_type' => 'team_sync',
'cost' => 38,
'level_req' => 20,
'desc' => '队员越多,治疗效果越强',
'heal_ratio' => [0.35, 0.55, 0.8, 1.1],
'team_bonus' => [0.2, 0.3, 0.45, 0.6], // 每增加一个队员增加的治疗百分比
],
],
// ============ 品质掉落概率 ============
'quality_drop_rates' => [
'common' => 70, // 普通法术 70% 掉落概率
'rare' => 20, // 稀有法术 20% 掉落概率
'epic' => 8, // 史诗法术 8% 掉落概率
'legendary' => 2, // 传奇法术 2% 掉落概率
],
// ============ 法术品质对应的学习资源书数量 ============
'quality_levels' => [
'common' => 1, // 普通资源书可学习普通法术
'rare' => 2, // 稀有资源书可学习稀有法术
@ -140,32 +315,59 @@ return [
'legendary' => 4, // 传奇资源书可学习传奇法术
],
// 法术升级系统
// ============ 法术升级系统 ============
'upgrades' => [
// 每个等级需要的资源书数量和属性提升
// level => ['cost' => 资源书数量, 'damage_bonus' => 伤害加成%, 'cost_reduction' => 消耗减少]
1 => ['cost' => 0, 'damage_bonus' => 0, 'cost_reduction' => 0],
2 => ['cost' => 2, 'damage_bonus' => 10, 'cost_reduction' => 2],
3 => ['cost' => 3, 'damage_bonus' => 20, 'cost_reduction' => 4],
4 => ['cost' => 4, 'damage_bonus' => 30, 'cost_reduction' => 6],
5 => ['cost' => 5, 'damage_bonus' => 40, 'cost_reduction' => 8],
6 => ['cost' => 6, 'damage_bonus' => 50, 'cost_reduction' => 10],
7 => ['cost' => 8, 'damage_bonus' => 60, 'cost_reduction' => 12],
8 => ['cost' => 10, 'damage_bonus' => 70, 'cost_reduction' => 14],
9 => ['cost' => 12, 'damage_bonus' => 80, 'cost_reduction' => 16],
10 => ['cost' => 15, 'damage_bonus' => 100, 'cost_reduction' => 20],
1 => ['cost' => 0, 'bonus' => 0, 'cost_reduction' => 0],
2 => ['cost' => 2, 'bonus' => 10, 'cost_reduction' => 2],
3 => ['cost' => 3, 'bonus' => 20, 'cost_reduction' => 4],
4 => ['cost' => 4, 'bonus' => 30, 'cost_reduction' => 6],
5 => ['cost' => 5, 'bonus' => 40, 'cost_reduction' => 8],
6 => ['cost' => 6, 'bonus' => 50, 'cost_reduction' => 10],
7 => ['cost' => 8, 'bonus' => 60, 'cost_reduction' => 12],
8 => ['cost' => 10, 'bonus' => 70, 'cost_reduction' => 14],
9 => ['cost' => 12, 'bonus' => 80, 'cost_reduction' => 16],
10 => ['cost' => 15, 'bonus' => 100, 'cost_reduction' => 20],
],
// 地牢法术掉落映射 - 定义各地牢的法术资源书掉落池
// ============ 地牢法术掉落映射 ============
'dungeon_spell_drops' => [
1 => [1, 10], // 七玄门 (Lv.1-5): 火球术、冰雹术
2 => [2, 3, 11], // 太南谷 (Lv.5-10): 冰锥术、雷击术、炎爆术
3 => [20, 21], // 血色禁地 (Lv.10-15): 治愈术、神圣庇护
4 => [12], // 黄枫谷 (Lv.15-20): 流星雨
5 => [4], // 燕翎堡 (Lv.20-30): 烈焰焚天
6 => [5, 22], // 越京皇宫 (Lv.30-40): 诛仙剑气、恢复光环
7 => [13], // 乱星海-魁星岛 (Lv.40-50): 灭世风暴
8 => [13, 22], // 虚天殿 (Lv.50-60): 灭世风暴、恢复光环
9 => [5, 13], // 外星海 (Lv.60+): 诛仙剑气、灭世风暴
1 => ['heal_single', 'damage_single', 'damage_aoe'], // 七玄门 (Lv.1-5)
2 => ['damage_single', 'damage_aoe', 'heal_aoe'], // 太南谷 (Lv.5-10)
3 => ['heal_single', 'heal_aoe'], // 血色禁地 (Lv.10-15)
4 => ['damage_single', 'damage_aoe'], // 黄枫谷 (Lv.15-20)
5 => ['damage_single', 'heal_aoe'], // 燕翎堡 (Lv.20-30)
6 => ['damage_single', 'heal_aoe'], // 越京皇宫 (Lv.30-40)
7 => ['damage_aoe'], // 乱星海-魁星岛 (Lv.40-50)
8 => ['damage_aoe', 'heal_single', 'heal_aoe'], // 虚天殿 (Lv.50-60)
9 => ['damage_single', 'damage_aoe', 'heal_single'], // 外星海 (Lv.60+)
],
// ============ 按法术类型和品质分类 ============
'spells_by_quality' => [
'common' => [
'heal_single' => [1],
'damage_single' => [10],
'damage_aoe' => [20],
'heal_aoe' => [30],
],
'rare' => [
'heal_single' => [2, 3],
'damage_single' => [11, 12],
'damage_aoe' => [21, 22],
'heal_aoe' => [31, 32],
],
'epic' => [
'heal_single' => [4, 5],
'damage_single' => [13, 14],
'damage_aoe' => [23, 24],
'heal_aoe' => [33, 34],
],
'legendary' => [
'heal_single' => [6],
'damage_single' => [15],
'damage_aoe' => [25],
'heal_aoe' => [35],
],
],
];

View File

@ -9,17 +9,17 @@ class Actor
public int $exp = 0;
public int $maxExp = 100;
public int $hp = 0;
public int $maxHp = 0;
public int $patk = 0;
public int $matk = 0;
public int $pdef = 0;
public int $mdef = 0;
public int $hp = 100;
public int $maxHp = 100;
public int $patk = 10;
public int $matk = 10;
public int $pdef = 10;
public int $mdef = 10;
public int $crit = 0;
public float $critdmg = 110.0;
public int $mana = 0;
public int $maxMana = 0;
public int $mana = 100;
public int $maxMana = 100;
// 技能槽位系统 (新法术系统)
public array $skillSlots = [

View File

@ -87,9 +87,6 @@ class Item
$growth = $typeConfig['growth'] ?? 0;
$item->heal = $baseStats[$qualityIndex] + ($level * $growth) + rand(0, 10);
$item->desc = "Lv.{$level} {$quality}品质的药剂";
} elseif ($type === 'spell_tome') {
// 法术资源书特殊处理
$item->desc = "Lv.{$level} {$quality}品质的法术资源书";
} else {
// 检查是否有特定物品配置
$specificConfig = $typeConfig['specific_config'][$item->name] ?? [];
@ -237,12 +234,13 @@ class Item
}
/**
* 创建法术物品
* @param int $spellId 法术ID (来自 spells.php)
* 创建法术物品 - 支持新的丰富法术系统
* @param int $spellId 法术ID
* @param string $quality 品质 (common, rare, epic, legendary)
* @param int $level 物品等级
* @return array 法术物品数组
*/
public static function createSpell(int $spellId, int $level = 1): array
public static function createSpell(int $spellId, string $quality = 'common', int $level = 1): array
{
static $spellsData = null;
if ($spellsData === null) {
@ -252,7 +250,7 @@ class Item
// 查找法术信息
$spellInfo = null;
foreach ($spellsData as $category => $spells) {
if (is_array($spells) && $category !== 'quality_levels' && $category !== 'upgrades' && $category !== 'dungeon_spell_drops') {
if (is_array($spells) && !in_array($category, ['quality_levels', 'upgrades', 'dungeon_spell_drops', 'quality_drop_rates', 'spells_by_quality'])) {
if (isset($spells[$spellId])) {
$spellInfo = $spells[$spellId];
break;
@ -266,33 +264,60 @@ class Item
'id' => uniqid('spell_'),
'type' => 'spell',
'name' => '未知法术',
'quality' => 'common',
'quality' => $quality,
'level' => $level,
'spellId' => $spellId,
'enhanceLevel' => 0,
'damage' => 1.0,
'calc_type' => 'matk',
'cost' => 20,
'spellType' => 'damage_single',
'desc' => '未知的法术',
];
}
// 品质映射到数组索引 (common=0, rare=1, epic=2, legendary=3)
$qualityIndex = match($quality) {
'common' => 0,
'rare' => 1,
'epic' => 2,
'legendary' => 3,
default => 0,
};
// 提取品质相关的参数
$healRatio = $spellInfo['heal_ratio'][$qualityIndex] ?? ($spellInfo['heal_ratio'][0] ?? 0);
$damageRatio = $spellInfo['damage_ratio'][$qualityIndex] ?? ($spellInfo['damage_ratio'][0] ?? 1.0);
$healBase = $spellInfo['heal_base'][$qualityIndex] ?? ($spellInfo['heal_base'][0] ?? 0);
$critBonus = $spellInfo['crit_bonus'][$qualityIndex] ?? ($spellInfo['crit_bonus'][0] ?? 0);
$critDmgBonus = $spellInfo['crit_dmg_bonus'][$qualityIndex] ?? ($spellInfo['crit_dmg_bonus'][0] ?? 0);
$enemyCountBonus = $spellInfo['enemy_count_bonus'][$qualityIndex] ?? ($spellInfo['enemy_count_bonus'][0] ?? 0);
$dispersion = $spellInfo['dispersion'][$qualityIndex] ?? ($spellInfo['dispersion'][0] ?? 1.0);
$teamBonus = $spellInfo['team_bonus'][$qualityIndex] ?? ($spellInfo['team_bonus'][0] ?? 0);
$priorityBonus = $spellInfo['priority_bonus'][$qualityIndex] ?? ($spellInfo['priority_bonus'][0] ?? 0);
return [
'id' => uniqid('spell_'),
'type' => 'spell',
'name' => $spellInfo['name'],
'quality' => $spellInfo['quality'] ?? 'common',
'quality' => $quality,
'level' => $level,
'spellId' => $spellId,
'enhanceLevel' => 0,
'damage' => $spellInfo['damage'] ?? 1.0,
'calc_type' => $spellInfo['calc_type'] ?? 'matk',
'cost' => $spellInfo['cost'] ?? 20,
'spellType' => $spellInfo['type'] ?? 'damage_single',
'subtype' => $spellInfo['subtype'] ?? null,
'heal' => $spellInfo['heal'] ?? 0,
'heal_base' => $spellInfo['heal_base'] ?? 0,
'defense_boost' => $spellInfo['defense_boost'] ?? 0,
'desc' => $spellInfo['desc'] ?? '',
// 品质参数
'heal_ratio' => $healRatio,
'damage_ratio' => $damageRatio,
'heal_base' => $healBase,
'crit_bonus' => $critBonus,
'crit_dmg_bonus' => $critDmgBonus,
'enemy_count_bonus' => $enemyCountBonus,
'dispersion' => $dispersion,
'team_bonus' => $teamBonus,
'priority_bonus' => $priorityBonus,
];
}

View File

@ -204,33 +204,15 @@ class Monster extends Actor
// 处理两种配置格式
$selectedSpells = [];
if (is_numeric($spellConfigs[0] ?? null)) {
// 格式1: 简单数组 [1, 3, 10] - 随机选择
$spellCount = rand(1, min(3, count($spellConfigs)));
$selectedIds = array_rand($spellConfigs, $spellCount);
if (!is_array($selectedIds)) {
$selectedIds = [$selectedIds];
}
foreach ($selectedIds as $key) {
// 格式2: 配置数组 [['id' => 1, 'name' => '治愈术', 'rate' => 30]]
foreach ($spellConfigs as $spellConfig) {
if (is_array($spellConfig) && isset($spellConfig['id'])) {
$selectedSpells[] = [
'id' => $spellConfigs[$key],
'name' => null,
'rate' => 30, // 格式1不指定rate时默认30%
'id' => $spellConfig['id'],
'name' => $spellConfig['name'] ?? null,
'rate' => $spellConfig['rate'] ?? 30, // 默认30%掉落概率
];
}
} else {
// 格式2: 配置数组 [['id' => 1, 'name' => '治愈术', 'rate' => 30]]
foreach ($spellConfigs as $spellConfig) {
if (is_array($spellConfig) && isset($spellConfig['id'])) {
$selectedSpells[] = [
'id' => $spellConfig['id'],
'name' => $spellConfig['name'] ?? null,
'rate' => $spellConfig['rate'] ?? 30, // 默认30%掉落概率
];
}
}
}
foreach ($selectedSpells as $spellConfig) {
@ -261,45 +243,6 @@ class Monster extends Actor
}
}
/**
* 应用装备属性加成到怪物属性
*/
// Monster-specific application of equipment is handled by Actor::getStats; applyEquipmentStats remains for legacy callers
public function applyEquipmentStats(): void
{
$this->hp = $this->baseHp;
$this->patk = $this->basePatk;
$this->matk = $this->baseMatk;
$this->pdef = $this->basePdef;
$this->mdef = $this->baseMdef;
foreach ($this->equip as $item) {
if (empty($item)) continue;
$this->hp += $item['hp'] ?? 0;
$this->patk += $item['patk'] ?? $item['atk'] ?? 0;
$this->matk += $item['matk'] ?? 0;
$this->pdef += $item['pdef'] ?? $item['def'] ?? 0;
$this->mdef += $item['mdef'] ?? 0;
$this->crit += $item['crit'] ?? 0;
$this->critdmg += $item['critdmg'] ?? 0;
}
}
/**
* 获取怪物装备的物品列表(用于战斗胜利时掉落)
* @return array
*/
public function getEquippedItems(): array
{
$items = [];
foreach ($this->equip as $item) {
if (!empty($item)) {
$items[] = $item;
}
}
return $items;
}
/**
* 随机掉落装备物品(从穿着的装备随机掉落)
* @param int $dropRate 掉落概率0-100

View File

@ -56,8 +56,7 @@ class Player extends Actor
$this->exp -= $this->maxExp;
$this->maxExp = (int)($this->maxExp * 1.5);
// 升级获得天赋点每级3点并通过 autoAllocateTalents 自动分配
$this->autoAllocateTalents(3);
$this->talentPoints += 3;
// 升级时恢复全部生命值
$this->fullHeal();

View File

@ -594,7 +594,7 @@ class InventoryPanel
foreach ($player->inventory as $index => $item) {
$quality = $item['quality'] ?? $item['rarity'] ?? 'common';
$isEquipment = in_array($item['type'], ['weapon', 'armor', 'ring', 'necklace', 'boots']);
$isEquipment = in_array($item['type'], ['weapon', 'armor', 'ring', 'necklace', 'boots','spell']);
if ($isEquipment && in_array($quality, $qualitiesToSell)) {
$price = \Game\Entities\Item::calculateSellPrice($item);

View File

@ -212,18 +212,16 @@ class SpellPanel
$actualDamage = $damage * (1 + $damageBonus / 100);
$out->writeln("伤害倍数: {$this->yellow}" . number_format($damage, 2) . "{$this->reset}{$this->green}" . number_format($actualDamage, 2) . "x{$this->reset}");
$out->writeln("效果: {$this->magenta}对所有敌人造成魔法伤害{$this->reset}");
} elseif ($type === 'support') {
$subtype = $spellInfo['subtype'] ?? '';
if ($subtype === 'heal' || $subtype === 'heal_all') {
$heal = $spellInfo['heal'] ?? 0.5;
$healBase = $spellInfo['heal_base'] ?? 20;
$out->writeln("恢复效果: {$this->green}魔攻 x {$heal} + {$healBase}{$this->reset}");
$out->writeln("效果: {$this->magenta}恢复生命值{$this->reset}");
} elseif ($subtype === 'defend') {
$defenseBoos = $spellInfo['defense_boost'] ?? 0;
$out->writeln("防御增加: {$this->green}+{$defenseBoos}{$this->reset}");
$out->writeln("效果: {$this->magenta}增加防御力{$this->reset}");
}
} elseif ($type === 'heal_single') {
$heal = $spellInfo['heal'] ?? 0.5;
$healBase = $spellInfo['heal_base'] ?? 20;
$out->writeln("恢复效果: {$this->green}魔攻 x {$heal} + {$healBase}{$this->reset}");
$out->writeln("效果: {$this->magenta}恢复单个目标的生命值{$this->reset}");
} elseif ($type === 'heal_aoe') {
$heal = $spellInfo['heal'] ?? 0.5;
$healBase = $spellInfo['heal_base'] ?? 20;
$out->writeln("恢复效果: {$this->green}魔攻 x {$heal} + {$healBase}{$this->reset}");
$out->writeln("效果: {$this->magenta}恢复所有队员的生命值{$this->reset}");
}
$out->writeln("");
@ -245,7 +243,7 @@ class SpellPanel
// 获取所有可学习的法术(按品质分类)
$allSpells = [];
foreach ($spellsData as $category => $spells) {
if (is_array($spells) && $category !== 'quality_levels' && $category !== 'upgrades') {
if (is_array($spells) && !in_array($category, ['quality_levels', 'upgrades', 'dungeon_spell_drops', 'quality_drop_rates', 'spells_by_quality'])) {
foreach ($spells as $spellId => $spellInfo) {
if (is_numeric($spellId)) {
$allSpells[$spellId] = $spellInfo;
@ -459,7 +457,7 @@ class SpellPanel
private function getSpellInfo(int $spellId, array $spellsData): ?array
{
foreach ($spellsData as $category => $spells) {
if (is_array($spells) && $category !== 'quality_levels' && $category !== 'upgrades') {
if (is_array($spells) && !in_array($category, ['quality_levels', 'upgrades', 'dungeon_spell_drops', 'quality_drop_rates', 'spells_by_quality'])) {
if (isset($spells[$spellId])) {
return $spells[$spellId];
}

View File

@ -1,6 +1,6 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
$monster = \Game\Entities\Monster::createGroup(2);
$monster = \Game\Entities\Monster::create(1);
dd(is_numeric('0'));
dd($monster->getRandomSpellDrops());