refactor(fight/effect): 重构效果失效逻辑,统一使用NotALive方法并优化效果叠加处理
This commit is contained in:
@@ -39,10 +39,7 @@ type EffectStat struct {
|
||||
// *(*uint32)(addrA) = 100
|
||||
// }
|
||||
func (e *EffectStat) SkillUseEnd(opp *input.Input) {
|
||||
// for i := 0; i < 6; i++ { //堆叠属性提升
|
||||
// ret.FAttack.Prop[i] = int8(attacker.GetProp(i, true))
|
||||
// ret.FAttack.Prop[i] = int8(defender.GetProp(i, true))
|
||||
// }
|
||||
|
||||
t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[1], 100)
|
||||
if t {
|
||||
if !e.etype { //自身
|
||||
|
||||
@@ -43,8 +43,8 @@ func (this *Effect62) TurnEnd(e *input.Input) {
|
||||
|
||||
func (e *Effect62) SkillUseEnd(opp *input.Input) {
|
||||
if !e.Hide { //如果还在隐藏,就直接返回
|
||||
defer e.NotALive() //失效
|
||||
e.Input.Death() //本只死亡
|
||||
defer e.EffectNode.NotALive() //失效
|
||||
e.Input.Death() //本只死亡
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ func (e *Effect0) TurnEnd(opp *input.Input) {
|
||||
e.Input.AttackValue.RemainHp = int32(e.Input.CurrentPet.Info.Hp)
|
||||
|
||||
// ret.FAttack.LostHp = uint32(f.First.GetDamageEffect(0).Stack()) //先手方造成血量
|
||||
opp.AttackValue.RemainHp = int32(opp.CurrentPet.Info.Hp)
|
||||
//opp.AttackValue.RemainHp = int32(opp.CurrentPet.Info.Hp)
|
||||
//ret.SAttack.LostHp = uint32(f.Second.GetDamageEffect(0).Stack()) //后手方造成血量
|
||||
|
||||
}
|
||||
|
||||
@@ -532,6 +532,11 @@ func (f *FightC) enterturn(fattack, sattack BattleActionI) {
|
||||
return true
|
||||
})
|
||||
|
||||
defender.Exec(func(t input.Effect) bool { //这个是能否使用技能
|
||||
//结算状态
|
||||
t.TurnEnd(defender) //返回本身结算,如果false,说明不能使用技能了
|
||||
return true
|
||||
})
|
||||
ret := info.AttackValueS{
|
||||
FAttack: *f.First.AttackValue,
|
||||
SAttack: *f.Second.AttackValue,
|
||||
|
||||
@@ -44,8 +44,6 @@ type Effect interface {
|
||||
// SetOwner(bool)
|
||||
// OnDefeat() bool // 精灵被击败时触发
|
||||
|
||||
// TurnEnd() bool // 回合结束
|
||||
|
||||
TurnEnd(opp *Input) //闪避率计算,,实际上是修改命中的判断
|
||||
// // 堆叠(Stack)相关触发
|
||||
// OnStackBefore() bool // 堆叠效果前触发
|
||||
@@ -57,12 +55,6 @@ type Effect interface {
|
||||
// OnBeforeHeal() bool // 治疗前触发
|
||||
// OnHeal() bool // 治疗生效时触发
|
||||
|
||||
// // // 怒气(Rage)相关触发
|
||||
// // BeforeRageGain EnumEffectTrigger enum:"37" // 增怒前触发
|
||||
// // OnRageGain EnumEffectTrigger enum:"38" // 增怒时触发
|
||||
// // BeforeRageLoss EnumEffectTrigger enum:"39" // 减怒前触发
|
||||
// // OnRageLoss EnumEffectTrigger enum:"40" // 减怒时触发
|
||||
|
||||
// // 精灵切换相关触发
|
||||
// OnSwitchIn() bool // 精灵出战 / 上场时触发
|
||||
// OnSwitchOut() bool // 精灵下场时触发
|
||||
@@ -200,18 +192,19 @@ func getTypeName(v interface{}) string {
|
||||
}
|
||||
|
||||
func (c *Input) AddEffect(e Effect) {
|
||||
//todo 免疫
|
||||
e.SetInput(c)
|
||||
// 如果已有同 ID 的效果,尝试叠加
|
||||
for _, eff := range c.Effects {
|
||||
if eff.ID() == e.ID() {
|
||||
//设置输入源
|
||||
if eff.Stack() < eff.GetMaxStack() { //如果小于最大叠层
|
||||
eff.Stack(eff.Stack()) //获取到当前叠层数然后叠加
|
||||
eff.Stack(e.Stack()) //获取到当前叠层数然后叠加
|
||||
} else {
|
||||
|
||||
//这里,说明是延续回合效果
|
||||
|
||||
eff.Duration(eff.Duration())
|
||||
eff.Duration(e.Duration())
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -22,7 +22,7 @@ func (e *EffectNode) OnTurnStart(opp *input.Input) {
|
||||
func (e *EffectNode) TurnEnd(opp *input.Input) {
|
||||
|
||||
if e.duration == 0 { // 保留 (负数表示永久)
|
||||
e.NotAlive = true
|
||||
e.NotALive()
|
||||
}
|
||||
e.duration--
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@ type EffectNode struct {
|
||||
Success bool // 是否执行成功 成功XXX,失败XXX
|
||||
arget bool // 传出作用对象,默认0是自身,1是作用于对面
|
||||
Flag int //过滤掉的战斗类型 pvp pve boss战斗,野怪全部生效
|
||||
NotAlive bool // 是否失效 effect返回值是否被取消,是否被删除
|
||||
notAlive bool // 是否失效 effect返回值是否被取消,是否被删除
|
||||
//增加owner target,如果owner target都为自身,就回合效果结束后再使用回合效果
|
||||
}
|
||||
|
||||
func (this *EffectNode) Alive() bool {
|
||||
|
||||
return !this.NotAlive
|
||||
return !this.notAlive
|
||||
|
||||
}
|
||||
func (this *EffectNode) ID() int {
|
||||
@@ -38,7 +38,7 @@ func (this *EffectNode) ID() int {
|
||||
}
|
||||
func (this *EffectNode) NotALive() {
|
||||
|
||||
this.NotAlive = true
|
||||
this.notAlive = true
|
||||
|
||||
}
|
||||
func (this *EffectNode) GetOwner() bool {
|
||||
|
||||
Reference in New Issue
Block a user