refactor(fight/effect): 重构伤害处理逻辑,统一使用DamageZone管理伤害值并优化Effect接口,移除过时方法
This commit is contained in:
@@ -18,7 +18,7 @@ func init() {
|
||||
|
||||
}
|
||||
func (e *Effect1) AfterSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
t := e.Input.GetEffect(input.EffectType.Damage, 0).Stack()
|
||||
e.Input.CurrentPet.Info.Hp += uint32(t / 2)
|
||||
|
||||
e.Input.CurrentPet.Info.Hp += uint32(e.Input.GetDamage(0) / 2)
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package effect
|
||||
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
@@ -23,7 +22,7 @@ type Effect8 struct {
|
||||
}
|
||||
|
||||
// 伤害落实前触发,限制最大伤害
|
||||
func (e *Effect8) BeforeAttacked(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (e *Effect8) Attack(opp *input.Input, eff *input.EffectID) {
|
||||
|
||||
// //在这里修改伤害
|
||||
// if opp.GetEffect(input.EffectType.Damage, 0).MaxStack() != 0 { //限制最大伤害
|
||||
@@ -31,8 +30,8 @@ func (e *Effect8) BeforeAttacked(opp *input.Input, skill *info.SkillEntity) {
|
||||
// }
|
||||
|
||||
opp.Pet(e.Input, func() { //我方取敌方属性
|
||||
dg := utils.Min(e.Input.GetEffect(input.EffectType.Damage, 0).Stack(), int(opp.CurrentPet.Info.Hp)-1)
|
||||
e.Input.GetEffect(input.EffectType.Damage, 0).Stack(dg)
|
||||
|
||||
e.Input.DamageZone[0] = utils.Min(e.Input.GetDamage(0), int(opp.CurrentPet.Info.Hp)-1)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
// 施加一个基类effect
|
||||
type Effect0 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect0) OnSwitchOut() bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect0) OnOwnerSwitchIn() bool {
|
||||
|
||||
return true
|
||||
}
|
||||
func (e *Effect0) TurnEnd(opp *input.Input) {
|
||||
e.Input.AttackValue.RemainHp = int32(e.Input.CurrentPet.Info.Hp)
|
||||
|
||||
}
|
||||
|
||||
// 使用技能时
|
||||
func (e *Effect0) OnSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
e.Input.Skill(skill, func() { //变威力作用
|
||||
|
||||
e.Stack(int(e.Input.CalculatePower(opp, skill).IntPart()))
|
||||
})
|
||||
|
||||
e.Input.Exec(func(t input.Effect) bool { //计算暴击率加成
|
||||
|
||||
e.Input.AttackValue.IsCritical = skill.Crit
|
||||
return e.Input.AttackValue.IsCritical == 0
|
||||
})
|
||||
e.Input.Exec(func(t input.Effect) bool { //加伤
|
||||
|
||||
t.AddZone(e.Input, &input.EffectID{
|
||||
ID: 1,
|
||||
Effect: e,
|
||||
})
|
||||
return true
|
||||
})
|
||||
e.Input.Exec(func(t input.Effect) bool { //乘伤
|
||||
|
||||
t.MulZone(e.Input, &input.EffectID{
|
||||
ID: 1,
|
||||
Effect: e,
|
||||
})
|
||||
return true
|
||||
})
|
||||
if e.Input.AttackValue.IsCritical == 1 {
|
||||
|
||||
e.Stack(e.Stack() * 2)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
func (e *Effect0) BeforeSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
skill.AttackTimeC(int(opp.GetProp(5, true))) //计算命中
|
||||
skill.Crit = 0
|
||||
if skill.Category() == info.Category.STATUS { //属性技能不用算暴击
|
||||
return
|
||||
}
|
||||
CritRate := utils.Max(skill.CritRate, 1)
|
||||
|
||||
//CritAtkFirst: 先出手时必定致命一击; 默认: 0
|
||||
if skill.CritAtkFirst != 0 && e.Input.First {
|
||||
CritRate = 16
|
||||
}
|
||||
//CritAtkSecond: 后出手时必定致命一击; 默认: 0
|
||||
if skill.CritAtkSecond != 0 && !e.Input.First {
|
||||
CritRate = 16
|
||||
}
|
||||
// CritSelfHalfHp: 自身体力低于一半时必定致命一击; 默认: 0
|
||||
if skill.CritSelfHalfHp != 0 && (e.Input.CurrentPet.HP < int(e.Input.CurrentPet.Info.MaxHp)/2) {
|
||||
CritRate = 16
|
||||
}
|
||||
// CritFoeHalfHp: 对方体力低于一半时必定致命一击; 默认: 0
|
||||
if skill.CritSelfHalfHp != 0 && (opp.CurrentPet.HP < int(opp.CurrentPet.Info.MaxHp)/2) {
|
||||
CritRate = 16
|
||||
}
|
||||
|
||||
//todo 暴击伤害
|
||||
if t, _, _ := e.Input.Player.Roll(625*CritRate, 10000); t {
|
||||
skill.Crit = 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 受击触发
|
||||
func (e *Effect0) Attacked(opp *input.Input, skill *info.SkillEntity) {
|
||||
|
||||
e.Input.Exec(func(t input.Effect) bool { //加伤
|
||||
|
||||
t.AddZone(opp, &input.EffectID{
|
||||
ID: 1,
|
||||
Effect: e,
|
||||
})
|
||||
return true
|
||||
})
|
||||
e.Input.Exec(func(t input.Effect) bool { //乘伤
|
||||
|
||||
t.MulZone(opp, &input.EffectID{
|
||||
ID: 1,
|
||||
Effect: e,
|
||||
})
|
||||
return true
|
||||
})
|
||||
|
||||
|
||||
opp.AttackValue.LostHp = uint32(opp.GetEffect(input.EffectType.Damage, 0).Stack())
|
||||
if uint32(opp.AttackValue.LostHp) > e.Input.CurrentPet.Info.Hp {
|
||||
//这里其实是受到致死伤害
|
||||
//然后先触发死亡效果,消除所有buff
|
||||
//然后触发回神效果
|
||||
e.Input.CurrentPet.Info.Hp = 0
|
||||
} else {
|
||||
e.Input.CurrentPet.Info.Hp = e.Input.CurrentPet.Info.Hp - opp.AttackValue.LostHp
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Damage, 0, &Effect0{})
|
||||
|
||||
}
|
||||
@@ -12,25 +12,52 @@ type EffectStatus struct {
|
||||
Status info.EnumBattleStatus
|
||||
}
|
||||
|
||||
type EffectStatusNotSkill struct {
|
||||
type StatusNotSkill struct {
|
||||
EffectStatus
|
||||
}
|
||||
|
||||
func (e *EffectStatusNotSkill) CanSkill(opp *input.Input) bool {
|
||||
func (e *StatusNotSkill) CanSkill(opp *input.Input) bool {
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
// 扣血类
|
||||
type DrainHP struct {
|
||||
EffectStatus
|
||||
}
|
||||
|
||||
func (e *DrainHP) OnTurnStart(opp *input.Input) {
|
||||
e.Input.Pet(e.Input, func() { //我方取我方
|
||||
e.Input.CurrentPet.Info.Hp = -e.Input.CurrentPet.Info.MaxHp / 8
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// 被寄生种子 扣血类
|
||||
type StatusDrainedHP struct {
|
||||
DrainHP
|
||||
}
|
||||
|
||||
func (e *StatusDrainedHP) OnTurnStart(opp *input.Input) {
|
||||
e.DrainHP.OnTurnStart(opp)
|
||||
opp.Pet(e.Input, func() { //我方取我方
|
||||
opp.CurrentPet.Info.Hp = -e.Input.CurrentPet.Info.MaxHp / 8
|
||||
})
|
||||
|
||||
}
|
||||
func init() {
|
||||
//麻痹,疲惫,害怕,石化,都是无法行动
|
||||
|
||||
tt := func(t info.EnumBattleStatus, f *EffectStatusNotSkill) {
|
||||
tt := func(t info.EnumBattleStatus, f *StatusNotSkill) {
|
||||
|
||||
f.Status = t
|
||||
input.InitEffect(input.EffectType.Status, int(t), f)
|
||||
}
|
||||
tt(info.PetStatus.Paralysis, &EffectStatusNotSkill{})
|
||||
tt(info.PetStatus.Tired, &EffectStatusNotSkill{})
|
||||
tt(info.PetStatus.Sleep, &EffectStatusNotSkill{})
|
||||
tt(info.PetStatus.Petrified, &EffectStatusNotSkill{})
|
||||
input.InitEffect(input.EffectType.Status, int(info.PetStatus.DrainHP), &EffectStatus{}) //寄生种子
|
||||
|
||||
tt(info.PetStatus.Paralysis, &StatusNotSkill{})
|
||||
tt(info.PetStatus.Tired, &StatusNotSkill{})
|
||||
tt(info.PetStatus.Sleep, &StatusNotSkill{})
|
||||
tt(info.PetStatus.Petrified, &StatusNotSkill{})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user