feat(player): 添加 UseCoins 方法统一处理玩家金币消耗逻辑 重构购买物品和变更外观功能,使用 UseCoins 方法替代手动操作 Coins 字段, 确保金币扣除的安全性和一致性。同时修复可能因并发导致的金币超扣问题。 此外,调整部分战斗系统接口参数传递方式,将 DamageZone 指
125 lines
3.2 KiB
Go
125 lines
3.2 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"
|
||
|
||
"github.com/gogf/gf/v2/util/gconv"
|
||
"github.com/shopspring/decimal"
|
||
)
|
||
|
||
type BaseSataus struct {
|
||
node.EffectNode
|
||
Status info.EnumBattleStatus
|
||
}
|
||
|
||
// /重写切换事件
|
||
func (e *BaseSataus) Switch(in *input.Input, outpet, inpet *info.BattlePetEntity) bool {
|
||
|
||
//状态如果是我方切换,那么就消除掉状态效果
|
||
if e.Input == e.Ctx().Our {
|
||
//下场,执行消回合效果
|
||
// e.ctx.Our.CancelAll()
|
||
///我放下场
|
||
e.Alive(false)
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
type StatusNotSkill struct {
|
||
BaseSataus
|
||
}
|
||
|
||
// 不能出手
|
||
func (e *StatusNotSkill) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool {
|
||
|
||
return false
|
||
|
||
}
|
||
|
||
type StatusSleep struct { //睡眠不能出手 ,这个挂载到对面来实现对方攻击后解除睡眠效果
|
||
StatusNotSkill
|
||
can bool
|
||
}
|
||
|
||
func (e *StatusSleep) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool {
|
||
|
||
e.can = true
|
||
return e.StatusNotSkill.Skill_Hit_Pre(a, b)
|
||
|
||
}
|
||
func (e *StatusSleep) Skill_Use_ex() bool {
|
||
if !e.can {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().Category() != info.Category.STATUS {
|
||
e.Alive(false)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// 扣血类
|
||
type DrainHP struct {
|
||
BaseSataus
|
||
|
||
damage decimal.Decimal
|
||
}
|
||
|
||
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))
|
||
|
||
e.Ctx().Our.Damage(e.Input, &info.DamageZone{
|
||
|
||
Type: info.DamageType.True,
|
||
Damage: e.damage,
|
||
})
|
||
|
||
return true
|
||
}
|
||
|
||
// 被寄生种子 扣血类
|
||
type DrainedHP struct {
|
||
DrainHP
|
||
}
|
||
|
||
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(a, b) //先调用父类扣血
|
||
//TODO 寄生种子 给对面回血,待实现回血buff
|
||
|
||
//这个回血不属于任何类型,所以不会被阻止回血
|
||
e.Ctx().Opp.Heal(e.Ctx().Our, nil, e.damage)
|
||
// input.CurrentPet.Info.Hp = -e.Input.CurrentPet.Info.MaxHp / 8
|
||
|
||
return true
|
||
|
||
}
|
||
func init() {
|
||
//麻痹,疲惫,害怕,石化,都是无法行动
|
||
|
||
tt := func(t info.EnumBattleStatus, f *StatusNotSkill) {
|
||
|
||
f.Status = t
|
||
input.InitEffect(input.EffectType.Status, int(t), f)
|
||
}
|
||
input.InitEffect(input.EffectType.Status, int(info.PetStatus.DrainedHP), &DrainedHP{}) //寄生种子
|
||
input.InitEffect(input.EffectType.Status, int(info.PetStatus.Poisoned), &DrainHP{}) //中毒
|
||
input.InitEffect(input.EffectType.Status, int(info.PetStatus.Frozen), &DrainHP{}) //冻伤
|
||
input.InitEffect(input.EffectType.Status, int(info.PetStatus.Burned), &DrainHP{}) //烧伤
|
||
tt(info.PetStatus.Paralysis, &StatusNotSkill{}) //麻痹
|
||
tt(info.PetStatus.Tired, &StatusNotSkill{}) //疲惫
|
||
tt(info.PetStatus.Fear, &StatusNotSkill{}) //害怕
|
||
tt(info.PetStatus.Petrified, &StatusNotSkill{}) //石化
|
||
input.InitEffect(input.EffectType.Status, 8, &StatusSleep{}) //睡眠
|
||
}
|