feat(player): 添加 UseCoins 方法统一处理玩家金币消耗逻辑

重构购买物品和变更外观功能,使用 UseCoins 方法替代手动操作 Coins 字段,
确保金币扣除的安全性和一致性。同时修复可能因并发导致的金币超扣问题。

此外,调整部分战斗系统接口参数传递方式,将 DamageZone 指
This commit is contained in:
2025-11-13 21:36:18 +08:00
parent 6e01848b04
commit 5e3d558d30
24 changed files with 306 additions and 114 deletions

View File

@@ -1,6 +1,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,6 +12,7 @@ import (
type BaseSataus struct {
node.EffectNode
Status info.EnumBattleStatus
}
// /重写切换事件
@@ -27,33 +29,26 @@ func (e *BaseSataus) Switch(in *input.Input, outpet, inpet *info.BattlePetEntity
return true
}
// 施加一个基类effect
type EffectStatus struct {
BaseSataus
Status info.EnumBattleStatus
}
type StatusNotSkill struct {
EffectStatus
BaseSataus
}
// 不能出手
func (e *StatusNotSkill) Skill_Hit_Pre() bool {
func (e *StatusNotSkill) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool {
return false
}
type StatusSleep struct { //睡眠不能出手 ,这个挂载到对面来实现对方攻击后解除睡眠效果
BaseSataus
StatusNotSkill
can bool
}
func (e *StatusSleep) Skill_Hit_Pre() bool {
e.StatusNotSkill.Skill_Hit_Pre()
func (e *StatusSleep) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool {
e.can = true
return false
return e.StatusNotSkill.Skill_Hit_Pre(a, b)
}
func (e *StatusSleep) Skill_Use_ex() bool {
@@ -71,12 +66,12 @@ func (e *StatusSleep) Skill_Use_ex() bool {
// 扣血类
type DrainHP struct {
EffectStatus
BaseSataus
damage decimal.Decimal
}
func (e *DrainHP) Skill_Hit_Pre() bool {
func (e *DrainHP) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool {
e.damage = decimal.NewFromUint64(uint64(e.Ctx().Our.CurrentPet.Info.MaxHp)).
Div(decimal.NewFromInt(8))
@@ -94,12 +89,12 @@ type DrainedHP struct {
DrainHP
}
func (e *DrainedHP) Skill_Hit_Pre() bool {
func (e *DrainedHP) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool {
if gconv.Int(e.Input.CurrentPet.Type) == 1 {
return true
}
e.DrainHP.Skill_Hit_Pre() //先调用父类扣血
e.DrainHP.Skill_Hit_Pre(a, b) //先调用父类扣血
//TODO 寄生种子 给对面回血待实现回血buff
//这个回血不属于任何类型,所以不会被阻止回血