diff --git a/logic/service/fight/action.go b/logic/service/fight/action.go index 079d0848..56ae2975 100644 --- a/logic/service/fight/action.go +++ b/logic/service/fight/action.go @@ -60,8 +60,9 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) { cool.Loger.Debug(context.Background(), " 战斗chan已关闭") return } - selfinput := f.GetInputByPlayer(c, false) + selfinput := f.GetInputByPlayer(c, false) + InitAttackValue := *selfinput.AttackValue oldpet := selfinput.CurrentPet ret := &action.ActiveSwitchAction{ BaseAction: action.NewBaseAction(c.GetInfo().UserID), @@ -69,14 +70,14 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) { selfinput.CurrentPet, ret.Reason = selfinput.GetPet(id) f.Switch = append(f.Switch, ret) - f.GetInputByPlayer(c, false).InitAttackValue() //切换精灵消除能力提升 + selfinput.InitAttackValue() //切换精灵消除能力提升 //这时候精灵已经切换过了,可以直接给新精灵加效果 f.Broadcast(func(ff *input.Input) { ff.Exec(func(t input.Effect) bool { - t.Switch(selfinput, oldpet, selfinput.CurrentPet) + t.Switch(selfinput, InitAttackValue, oldpet) return true }) diff --git a/logic/service/fight/effect/effect_34.go b/logic/service/fight/effect/effect_34.go new file mode 100644 index 00000000..3b21c337 --- /dev/null +++ b/logic/service/fight/effect/effect_34.go @@ -0,0 +1,56 @@ +package effect + +import ( + "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" + + "github.com/shopspring/decimal" +) + +/** + * 将所受的伤害n倍反馈给对手 + */ + +func init() { + input.InitEffect(input.EffectType.Skill, 34, &Effect34{}) + +} + +type Effect34 struct { + node.EffectNode + can bool +} + +// 使用技能时,不可被继承,继承Miss和Hit就行 +func (e *Effect34) OnSkill() bool { + if !e.Hit() { + return true + } + e.can = true + return true +} + +// 被攻击时候反弹 +func (e *Effect34) Skill_Use_ex() bool { + + if !e.can { + return true + } + //不是技能 + if e.Ctx().SkillEntity == nil { + return true + } + + // //0血不触发 + // if e.Input.CurrentPet.Info.Hp <= 0 { + // return true + // } + + e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{ + + Type: info.DamageType.Fixed, + Damage: decimal.NewFromInt(int64(e.Ctx().Opp.DamageZone.Damage.IntPart())).Sub(decimal.NewFromInt(int64(e.SideEffectArgs[0]))), + }) + return true +} diff --git a/logic/service/fight/effect/effect_35.go b/logic/service/fight/effect/effect_35.go new file mode 100644 index 00000000..984f4d70 --- /dev/null +++ b/logic/service/fight/effect/effect_35.go @@ -0,0 +1,45 @@ +package effect + +import ( + "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" +) + +// 惩罚,对方能力等级越高,此技能威力越大 +type Effect35 struct { + node.EffectNode + can bool +} + +func (e *Effect35) Skill_Hit() bool { + if !e.Hit() { + return true + } + + if e.Ctx().SkillEntity == nil { + return true + } + + if e.Ctx().SkillEntity.Category() == info.Category.STATUS { + return true + } + + if e.Ctx().SkillEntity.Category() == info.Category.PHYSICAL { + return true + } + + switch e.Ctx().SkillEntity.Category() { + case info.Category.PHYSICAL: + e.Ctx().SkillEntity.Power += e.Ctx().Opp.GetProp(0, true) + e.Ctx().Opp.GetProp(1, true) + case info.Category.SPECIAL: + e.Ctx().SkillEntity.Power += e.Ctx().Opp.GetProp(2, true) + e.Ctx().Opp.GetProp(3, true) + } + + return true +} + +// ---- 注册所有效果 ---- +func init() { + input.InitEffect(input.EffectType.Skill, 35, &Effect35{}) +} diff --git a/logic/service/fight/effect/effect_36.go b/logic/service/fight/effect/effect_36.go new file mode 100644 index 00000000..a866d12a --- /dev/null +++ b/logic/service/fight/effect/effect_36.go @@ -0,0 +1,47 @@ +package effect + +import ( + "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" + + "github.com/shopspring/decimal" +) + +/** + * 命中时x%的概率秒杀对方 + */ + +func init() { + input.InitEffect(input.EffectType.Skill, 36, &Effect36{}) + +} + +type Effect36 struct { + node.EffectNode + can bool +} + +func (e *Effect36) OnSkill() bool { + if !e.Hit() { + return true + } + e.can = true + return true +} +func (e *Effect36) Damage_Floor(b *info.DamageZone) bool { + if !e.can { + return true + } + // 概率判定 + ok, _, _ := e.Input.Player.Roll(e.SideEffectArgs[0], 100) + if !ok { + return true + } + + if b.Type == info.DamageType.Red { + b.Damage = decimal.NewFromInt(int64(e.Ctx().Opp.CurrentPet.Info.MaxHp)) + + } + return true +} diff --git a/logic/service/fight/effect/effect_37.go b/logic/service/fight/effect/effect_37.go new file mode 100644 index 00000000..2cdc46db --- /dev/null +++ b/logic/service/fight/effect/effect_37.go @@ -0,0 +1,30 @@ +package effect + +import ( + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" + + "github.com/shopspring/decimal" +) + +// 自身体力小于1/n时威力为m倍 +type Effect37 struct { + node.EffectNode + can bool +} + +func (e *Effect37) Skill_Hit() bool { + if !e.Hit() { + return true + } + cmphp := e.GetInput().CurrentPet.GetMaxHP().Div(decimal.NewFromInt(int64(e.Args()[0]))) + if e.GetInput().CurrentPet.GetHP().Cmp(cmphp) == -1 { + e.Ctx().SkillEntity.Power *= e.Args()[0] + } + return true +} + +// ---- 注册所有效果 ---- +func init() { + input.InitEffect(input.EffectType.Skill, 37, &Effect37{}) +} diff --git a/logic/service/fight/effect/effect_43.go b/logic/service/fight/effect/effect_43.go index 743c8a94..80629e45 100644 --- a/logic/service/fight/effect/effect_43.go +++ b/logic/service/fight/effect/effect_43.go @@ -13,9 +13,7 @@ import ( */ func init() { - input.InitEffect(input.EffectType.Skill, 43, &Effect43{ - EffectNode: node.EffectNode{}, - }) + input.InitEffect(input.EffectType.Skill, 43, &Effect43{}) } diff --git a/logic/service/fight/effect/effect_58.go b/logic/service/fight/effect/effect_58.go index 67bf208c..a72825c0 100644 --- a/logic/service/fight/effect/effect_58.go +++ b/logic/service/fight/effect/effect_58.go @@ -2,6 +2,7 @@ package effect import ( "blazing/logic/service/fight/action" + "blazing/logic/service/fight/info" "blazing/logic/service/fight/input" "blazing/logic/service/fight/node" ) @@ -11,9 +12,7 @@ import ( */ func init() { - input.InitEffect(input.EffectType.Skill, 58, &Effect58{ - EffectNode: node.EffectNode{}, - }) + input.InitEffect(input.EffectType.Skill, 58, &Effect58{}) } @@ -38,7 +37,20 @@ func (e *Effect58) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool { if !e.can { return true } - e.Ctx().SkillEntity.Crit = 16 + //fmt.Println(e.Ctx().SkillEntity) + if e.Ctx().SkillEntity == nil { + return true + } + if e.Ctx().SkillEntity.Category() == info.Category.STATUS { + return true + } + e.Ctx().SkillEntity.CritRate = 16 return true } +func (e *Effect58) SetArgs(t *input.Input, a ...int) { + + e.EffectNode.SetArgs(t, a...) + e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0]) + +} diff --git a/logic/service/fight/effect/effect_67.go b/logic/service/fight/effect/effect_67.go index 30205347..62c76519 100644 --- a/logic/service/fight/effect/effect_67.go +++ b/logic/service/fight/effect/effect_67.go @@ -4,6 +4,8 @@ import ( "blazing/logic/service/fight/info" "blazing/logic/service/fight/input" "blazing/logic/service/fight/node" + + "github.com/shopspring/decimal" ) /** @@ -11,31 +13,47 @@ import ( */ type Effect67 struct { node.EffectNode + can bool } func init() { - t := &Effect67{ - EffectNode: node.EffectNode{}, - } + t := &Effect67{} input.InitEffect(input.EffectType.Skill, 67, t) } +func (e *Effect67) OnSkill() bool { + if !e.Hit() { + return true + } + e.can = true + return true +} // 重写死亡,如果击败,就出触发死亡事件,判断是目标精灵 -func (this *Effect67) OnDefeat(*input.Input, *info.SkillEntity) bool { +func (e *Effect67) Switch(in *input.Input, at info.AttackValue, outpet *info.BattlePetEntity) bool { + //技能效果还没生效 + if !e.can { + return true + } + //如果是我方切精灵 + if in == e.Ctx().Our { + return true + } + + if outpet.NotAlive { //如果上一只已经死亡后切换的,对对手直接施加扣血 + e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{ + Type: info.DamageType.Fixed, + Damage: decimal.NewFromInt(int64(e.Ctx().Opp.CurrentPet.Info.MaxHp)).Div(decimal.NewFromInt(int64(e.SideEffectArgs[0]))), + }) + + } return true } +func (e *Effect67) SetArgs(t *input.Input, a ...int) { -// 登场是下一只 减少对方下次出战精灵的最大体力1/n -func (this *Effect67) OnSwitchIn() bool { + e.EffectNode.SetArgs(t, a...) + e.EffectNode.Duration(1) - return true -} - -// 下场不消除buff -func (this *Effect67) OnSwitchOut() bool { - //下场默认清除effect - panic("not implemented") // TODO: Implement } diff --git a/logic/service/fight/effect/effect_9.go b/logic/service/fight/effect/effect_9.go index 2a510ecf..db1b1265 100644 --- a/logic/service/fight/effect/effect_9.go +++ b/logic/service/fight/effect/effect_9.go @@ -11,9 +11,7 @@ import ( */ func init() { - t := &Effect9{ - EffectNode: node.EffectNode{}, - } + t := &Effect9{} t.Duration(-1) t.MaxStack(-1) input.InitEffect(input.EffectType.Skill, 9, t) diff --git a/logic/service/fight/effect/effect_status.go b/logic/service/fight/effect/effect_status.go index 0a1a5ee2..2c15cd7d 100644 --- a/logic/service/fight/effect/effect_status.go +++ b/logic/service/fight/effect/effect_status.go @@ -16,7 +16,7 @@ type BaseSataus struct { } // /重写切换事件 -func (e *BaseSataus) Switch(in *input.Input, outpet, inpet *info.BattlePetEntity) bool { +func (e *BaseSataus) Switch(*input.Input, info.AttackValue, *info.BattlePetEntity) bool { //状态如果是我方切换,那么就消除掉状态效果 if e.Input == e.Ctx().Our { diff --git a/logic/service/fight/info/BattlePetEntity.go b/logic/service/fight/info/BattlePetEntity.go index 790c5c67..d3701c75 100644 --- a/logic/service/fight/info/BattlePetEntity.go +++ b/logic/service/fight/info/BattlePetEntity.go @@ -7,6 +7,8 @@ import ( "blazing/modules/blazing/model" "math/rand" "sync" + + "github.com/shopspring/decimal" ) // 战斗属性类型 @@ -75,7 +77,16 @@ func CalculateRealValue(value int, stat int) int { return r } } +func (u *BattlePetEntity) GetHP() decimal.Decimal { + return decimal.NewFromInt(int64(u.Info.Hp)) + +} +func (u *BattlePetEntity) GetMaxHP() decimal.Decimal { + + return decimal.NewFromInt(int64(u.Info.MaxHp)) + +} func (u *BattlePetEntity) Type() *element.ElementCombination { // 1. 遍历宠物配置,查找对应元素类型ID var typeID int diff --git a/logic/service/fight/input/effect.go b/logic/service/fight/input/effect.go index b332c150..876ef373 100644 --- a/logic/service/fight/input/effect.go +++ b/logic/service/fight/input/effect.go @@ -141,7 +141,7 @@ func (our *Input) AddEffect(e Effect) Effect { if v.ID() == e.ID() && //找到相同的效果id v.Alive() && //如果之前的效果还存活 - equalInts(v.GetArgs(), e.GetArgs()) { //如果层数可以叠加或者是无限层数 + equalInts(v.Args(), e.Args()) { //如果层数可以叠加或者是无限层数 if v.MaxStack() == 0 { //说明进行了替换 v.Alive(false) //不允许叠层,取消效果 diff --git a/logic/service/fight/input/interface.go b/logic/service/fight/input/interface.go index 276edff1..9349e7ed 100644 --- a/logic/service/fight/input/interface.go +++ b/logic/service/fight/input/interface.go @@ -6,7 +6,7 @@ import ( ) type Effect interface { - Fight_Start() bool //战斗开始 + Fight_Start() bool //战斗开始 首发也写这里吧,别)单独写了 Turn_Start(fattack, sattack *action.SelectSkillAction) //回合开始,注入特性 Compare_Pre(fattack, sattack *action.SelectSkillAction) bool //比较前对优先级的修改 //技能命中前的返回值代表是否可以出手 ,对命中本身的修改应该是对上下文本身的修改 @@ -36,7 +36,7 @@ type Effect interface { // 首发其实就是切换的精灵为nil - Switch(in *Input, outpet, inpet *info.BattlePetEntity) bool // 精灵出战 / 上场时触发 + Switch(in *Input, at info.AttackValue, outpet *info.BattlePetEntity) bool // 精灵出战 / 上场时触发 //OnSwitchOut() bool // 精灵下场时触发 // OnOwnerSwitchIn() bool // 所属玩家精灵出战时触发 // OnOwnerSwitchOut() bool // 所属玩家精灵下场时触发 @@ -49,7 +49,7 @@ type Effect interface { //boss是进入防守方才被添加抵御异常状态效果的,boss免疫的实质是给挑战者挂载一个阻止添加给对手的debuff EFFect_Befer() SetArgs(input *Input, param ...int) - GetArgs() []int + Args() []int // 治疗相关触发 Heal_Pre(action.BattleActionI, *int) bool // 治疗前触发 回复翻倍效果 //Heal(action.BattleActionI) bool // 治疗生效时触发 药剂反噬 diff --git a/logic/service/fight/node/PetSwitch.go b/logic/service/fight/node/PetSwitch.go index 59c5636f..bbc81885 100644 --- a/logic/service/fight/node/PetSwitch.go +++ b/logic/service/fight/node/PetSwitch.go @@ -8,7 +8,7 @@ import ( // 切精灵返回false,重写change方法来实现切换效果 // 精灵切换相关触发 -func (e *EffectNode) Switch(in *input.Input, outpet, inpet *info.BattlePetEntity) bool { +func (e *EffectNode) Switch(in *input.Input, at info.AttackValue, outpet *info.BattlePetEntity) bool { //说明是我放切精灵 if e.Input == in { diff --git a/logic/service/fight/node/Turn.go b/logic/service/fight/node/Turn.go index 0ca41874..c086cd91 100644 --- a/logic/service/fight/node/Turn.go +++ b/logic/service/fight/node/Turn.go @@ -24,14 +24,14 @@ func (e *EffectNode) Turn_End() { e.Alive(false) } else { - e.trunl.Do(func() { + // e.trunl.Do(func() { - if !e.Ctx().Our.FightC.IsFirst(e.Ctx().Our.Player) { //如果我方后手,那就给回合+1 - e.duration++ - // e.Alive(true) - } + // if !e.Ctx().Our.FightC.IsFirst(e.Ctx().Our.Player) { //如果我方后手,那就给回合+1 + // e.duration++ + // // e.Alive(true) + // } - }) + // }) e.duration-- } diff --git a/logic/service/fight/node/node.go b/logic/service/fight/node/node.go index 3aaff534..0e78faee 100644 --- a/logic/service/fight/node/node.go +++ b/logic/service/fight/node/node.go @@ -91,7 +91,7 @@ func (e *EffectNode) SetArgs(t *input.Input, a ...int) { e.SideEffectArgs = a } -func (e *EffectNode) GetArgs() []int { +func (e *EffectNode) Args() []int { return e.SideEffectArgs