refactor(fight/effect): 重构效果命中处理逻辑,统一Hit接口并优化效果触发时机
This commit is contained in:
@@ -44,7 +44,13 @@ func init() {
|
||||
func (e *Effect10) OnHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[0], 100)
|
||||
if t {
|
||||
e.Input.AddEffect(input.Geteffect(input.EffectType.Status, int(e.Status)))
|
||||
|
||||
t1 := e.Input.FightC.GetRand().Int31n(3)
|
||||
|
||||
eff := input.Geteffect(input.EffectType.Status, int(e.Status))
|
||||
eff.Effect.Duration(int(t1 + 1))
|
||||
e.Input.AddEffect(eff)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
@@ -12,7 +11,7 @@ import (
|
||||
type Effect62 struct {
|
||||
node.EffectNode
|
||||
Hide bool // 是否隐藏 正常是命中就可用,镇魂歌是回合数到才可用
|
||||
Hit bool
|
||||
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -24,24 +23,14 @@ func init() {
|
||||
|
||||
}
|
||||
|
||||
// 这个只会在我方命中时触发
|
||||
func (e *Effect62) OnHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
if opp.UserID != e.Input.UserID { //说明是自身回合
|
||||
e.Hit = true
|
||||
}
|
||||
|
||||
}
|
||||
func (e *Effect62) TurnEnd(opp *input.Input) {
|
||||
e.EffectNode.TurnEnd(opp) //先调用回合
|
||||
if e.Duration() != 1 { //说明还没到生效节点
|
||||
e.Hide = true //隐藏效果
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (e *Effect62) SkillUseEnd(opp *input.Input) {
|
||||
if e.Duration() != 1 { //说明还没到生效节点
|
||||
e.Hide = true //隐藏效果
|
||||
} else {
|
||||
e.Hide = false
|
||||
}
|
||||
|
||||
if opp.UserID == e.Input.UserID && !e.Hide && e.Hit { //说明是自身回合//如果还在隐藏,就直接返回
|
||||
if !e.Hide && e.Hit() { //说明是自身回合//如果还在隐藏,就直接返回
|
||||
|
||||
//defer e.EffectNode.NotALive() //失效
|
||||
//应该是对方固定伤害等于自身血量
|
||||
|
||||
@@ -75,6 +75,7 @@ func (this *Effect0) IsCrit(opp *input.Input, skill *info.SkillEntity) {
|
||||
|
||||
// 受击触发
|
||||
func (e *Effect0) AfterAttacked(opp *input.Input, skill *info.SkillEntity) {
|
||||
//在这里修改伤害
|
||||
|
||||
if uint32(opp.AttackValue.LostHp) > e.Input.CurrentPet.Info.Hp {
|
||||
//这里其实是受到致死伤害
|
||||
|
||||
@@ -425,12 +425,13 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *SelectSk
|
||||
|
||||
return true
|
||||
})
|
||||
//这里施加miss
|
||||
attacker.AttackValue.AttackTime = a.Skill.AttackTime
|
||||
f.parseskill(attacker, defender, a) //是否miss都应该施加解析effect
|
||||
if attacker.AttackValue.AttackTime > 0 { //如果命中
|
||||
|
||||
attacker.AttackValue.AttackTime = a.Skill.AttackTime
|
||||
f.parseskill(attacker, defender, a) //是否miss都应该施加解析effect
|
||||
|
||||
if attacker.AttackValue.AttackTime > 0 { //如果命中
|
||||
attacker.Exec(func(t input.Effect) bool {
|
||||
t.Hit(true) //我方效果命中
|
||||
|
||||
t.OnSkill(defender, a.Skill) //调用伤害计算
|
||||
|
||||
@@ -438,26 +439,27 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *SelectSk
|
||||
})
|
||||
defender.Exec(func(t input.Effect) bool {
|
||||
|
||||
t.AfterAttacked(attacker, a.Skill) //红伤落实
|
||||
|
||||
if t.GetOwner() { //如果取反,说明是给对方添加的回合效果
|
||||
t.Hit(true)
|
||||
}
|
||||
return true
|
||||
})
|
||||
attacker.Exec(func(t input.Effect) bool {
|
||||
|
||||
t.OnHit(defender, a.Skill) //命中后结算
|
||||
|
||||
return true
|
||||
})
|
||||
attacker.Exec(func(t input.Effect) bool {
|
||||
|
||||
t.SkillUseEnd(defender) //技能使用完毕后结算
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
// 扣减防御方血量
|
||||
} //todo 处理未命中效果
|
||||
|
||||
} //todo 处理未命中效果
|
||||
defender.Exec(func(t input.Effect) bool {
|
||||
|
||||
t.AfterAttacked(attacker, a.Skill) //红伤落实
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
attacker.Exec(func(t input.Effect) bool {
|
||||
|
||||
t.SkillUseEnd(defender) //技能使用完毕后结算
|
||||
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
//回合有先手方和后手方,同时有攻击方和被攻击方
|
||||
|
||||
@@ -29,9 +29,9 @@ type Effect interface {
|
||||
|
||||
OnSkill(opp *Input, skill *info.SkillEntity) //闪避率计算,,实际上是修改命中的判断
|
||||
|
||||
OnMiss(opp *Input, skill *info.SkillEntity) // 技能未命中时触发
|
||||
|
||||
BeforHit(opp *Input, skill *info.SkillEntity) // 技能命中前触发
|
||||
OnHit(opp *Input, skill *info.SkillEntity) // 技能命中时触发
|
||||
|
||||
|
||||
AfterHit(opp *Input, skill *info.SkillEntity) // 技能命中后触发
|
||||
|
||||
@@ -66,7 +66,7 @@ type Effect interface {
|
||||
|
||||
//回合数,然后次数另外维护
|
||||
Duration(...int) int
|
||||
|
||||
Hit(...bool) bool
|
||||
Alive() bool
|
||||
Stack(...int) int
|
||||
GetMaxStack() int
|
||||
|
||||
@@ -23,6 +23,7 @@ type EffectNode struct {
|
||||
arget bool // 传出作用对象,默认0是自身,1是作用于对面
|
||||
Flag int //过滤掉的战斗类型 pvp pve boss战斗,野怪全部生效
|
||||
notAlive bool // 是否失效 effect返回值是否被取消,是否被删除
|
||||
hit bool
|
||||
//增加owner target,如果owner target都为自身,就回合效果结束后再使用回合效果
|
||||
}
|
||||
|
||||
@@ -54,6 +55,14 @@ func (this *EffectNode) Stack(t ...int) int {
|
||||
|
||||
return this.stacks
|
||||
|
||||
}
|
||||
func (this *EffectNode) Hit(t ...bool) bool {
|
||||
if len(t) > 0 {
|
||||
this.hit = t[0]
|
||||
}
|
||||
|
||||
return this.hit
|
||||
|
||||
}
|
||||
func (this *EffectNode) GetMaxStack() int {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user