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

@@ -105,9 +105,8 @@ 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_ADD() //红伤落实前,我方增伤
t.Damage_ADD(sub) //红伤落实前,我方增伤
return true
})
@@ -115,8 +114,8 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) {
//sub.BeforeMul = sub.Damage
if ok {
ok = our.Opp.Exec(func(t Effect) bool {
t.Ctx().DamageZone = sub
t.Damage_Mul() //红伤落实前,我方增伤
t.Damage_Mul(sub) //红伤落实前,我方增伤
return true
})
@@ -124,8 +123,8 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) {
//sub.BeforeFloor = sub.Damage
if ok {
ok = our.Opp.Exec(func(t Effect) bool {
t.Ctx().DamageZone = sub
t.Damage_Floor() //红伤落实,内部有befer
t.Damage_Floor(sub) //红伤落实,内部有befer
return true
})
@@ -135,8 +134,8 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) {
// sub.BeforeMul = sub.Damage
if ok {
ok = our.Exec(func(t Effect) bool {
t.Ctx().DamageZone = sub
t.Damage_DIV_ex() //红伤落实,内部有befer
t.Damage_DIV_ex(sub) //红伤落实,内部有befer
return true
})
@@ -145,9 +144,8 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) {
//sub.BeforeSUB = sub.Damage
if ok {
ok = our.Exec(func(t Effect) bool {
t.Ctx().DamageZone = sub
t.Damage_SUB_ex()
t.Damage_SUB_ex(sub)
return true
})
@@ -157,7 +155,7 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) {
if ok && in != our {
ok = our.Opp.Exec(func(t Effect) bool {
t.Damage_Lock()
t.Damage_Lock(sub)
return true
})
@@ -166,7 +164,7 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) {
if ok {
our.Exec(func(t Effect) bool {
t.Damage_Lock_ex()
t.Damage_Lock_ex(sub)
return true
})