refactor(fight): 重构战斗系统

- 移除 NodeManager 相关代码,改为使用 input 包中的 Effect
- 重构 FightC 结构,添加 GetRand 方法
- 新增 BaseAction 结构和 NewBaseAction 函数
- 更新 effect 包中的 Effect 结构和相关方法
- 调整 BattleSkillEntity 中的 AttackTime 方法,增加 Hit 字段
- 更新 AttackValue 结构,保留原有的 AttackTime 字段
- 重构战斗逻辑,包括回合开始前的处理、技能使用、伤害计算等
This commit is contained in:
2025-09-14 03:36:26 +08:00
parent 06e8ae3d9c
commit 9d87ce9e46
19 changed files with 858 additions and 246 deletions

View File

@@ -1,6 +1,23 @@
package node
func (this *EffectNode) UseSkill() bool {
import (
"blazing/common/utils"
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
)
// 技能命中计算
func (this *EffectNode) IsHit(attacker, defender *input.Input, skill *info.BattleSkillEntity) uint32 {
return skill.AttackTime() //计算命中
}
// 被命中计算,默认直接返回,重写这个来实现闪避率
func (this *EffectNode) TakeHit(attacker, defender *input.Input, skill *info.BattleSkillEntity) uint32 {
return skill.Hit
}
func (this *EffectNode) UseSkill(attacker, defender *input.Input) bool {
panic("not implemented") // TODO: Implement
}
func (this *EffectNode) OnSkillPP() bool {
@@ -26,7 +43,7 @@ func (this *EffectNode) PreDamage() bool {
panic("not implemented") // TODO: Implement
}
func (this *EffectNode) OnBeforeCalculateDamage() bool {
func (this *EffectNode) CalculateDamage(attacker, defender *input.Input, skill *info.BattleSkillEntity) {
panic("not implemented") // TODO: Implement
}
@@ -42,8 +59,32 @@ func (this *EffectNode) PostDamage() bool {
panic("not implemented") // TODO: Implement
}
func (this *EffectNode) OnCritPostDamage() bool {
panic("not implemented") // TODO: Implement
func (this *EffectNode) IsCrit(attacker, defender *input.Input, skill *info.BattleSkillEntity) uint32 {
CritRate := utils.Max(skill.CritRate, 1)
CritRateR := attacker.FightC.GetRand().Int31n(16)
//CritAtkFirst: 先出手时必定致命一击; 默认: 0
if skill.CritAtkFirst != 0 && skill.First {
CritRate = 16
}
//CritAtkSecond: 后出手时必定致命一击; 默认: 0
if skill.CritAtkSecond != 0 && !skill.First {
CritRate = 16
}
// CritSelfHalfHp: 自身体力低于一半时必定致命一击; 默认: 0
if skill.CritSelfHalfHp != 0 && (attacker.CurrentPet.HP < int(attacker.CurrentPet.Info.MaxHp)/2) {
CritRate = 16
}
// CritFoeHalfHp: 对方体力低于一半时必定致命一击; 默认: 0
if skill.CritSelfHalfHp != 0 && (defender.CurrentPet.HP < int(defender.CurrentPet.Info.MaxHp)/2) {
CritRate = 16
}
//todo 暴击伤害
if CritRateR <= int32(CritRate) {
return 1
}
return 0
}
func (this *EffectNode) OnHit() bool {