feat(player): 添加 UseCoins 方法统一处理玩家金币消耗逻辑 重构购买物品和变更外观功能,使用 UseCoins 方法替代手动操作 Coins 字段, 确保金币扣除的安全性和一致性。同时修复可能因并发导致的金币超扣问题。 此外,调整部分战斗系统接口参数传递方式,将 DamageZone 指
35 lines
633 B
Go
35 lines
633 B
Go
package effect
|
|
|
|
import (
|
|
"blazing/common/utils"
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/fight/input"
|
|
"blazing/logic/service/fight/node"
|
|
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
/**
|
|
* 伤害大于对方体力时会余下1体力
|
|
*/
|
|
|
|
func init() {
|
|
input.InitEffect(input.EffectType.Skill, 8, &Effect8{})
|
|
|
|
}
|
|
|
|
type Effect8 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
// 伤害落实前触发,限制最大伤害
|
|
func (e *Effect8) Damage_Floor(t *info.DamageZone) bool {
|
|
if t.Type == info.DamageType.Red {
|
|
t.Damage = decimal.NewFromInt(utils.Min(t.Damage.IntPart(),
|
|
int64(e.Ctx().Opp.CurrentPet.Info.Hp)-1))
|
|
|
|
}
|
|
|
|
return true
|
|
}
|