fix(fight): 修复技能效果添加逻辑并优化效果管理
- 修改 `AddEffect` 方法,使用 `EffectID` 包装技能效果,并避免重复添加 - 将 `Effects` 类型从 `[]Effect` 改为 `*utils.OrderedMap[int, Effect]` 以提升查找和管理效率 - 移除 `Effect` 接口中的 `ID()` 方法,改由 `EffectID` 结构体维护 - 增加 `GetSkillEffect` 和 `GetDamageEffect` 方法返回带 ID 的效果结构 - 更新 `CancelTurn` 和 `Exec` 方法以适配新的数据结构 - 初始化 `Effects` 为 `OrderedMap` 实例,确保容器正确创建
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package input
|
||||
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/fight/info"
|
||||
"fmt"
|
||||
@@ -19,7 +20,7 @@ type Input struct {
|
||||
*info.AttackValue
|
||||
FightC common.FightI
|
||||
// info.BattleActionI
|
||||
Effects []Effect //effects 实际上全局就是effect无限回合 //effects容器 技能的
|
||||
Effects *utils.OrderedMap[int, Effect] //effects 实际上全局就是effect无限回合 //effects容器 技能的
|
||||
//Damage decimal.Decimal //造成伤害
|
||||
First bool //是否先手
|
||||
}
|
||||
@@ -29,6 +30,7 @@ func NewInput(c common.FightI, p common.PlayerI) *Input {
|
||||
t := ret.GetDamageEffect(0)
|
||||
ret.AddEffect(t) //添加默认基类,实现继承
|
||||
p.SetFightC(c) //给玩家设置战斗容器
|
||||
ret.Effects = utils.NewOrderedMap[int, Effect]()
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user