diff --git a/logic/service/fight/effect/effect_1.go b/logic/service/fight/effect/effect_1.go index 8da369be2..c446f8116 100644 --- a/logic/service/fight/effect/effect_1.go +++ b/logic/service/fight/effect/effect_1.go @@ -14,11 +14,15 @@ type Effect1 struct { } func init() { - input.InitEffect(input.EffectType.Skill, 1, &Effect1{}) + ret := &Effect1{} + ret.Effect = ret + input.InitEffect(input.EffectType.Skill, 1, ret) } -func (e *Effect1) AfterSkill(opp *input.Input, skill *info.SkillEntity) { - e.Input.CurrentPet.Info.Hp += uint32(e.Input.GetDamage(0) / 2) +// 命中之后 +func (e *Effect1) OnHit(opp *input.Input, skill *info.SkillEntity) { + + e.Input.CurrentPet.Info.Hp += uint32(e.Input.DamageZone.Attack / 2) } diff --git a/logic/service/fight/effect/effect_20.go b/logic/service/fight/effect/effect_20.go new file mode 100644 index 000000000..ff73825be --- /dev/null +++ b/logic/service/fight/effect/effect_20.go @@ -0,0 +1,26 @@ +package effect + +import ( + "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" +) + +/** + * m%令本方疲惫,n回合无法攻击 + */ + +func init() { + input.InitEffect(input.EffectType.Skill, 20, &Effect20{}) + +} + +type Effect20 struct { + node.EffectNode +} + +// 使用技能时,不可被继承,继承Miss和Hit就行 +func (e *Effect20) OnSkill(opp *input.Input, skill *info.SkillEntity) { + e.Input.AddEffect(input.Geteffect(input.EffectType.Status, int(info.PetStatus.Tired))) + +} diff --git a/logic/service/fight/effect/effect_3_33_63__85_145.go b/logic/service/fight/effect/effect_3_33_63__85_145.go index 80d92ab58..a9cc10470 100644 --- a/logic/service/fight/effect/effect_3_33_63__85_145.go +++ b/logic/service/fight/effect/effect_3_33_63__85_145.go @@ -24,37 +24,30 @@ func (e *Effect3) OnHit(opp *input.Input, skill *info.SkillEntity) { } } + +func neweffect3(rev bool, level int8, etype info.EnumAbilityOpType) *Effect3 { + ret := &Effect3{ + Rev: rev, + Level: level, + Etype: etype, + } + ret.Effect = ret + return ret +} func init() { //解除能力下降状态 - input.InitEffect(input.EffectType.Skill, 3, &Effect3{ - EffectNode: node.EffectNode{}, - Level: -1, - Etype: info.AbilityOpType.RESET, - }) + + input.InitEffect(input.EffectType.Skill, 3, neweffect3(false, -1, info.AbilityOpType.RESET)) // 消除对手能力提升状态 - input.InitEffect(input.EffectType.Skill, 33, &Effect3{ - EffectNode: node.EffectNode{}, - Rev: true, - Level: 1, - Etype: info.AbilityOpType.RESET, - }) + + input.InitEffect(input.EffectType.Skill, 33, neweffect3(true, 1, info.AbilityOpType.RESET)) // 将能力下降状态反馈给对手 - input.InitEffect(input.EffectType.Skill, 63, &Effect3{ - EffectNode: node.EffectNode{}, - Etype: info.AbilityOpType.AbilityOpBounceWeaken, - }) + input.InitEffect(input.EffectType.Skill, 63, neweffect3(false, 0, info.AbilityOpType.AbilityOpBounceWeaken)) //使对手的能力提升效果转化到自己身上 - input.InitEffect(input.EffectType.Skill, 85, &Effect3{ - EffectNode: node.EffectNode{}, - Etype: info.AbilityOpType.AbilityOpStealStrengthen, - }) + input.InitEffect(input.EffectType.Skill, 85, neweffect3(false, -1, info.AbilityOpType.AbilityOpStealStrengthen)) // 使对手的能力提升效果反转成能力下降效果 - input.InitEffect(input.EffectType.Skill, 145, &Effect3{ - EffectNode: node.EffectNode{}, - Rev: true, - Level: 1, - Etype: info.AbilityOpType.AbilityOpReverse, - }) + + input.InitEffect(input.EffectType.Skill, 145, neweffect3(true, 1, info.AbilityOpType.AbilityOpReverse)) } diff --git a/logic/service/fight/effect/effect_power_doblue.go b/logic/service/fight/effect/effect_power_doblue.go index 1372fb930..bf1320198 100644 --- a/logic/service/fight/effect/effect_power_doblue.go +++ b/logic/service/fight/effect/effect_power_doblue.go @@ -23,7 +23,22 @@ func init() { return ret }, }) + //后出手的话威力为2倍 + input.InitEffect(input.EffectType.Skill, 30, &Effect96{ + EffectNode: node.EffectNode{}, + Status: func(i, o *input.Input) bool { + return !i.First + }, + }) + //先出手的话威力为2倍 + input.InitEffect(input.EffectType.Skill, 40, &Effect96{ + EffectNode: node.EffectNode{}, + Status: func(i, o *input.Input) bool { + + return i.First + }, + }) //对手处于烧伤状态时,威力翻倍 input.InitEffect(input.EffectType.Skill, 96, &Effect96{ diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index 3c992c1f2..a592d4fee 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -11,6 +11,7 @@ import ( "sort" "time" + "github.com/barkimedes/go-deepcopy" "github.com/jinzhu/copier" "github.com/shopspring/decimal" ) @@ -435,27 +436,27 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *SelectSk return true }) - attacker.BeforeSkill(defender, a.Skill) + attacker.UseSkill(defender, a.Skill) //攻击方计算技能使用 + attacker.AttackValue.AttackTime = a.Skill.AttackTime + f.parseskill(attacker, defender, a) //是否miss都应该施加解析effect if attacker.AttackValue.AttackTime > 0 { //如果命中 - attacker.DamageZone[0] = int(attacker.CalculatePower(defender, a.Skill).IntPart()) + attacker.DamageZone.Attack = int(attacker.CalculatePower(defender, a.Skill).IntPart()) attacker.AttackValue.IsCritical = a.Skill.Crit if attacker.AttackValue.IsCritical == 1 { - attacker.DamageZone[0] *= 2 + attacker.DamageZone.Attack *= 2 } attacker.Exec(func(t input.Effect) bool { t.Hit(true) //我方效果命中 - t.OnSkill(defender, a.Skill) //调用伤害计算 - return true }) defender.Exec(func(t input.Effect) bool { @@ -469,9 +470,15 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *SelectSk } + attacker.Exec(func(t input.Effect) bool { + + t.OnSkill(defender, a.Skill) //调用伤害计算 + + return true + }) defender.Damage(attacker, info.DamageZone{ Type: info.DamageType.Red, - Damage: decimal.NewFromInt(int64(attacker.DamageZone[0])), + Damage: decimal.NewFromInt(int64(attacker.DamageZone.Attack)), }) } @@ -521,13 +528,14 @@ func (f *FightC) enterturn(fattack, sattack BattleActionI) { } if canuseskill { //可以使用技能 - + oldskill, _ := deepcopy.Anything(skill.Skill) //备份技能 f.processSkillAttack(attacker, defender, skill) + skill.Skill = oldskill.(*info.SkillEntity) //还原技能效果 skill.Skill.Info.PP-- //减少PP } fmt.Println(i, - "玩家技能伤害:", attacker.GetDamage(info.DamageType.Red), + "玩家技能伤害:", attacker.DamageZone.Attack, "自身剩余血量:", attacker.CurrentPet.Info.Hp, "对手剩余血量:", defender.CurrentPet.Info.Hp, ) diff --git a/logic/service/fight/input/effecti.go b/logic/service/fight/input/effecti.go index a46fff586..7649a79f8 100644 --- a/logic/service/fight/input/effecti.go +++ b/logic/service/fight/input/effecti.go @@ -10,18 +10,20 @@ type Effect interface { PreActionStart() bool //行动开始前,注入视为等参数在这里实现 CanSkill(opp *Input) bool //使用技能 可以取消用技能节点 PreSkill(opp *Input, skill *info.SkillEntity) //对技能修改,比如变威力 - BeforeSkill(opp *Input, skill *info.SkillEntity) // 技能命中前触发 - OnSkill(opp *Input, skill *info.SkillEntity) //闪避率计算,,实际上是修改命中的判断 + BeforeSkill(opp *Input, skill *info.SkillEntity) // 技能命中前触发//预处理受击技能 被攻击方效果 + OnSkill(opp *Input, skill *info.SkillEntity) // 触发on miss onhit BeferProp(in *Input, prop, level int8, ptype info.EnumAbilityOpType) bool //锁定属性 SetArgs(input *Input, param ...int) - BeforeAttack(opp *Input, id *info.DamageZone) // 攻击前触发 ,这时候就是+区间 - Attack(opp *Input, id *info.DamageZone) // 攻击触发 - PreAttacked(opp *Input, skill *info.SkillEntity) //预处理受击技能 - BeforeAttacked(opp *Input, id *info.DamageZone) //受击前触发 这时候就是百分比减伤区间 - Attacked(opp *Input, id *info.DamageZone) // 受击触发 这时候就是点数减伤 + BeforeAttack(opp *Input, id *info.DamageZone) // 攻击前触发 ,这时候就是+区间 + Attack(opp *Input, id *info.DamageZone) // 攻击触发 + + FloorDamage(opp *Input, id *info.DamageZone) // 保底伤害 + BeforeAttacked(opp *Input, id *info.DamageZone) //受击前触发 这时候就是百分比减伤区间 + Attacked(opp *Input, id *info.DamageZone) // 受击触发 这时候就是点数减伤 + LockDamage(opp *Input, id *info.DamageZone) //锁定伤害 PostDamage() bool // 伤害结算后触发(血量扣除后),比如触发回神,反弹也在这里实现 Shield() bool // 护盾值变化时触发 diff --git a/logic/service/fight/input/fight.go b/logic/service/fight/input/fight.go index 644396fa1..5b8d56960 100644 --- a/logic/service/fight/input/fight.go +++ b/logic/service/fight/input/fight.go @@ -9,7 +9,7 @@ import ( "github.com/shopspring/decimal" ) -func (u *Input) BeforeSkill(opp *Input, skill *info.SkillEntity) { +func (u *Input) UseSkill(opp *Input, skill *info.SkillEntity) { skill.AttackTimeC(int(u.GetProp(5, true))) //计算命中 skill.Crit = 0 if skill.Category() == info.Category.STATUS { //属性技能不用算暴击 @@ -55,6 +55,7 @@ func (u *Input) Damage(attacker *Input, id info.DamageZone) { return true }) + attacker.DamageZone.OldAttack = attacker.DamageZone.Attack //反弹伤害记录 u.Exec(func(t Effect) bool { diff --git a/logic/service/fight/input/input.go b/logic/service/fight/input/input.go index be8d0c201..c529775cb 100644 --- a/logic/service/fight/input/input.go +++ b/logic/service/fight/input/input.go @@ -18,14 +18,17 @@ type Input struct { FightC common.FightI // info.BattleActionI Effects *utils.OrderedMap[int, Effect] //effects 实际上全局就是effect无限回合 //effects容器 技能的 - DamageZone map[info.EnumDamageType]int //伤害容器 - First bool //是否先手 + DamageZone struct { + Attack int //攻击伤害 + OldAttack int //攻击伤害被挡前伤害记录 + } //伤害容器 + First bool //是否先手 } func NewInput(c common.FightI, p common.PlayerI) *Input { ret := &Input{FightC: c, Player: p} ret.Effects = utils.NewOrderedMap[int, Effect]() - ret.DamageZone = make(map[info.EnumDamageType]int) + // t := Geteffect(EffectType.Damage, 0) // t.Effect.SetArgs(ret) // ret.AddEffect(t) //添加默认基类,实现继承 diff --git a/logic/service/fight/input/node.go b/logic/service/fight/input/node.go index 48dac8885..14ad32647 100644 --- a/logic/service/fight/input/node.go +++ b/logic/service/fight/input/node.go @@ -66,16 +66,7 @@ func (c *Input) GetProp(id int, istue bool) int { return realValue } -func (c *Input) GetDamage(etype info.EnumDamageType) int { - rer, ok := c.DamageZone[etype] - if ok { - - return rer - //todo 获取后GetEffect - } - return 0 -} func (c *Input) GetEffect(etype EnumEffectType, id int) *EffectID { rer, ok := c.Effects.Load(id + int(etype)) diff --git a/logic/service/fight/node/skill.go b/logic/service/fight/node/dagame.go similarity index 100% rename from logic/service/fight/node/skill.go rename to logic/service/fight/node/dagame.go diff --git a/logic/service/fight/node/hit.go b/logic/service/fight/node/hit.go index a93e469ef..e24e05034 100644 --- a/logic/service/fight/node/hit.go +++ b/logic/service/fight/node/hit.go @@ -20,3 +20,11 @@ func (this *EffectNode) Attacked(*input.Input, *info.DamageZone) { // 受击触发 func (this *EffectNode) BeforeAttacked(*input.Input, *info.DamageZone) { } + +// 受击触发 +func (this *EffectNode) FloorDamage(*input.Input, *info.DamageZone) { +} + +// 受击触发 +func (this *EffectNode) LockDamage(*input.Input, *info.DamageZone) { +}