refactor(fight): 重构战斗模块代码

- 优化了 FightC 结构体,将 Info 字段改为指针类型
- 添加了 EffectNode 类型的 Type 方法,用于获取效果类型
- 修改了 BattlePetEntity 中的 Attribute 结构,移除了未使用的枚举类型
- 删除了 info.go 文件中未使用的结构体定义
- 在 effect_1.go 中更新了 Effect1 类的 PostDamage 方法,待重写实现
This commit is contained in:
2025-09-04 02:11:55 +08:00
parent adfe5f17e7
commit 8e690dacd4
7 changed files with 14 additions and 20 deletions

View File

@@ -78,7 +78,7 @@ func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *service.Player
c.SendPack(ttt.Pack(&fight.FightOverInfo{
Reason: 0,
}))
c.FightC = nil
}()
return nil, 0

View File

@@ -16,7 +16,7 @@ type PlayerI interface {
SendNoteReadyToFightInfo(info.NoteReadyToFightInfo)
}
type FightC struct {
Info info.NoteReadyToFightInfo
Info *info.NoteReadyToFightInfo
Our PlayerI
Opp PlayerI
}
@@ -64,11 +64,8 @@ func (f *FightC) ReadyFight(c PlayerI) {
}
func (f *FightC) NewFight(i *info.NoteReadyToFightInfo, plays PlayerI) {
f.Our = plays
f.Info = i
// t12, _ := uuid.NewV7()
// uuid := strings.Replace(t12.String(), "-", "", -1) //绑定战斗ID
// /FightCache[uuid] = i
//先发送战斗准备包
f.Info.FightId = i.FightId
switch i.FightId {
case 1:

View File

@@ -28,6 +28,7 @@ func (this *Effect1) ID() int {
func (this *Effect1) PostDamage() bool {
off := this.GetSkill().DamageValue.Div(decimal.NewFromInt(2)) //伤害的一半
this.GetOwnerPet().Hp += uint32(off.IntPart()) //这里是effect在对方挂载,故回血给自己回血
this.GetOwnerPet().HP += int(off.IntPart()) //这里是effect在对方挂载,故回血给自己回血
//待重写实现
return true
}

View File

@@ -19,6 +19,7 @@ type EffectNode struct {
SideEffectArgs []int // 附加效果参数
Success bool // 是否执行成功 成功XXX失败XXX
efftype int // 传出作用对象,默认0是自身,1是作用于对面
}
@@ -26,6 +27,13 @@ func (this *EffectNode) ID() int {
return 0
}
// 传出作用对象,默认0是自身,1是作用于对面
func (this *EffectNode) Type() int {
return this.efftype
}
func (this *EffectNode) Stack(t int) int {
if t != 0 {

View File

@@ -6,8 +6,6 @@ import (
"blazing/modules/blazing/model"
"context"
"sync"
"github.com/tnnmigga/enum"
)
// 战斗属性类型
@@ -17,16 +15,6 @@ type EnumAttrType int
const Pet_O_Ctx = "PET_O"
const Pet_T_Ctx = "PET_T"
var AttrType = enum.New[struct {
Attack EnumAttrType `enum:"1"` //`enum:"攻击"`
Defense EnumAttrType `enum:"2"` //`enum:"防御"`
SpecialAttack EnumAttrType `enum:"3"` //`enum:"特殊攻击"`
SpecialDefense EnumAttrType `enum:"4"` //`enum:"特殊防御"`
Speed EnumAttrType `enum:"5"` //`enum:"速度"`
Accuracy EnumAttrType `enum:"6"` //`enum:"命中率"`
HP EnumAttrType `enum:"7"` //血量
}]()
// 属性封装结构Ext 存储临时血量增量key=状态IDvalue=增量值)
type Attribute struct {
//CanSet bool // 是否允许修改

View File

@@ -12,7 +12,7 @@ type Battle struct {
Round int //回合数
BattleMode EnumBattleMode //战斗模式
opposite []BattleInputSourceEntity //不同阵营
Effects map[uint32]*NodeManagerE //挂载effect,实际上是给每个输入源,然后触发时候循环调用Effects ,
Effects NodeManagerE //挂载effect,实际上是给每个输入源,然后触发时候循环调用Effects ,
//A的effect->触发死亡->这时候就应该调用对手的切换,实现effect62
}