refactor(fight/effect): 重构效果触发时机处理,统一命中前/后接口并移除冗余方法
This commit is contained in:
@@ -42,15 +42,17 @@ func init() {
|
||||
|
||||
}
|
||||
func (e *Effect10) OnHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[0], 100)
|
||||
if t {
|
||||
if e.Hit() {
|
||||
t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[0], 100)
|
||||
if t {
|
||||
|
||||
t1 := e.Input.FightC.GetRand().Int31n(3)
|
||||
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)
|
||||
eff := input.Geteffect(input.EffectType.Status, int(e.Status))
|
||||
eff.Effect.Duration(int(t1 + 1))
|
||||
e.Input.AddEffect(eff)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
@@ -23,7 +24,7 @@ func init() {
|
||||
|
||||
}
|
||||
|
||||
func (e *Effect62) SkillUseEnd(opp *input.Input) {
|
||||
func (e *Effect62) AfterHit(*input.Input, *info.SkillEntity) {
|
||||
if e.Duration() != 1 { //说明还没到生效节点
|
||||
e.Hide = true //隐藏效果
|
||||
} else {
|
||||
|
||||
@@ -12,16 +12,6 @@ type Effect0 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
// 技能命中计算
|
||||
func (this *Effect0) IsHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
skill.AttackTimeC(int(opp.GetProp(5, true))) //计算命中
|
||||
}
|
||||
|
||||
// 比如xx技能无效
|
||||
func (this *Effect0) UseSkill(opp *input.Input) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect0) TurnEnd(opp *input.Input) {
|
||||
e.Input.AttackValue.RemainHp = int32(e.Input.CurrentPet.Info.Hp)
|
||||
|
||||
@@ -35,7 +25,6 @@ func (e *Effect0) OnSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
|
||||
e.Input.Exec(func(t input.Effect) bool { //计算暴击率加成
|
||||
|
||||
t.IsCrit(opp, skill)
|
||||
e.Input.AttackValue.IsCritical = skill.Crit
|
||||
return e.Input.AttackValue.IsCritical == 0
|
||||
})
|
||||
@@ -45,7 +34,8 @@ func (e *Effect0) OnSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
}
|
||||
|
||||
}
|
||||
func (this *Effect0) IsCrit(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (this *Effect0) BeforHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
skill.AttackTimeC(int(opp.GetProp(5, true))) //计算命中
|
||||
skill.Crit = 0
|
||||
CritRate := utils.Max(skill.CritRate, 1)
|
||||
CritRateR := this.Input.FightC.GetRand().Int31n(16)
|
||||
|
||||
@@ -456,7 +456,7 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *SelectSk
|
||||
|
||||
attacker.Exec(func(t input.Effect) bool {
|
||||
|
||||
t.SkillUseEnd(defender) //技能使用完毕后结算
|
||||
t.AfterHit(defender, a.Skill) //技能使用完毕后结算
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
@@ -10,10 +10,9 @@ type Effect interface {
|
||||
OnTurnStart(opp *Input) //回合开始
|
||||
|
||||
UseSkill(opp *Input) bool //使用技能 可以取消用技能节点
|
||||
SkillUseEnd(opp *Input)
|
||||
|
||||
// OnSkillPP() bool //技能PP减少节点
|
||||
// BeforeMultiHit() bool //多段攻击前
|
||||
// BeforeHit() bool //命中前
|
||||
|
||||
// OnCritPreDamage() bool //暴击判定成功且伤害计算前触发
|
||||
// PreDamage() bool // 技能伤害计算前触发(增伤 / 减伤等)
|
||||
// OnBeforeCalculateDamage() bool // 最终伤害计算前触发
|
||||
@@ -23,15 +22,13 @@ type Effect interface {
|
||||
AfterAttr(t *info.BattlePetEntity) //在获取属性前,比如重写对方属性AfterAttr
|
||||
BeferAttr(t *info.BattlePetEntity) //在获取属性后,比如视为对方属性
|
||||
SetArgs(input *Input, param ...int)
|
||||
IsCrit(opp *Input, skill *info.SkillEntity) //是否暴击
|
||||
CalculateDamage(opp *Input, skill *info.SkillEntity) //击判定成功且伤害计算前触发
|
||||
OnBeforeCalculateDamage(opp *Input, skill *info.SkillEntity) // 最终伤害计算前触发
|
||||
|
||||
CalculateDamage(opp *Input, skill *info.SkillEntity) //击判定成功且伤害计算前触发
|
||||
BeforeCalculateDamage(opp *Input, skill *info.SkillEntity) // 最终伤害计算前触发
|
||||
|
||||
OnSkill(opp *Input, skill *info.SkillEntity) //闪避率计算,,实际上是修改命中的判断
|
||||
|
||||
|
||||
BeforHit(opp *Input, skill *info.SkillEntity) // 技能命中前触发
|
||||
|
||||
|
||||
AfterHit(opp *Input, skill *info.SkillEntity) // 技能命中后触发
|
||||
|
||||
@@ -41,15 +38,10 @@ type Effect interface {
|
||||
// PostDamage() bool // 伤害结算后触发(血量扣除后)
|
||||
// AfterAttacked() bool // 被攻击后触发(受击判定)
|
||||
|
||||
// SetOwner(bool)
|
||||
// OnDefeat() bool // 精灵被击败时触发
|
||||
|
||||
TurnEnd(opp *Input) //闪避率计算,,实际上是修改命中的判断
|
||||
// // 堆叠(Stack)相关触发
|
||||
// OnStackBefore() bool // 堆叠效果前触发
|
||||
// OnStack() bool // 堆叠效果触发
|
||||
// OnBeforeConsumeStack() bool // 消耗堆叠前触发
|
||||
// OnConsumeStack() bool // 消耗堆叠时触发
|
||||
|
||||
|
||||
// // 治疗相关触发
|
||||
// OnBeforeHeal() bool // 治疗前触发
|
||||
|
||||
@@ -22,7 +22,7 @@ func (this *EffectNode) BeforeMultiHit() bool {
|
||||
}
|
||||
|
||||
// 回合结束前
|
||||
func (this *EffectNode) OnBeforeCalculateDamage(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (this *EffectNode) BeforeCalculateDamage(opp *input.Input, skill *info.SkillEntity) {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
@@ -46,10 +46,7 @@ func (this *EffectNode) PostDamage() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
// 正常来说,什么都不做
|
||||
func (this *EffectNode) IsCrit(opp *input.Input, skill *info.SkillEntity) {
|
||||
//return skill.Crit
|
||||
}
|
||||
|
||||
|
||||
func (this *EffectNode) OnDefeat() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
|
||||
@@ -18,6 +18,4 @@ func (e *EffectNode) OnSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (e *EffectNode) OnSkillPP() bool {
|
||||
return true
|
||||
}
|
||||
func (e *EffectNode) SkillUseEnd(*input.Input) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user