refactor(logic): 重构战斗逻辑代码
- 移除了未使用的变量和注释 - 添加了战斗回合循环的框架 - 删除了重复的代码片段 - 优化了代码结构,提高了可读性和可维护性
This commit is contained in:
@@ -81,64 +81,8 @@ func (f *FightC) NewFight(i *info.NoteReadyToFightInfo, plays PlayerI) {
|
||||
|
||||
}
|
||||
|
||||
//调用技能产生effect参数后,创建effect实例,而非技能创建
|
||||
c := info.NewBattleContainer1v1(*i) //创建战斗容器
|
||||
t := info.BattleSkillEntity{} //
|
||||
t.SideEffectArgs = []int{1, 2, 3}
|
||||
//先提交effecet后然后计算伤害
|
||||
for { //战斗回合循环
|
||||
|
||||
//物理和特殊,百分比和固定伤害也算,真实伤害不分类别,故直接扣血就行,不需要计算
|
||||
if t.Category() == info.Category.PHYSICAL || t.Category() == info.Category.SPECIAL {
|
||||
|
||||
c.Effects.Exec(func(e info.Effect) bool {
|
||||
|
||||
if e.Type() == 0 { //判断是自己的效果
|
||||
return e.PreDamage() //执行预处理效果
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
// Apply pre-damage effects for pet sources
|
||||
// battle.applyEffects(context, EffectTrigger.PreDamage)
|
||||
// if (context.crit) {
|
||||
// battle.applyEffects(context, EffectTrigger.OnCritPreDamage) // Trigger crit pre-damage effects
|
||||
// }
|
||||
//假如说这里需要能力提升
|
||||
// c.Exec(func(e Effect) func() {
|
||||
// return e.OnBeforeAddMark()
|
||||
// })
|
||||
//添加印记前的效果如果有任何一个false,说明组织了添加效果
|
||||
//这里能力提升
|
||||
// c.Exec(func(e Effect) bool {
|
||||
// return e.OnAnyMarkAdded()
|
||||
// })
|
||||
|
||||
// var candidates []*Effect
|
||||
// for _, eff := range c.Effects {
|
||||
// if eff.Trigger == trigger {
|
||||
// candidates = append(candidates, eff)
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 按优先级排序
|
||||
// sort.SliceStable(candidates, func(i, j int) bool {
|
||||
// return candidates[i].Priority > candidates[j].Priority
|
||||
// })
|
||||
|
||||
// // 执行
|
||||
// for _, eff := range candidates {
|
||||
// ctx.Effect = eff
|
||||
// keep := eff.Apply(ctx)
|
||||
|
||||
// if !keep {
|
||||
// // 持续回合结束 / 返回 false 的 effect 删除
|
||||
// c.removeEffect(eff)
|
||||
// }
|
||||
|
||||
// if ctx.Done {
|
||||
// break // 被拦截
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user