feat(player): 添加 UseCoins 方法统一处理玩家金币消耗逻辑 重构购买物品和变更外观功能,使用 UseCoins 方法替代手动操作 Coins 字段, 确保金币扣除的安全性和一致性。同时修复可能因并发导致的金币超扣问题。 此外,调整部分战斗系统接口参数传递方式,将 DamageZone 指
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package effect
|
|
|
|
import (
|
|
"blazing/logic/service/fight/action"
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/fight/input"
|
|
"blazing/logic/service/fight/node"
|
|
"fmt"
|
|
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
/**
|
|
* 对方体力高于自己时才能命中,将对方体力减到和自己相同
|
|
*/
|
|
|
|
func init() {
|
|
input.InitEffect(input.EffectType.Skill, 7, &Effect7{
|
|
EffectNode: node.EffectNode{},
|
|
})
|
|
|
|
}
|
|
|
|
type Effect7 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect7) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool {
|
|
if e.Ctx().Opp.CurrentPet.Info.Hp <= e.Ctx().Our.CurrentPet.Info.Hp {
|
|
e.Ctx().SkillEntity.Accuracy = 0
|
|
}
|
|
|
|
return true
|
|
}
|
|
func (e *Effect7) Damage_Floor(t *info.DamageZone) bool {
|
|
if !e.Hit() {
|
|
return true
|
|
}
|
|
fmt.Println("Effect7_old", t.Damage.IntPart())
|
|
if t.Type == info.DamageType.Red {
|
|
if e.Ctx().Our.CurrentPet.Info.Hp <= e.Ctx().Opp.CurrentPet.Info.Hp {
|
|
|
|
t.Damage = decimal.NewFromInt(int64(e.Ctx().Opp.CurrentPet.Info.Hp - e.Ctx().Our.CurrentPet.Info.Hp))
|
|
|
|
}
|
|
|
|
}
|
|
fmt.Println("Effect7_new", t.Damage.IntPart())
|
|
return true
|
|
}
|