fix(fight): 修复空变更提交问题

This commit is contained in:
1
2025-11-12 13:44:21 +00:00
parent 0b5cfac0b2
commit 6c98a678ff
13 changed files with 57 additions and 52 deletions

View File

@@ -23,13 +23,13 @@ func init() {
}
// 命中之后
func (e *Effect1) OnSkill( ) bool {
func (e *Effect1) OnSkill() bool {
if !e.Hit() {
return true
}
e.Input.Heal(
&action.SelectSkillAction{}, e.Input.DamageZone.Damage.Div(decimal.NewFromInt(2)),
e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.DamageZone.Damage.Div(decimal.NewFromInt(2)),
)
return true
}

View File

@@ -58,7 +58,7 @@ func (e *Effect21) Skill_Use_ex() bool {
return true
}
e.Ctx().Opp.Damage(&info.DamageZone{
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: decimal.NewFromInt(int64(e.Ctx().Opp.DamageZone.Damage.IntPart())).Div(decimal.NewFromInt(int64(e.SideEffectArgs[0]))),

View File

@@ -28,7 +28,7 @@ func (e *Effect28) OnSkill() bool {
return true
}
e.Ctx().Our.Damage(&info.DamageZone{
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: decimal.NewFromInt(int64(e.Ctx().Opp.CurrentPet.Info.Hp)).Div(decimal.NewFromInt(int64(e.SideEffectArgs[0]))),
})

View File

@@ -28,7 +28,7 @@ func (e *Effect29) OnSkill() bool {
return true
}
e.Ctx().Our.Damage(&info.DamageZone{
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: decimal.NewFromInt(int64(e.SideEffectArgs[0])),

View File

@@ -28,7 +28,7 @@ func (e *Effect43) OnSkill() bool {
return true
}
e.Input.Heal(&action.SelectSkillAction{}, decimal.NewFromInt(int64(e.Input.MaxHp)).Div(decimal.NewFromInt(int64(e.SideEffectArgs[0]))))
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, decimal.NewFromInt(int64(e.Ctx().Our.MaxHp)).Div(decimal.NewFromInt(int64(e.SideEffectArgs[0]))))
return true
}

View File

@@ -26,7 +26,7 @@ type Effect6 struct {
// 我方使用效果
func (e *Effect6) Skill_Useed() bool {
e.Input.Damage(&info.DamageZone{
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
//这个对面计算前是在他的回合,所以后手也能拿到伤害
Damage: e.Ctx().Opp.DamageZone.Damage.Div(decimal.NewFromInt(int64(e.SideEffectArgs[0]))),
})

View File

@@ -33,7 +33,7 @@ func (e *Effect62_sub) OnSkill() bool {
if e.Duration() == 0 { //说明对方没有切换精灵
//直接扣除所有血量OnSkill
//相当于对方给自己的伤害
e.Ctx().Opp.Damage(&info.DamageZone{
e.Ctx().Our.Damage(e.Ctx().Opp, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: decimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
})

View File

@@ -37,7 +37,10 @@ func (e *Effect7) Damage_Floor() bool {
}
fmt.Println("Effect7_old", e.Ctx().DamageZone.Damage.IntPart())
if e.Ctx().DamageZone.Type == info.DamageType.Red {
e.Ctx().DamageZone.Damage = decimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.Hp - e.Ctx().Opp.CurrentPet.Info.Hp))
if e.Ctx().Our.CurrentPet.Info.Hp <= e.Ctx().Opp.CurrentPet.Info.Hp {
e.Ctx().DamageZone.Damage = decimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.Hp - e.Ctx().Opp.CurrentPet.Info.Hp))
}
}
fmt.Println("Effect7_new", e.Ctx().DamageZone.Damage.IntPart())

View File

@@ -61,10 +61,10 @@ type DrainHP struct {
}
func (e *DrainHP) Skill_Hit_Pre() bool {
e.damage = decimal.NewFromUint64(uint64(e.Input.CurrentPet.Info.MaxHp)).
e.damage = decimal.NewFromUint64(uint64(e.Ctx().Our.CurrentPet.Info.MaxHp)).
Div(decimal.NewFromInt(8))
e.Input.Damage(&info.DamageZone{
e.Ctx().Our.Damage(e.Input, &info.DamageZone{
Type: info.DamageType.True,
Damage: e.damage,
@@ -87,7 +87,7 @@ func (e *DrainedHP) Skill_Hit_Pre() bool {
//TODO 寄生种子 给对面回血待实现回血buff
//这个回血不属于任何类型,所以不会被阻止回血
e.Ctx().Opp.Heal(nil, e.damage)
e.Ctx().Opp.Heal(e.Ctx().Our, nil, e.damage)
// input.CurrentPet.Info.Hp = -e.Input.CurrentPet.Info.MaxHp / 8
return true

View File

@@ -84,7 +84,7 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *info.Ski
return true
})
attacker.Damage(&info.DamageZone{
defender.Damage(attacker, &info.DamageZone{
Damage: attacker.DamageZone.Damage,
},

View File

@@ -46,10 +46,12 @@ func (our *Input) CalculateCrit(opp *Input, skill *info.SkillEntity) {
}
// 恢复血量
func (our *Input) Heal(ac action.BattleActionI, value decimal.Decimal) {
func (our *Input) Heal(in *Input, ac action.BattleActionI, value decimal.Decimal) {
//使用道具回血
if _, ok := ac.(*action.UseItemAction); !ok && ac != nil {
if _, ok := ac.(*action.UseItemAction); !ok &&
ac != nil &&
in == our {
our.AttackValue.GainHp = int32(value.IntPart()) //道具有专门的回血包
}
@@ -94,41 +96,41 @@ func (our *Input) DelPP(value int) {
// /红伤只允许调用一次来保持锁伤
// 这个方法是对对方造成伤害
// 伤害落实 // 血量扣减节点比如触发回神,反弹也在这里实现
func (our *Input) Damage(sub *info.DamageZone) {
// sub := deep.MustCopy(ctx.DamageZone) //拷贝伤害,避免直接上下文传递,便于附加伤害
// sub := ctx.DamageZone
//sub.BeforeADD = sub.Damage
ok := our.Exec(func(t Effect) bool {
t.Ctx().DamageZone = sub
t.Damage_ADD() //红伤落实前,我方增伤
return true
})
//sub.BeforeMul = sub.Damage
if ok {
ok = our.Exec(func(t Effect) bool {
func (our *Input) Damage(in *Input, sub *info.DamageZone) {
// 对方对我方造成,需要吃到对方的加成
var ok bool
if our != in {
ok = our.Opp.Exec(func(t Effect) bool {
t.Ctx().DamageZone = sub
t.Damage_Mul() //红伤落实前,我方增伤
t.Damage_ADD() //红伤落实前,我方增伤
return true
})
}
//sub.BeforeFloor = sub.Damage
if ok {
ok = our.Exec(func(t Effect) bool {
t.Ctx().DamageZone = sub
t.Damage_Floor() //红伤落实,内部有befer
return true
})
//sub.BeforeMul = sub.Damage
if ok {
ok = our.Opp.Exec(func(t Effect) bool {
t.Ctx().DamageZone = sub
t.Damage_Mul() //红伤落实前,我方增伤
return true
})
}
//sub.BeforeFloor = sub.Damage
if ok {
ok = our.Opp.Exec(func(t Effect) bool {
t.Ctx().DamageZone = sub
t.Damage_Floor() //红伤落实,内部有befer
return true
})
}
}
// sub.BeforeMul = sub.Damage
if ok {
ok = our.Opp.Exec(func(t Effect) bool {
ok = our.Exec(func(t Effect) bool {
t.Ctx().DamageZone = sub
t.Damage_DIV_ex() //红伤落实,内部有befer
@@ -138,7 +140,7 @@ func (our *Input) Damage(sub *info.DamageZone) {
//sub.BeforeSUB = sub.Damage
if ok {
ok = our.Opp.Exec(func(t Effect) bool {
ok = our.Exec(func(t Effect) bool {
t.Ctx().DamageZone = sub
t.Damage_SUB_ex()
@@ -148,7 +150,7 @@ func (our *Input) Damage(sub *info.DamageZone) {
}
// sub.BeforeLock = sub.Damage
if ok {
if ok && in != our {
ok = our.Opp.Exec(func(t Effect) bool {
t.Damage_Lock()
@@ -158,7 +160,7 @@ func (our *Input) Damage(sub *info.DamageZone) {
}
//sub.BeforeLocked = sub.Damage
if ok {
our.Opp.Exec(func(t Effect) bool {
our.Exec(func(t Effect) bool {
t.Damage_Lock_ex()
@@ -167,15 +169,15 @@ func (our *Input) Damage(sub *info.DamageZone) {
}
if sub.Type == info.DamageType.Red { //红才会产生造成伤害
our.DamageZone.Damage = sub.Damage // 叠加总伤害
our.AttackValue.LostHp = uint32(our.DamageZone.Damage.IntPart()) //红伤落实
our.Opp.DamageZone.Damage = sub.Damage // 叠加总伤害
our.Opp.AttackValue.LostHp = uint32(our.Opp.DamageZone.Damage.IntPart()) //红伤落实
}
if uint32(our.DamageZone.Damage.IntPart()) > our.Opp.CurrentPet.Info.Hp {
if uint32(our.Opp.DamageZone.Damage.IntPart()) > our.CurrentPet.Info.Hp {
our.Opp.CurrentPet.Info.Hp = 0
our.CurrentPet.Info.Hp = 0
} else {
our.Opp.CurrentPet.Info.Hp = our.Opp.CurrentPet.Info.Hp - uint32(our.DamageZone.Damage.IntPart())
our.CurrentPet.Info.Hp = our.CurrentPet.Info.Hp - uint32(our.Opp.DamageZone.Damage.IntPart())
}
//todo 待实现死亡effet

View File

@@ -32,8 +32,8 @@ type Effect interface {
Skill_Use_ex() bool //技能PP减少节点
Skill_Useed() bool //技能PP减少节点
//OnDefeat(opp *Input) bool // 精灵被击败时触发
OnSwitchIn() bool // 精灵出战 / 上场时触发
OnSwitchOut() bool // 精灵下场时触发
OnSwitch(in *Input,) bool // 精灵出战 / 上场时触发
//OnSwitchOut() bool // 精灵下场时触发
// OnOwnerSwitchIn() bool // 所属玩家精灵出战时触发
// OnOwnerSwitchOut() bool // 所属玩家精灵下场时触发

View File

@@ -200,7 +200,7 @@ func (f *FightC) handleItemAction(a *action.UseItemAction) {
return true
})
f.GetInputByAction(a, false).Heal(a, decimal.NewFromInt(int64(addhp)))
f.GetInputByAction(a, false).Heal(f.GetInputByAction(a, false), a, decimal.NewFromInt(int64(addhp)))
f.Broadcast(func(ff *input.Input) {
ff.Player.SendUsePetItemInfo(info.UsePetIteminfo{
UserID: f.GetInputByAction(a, false).UserID,