refactor(fight): 重构战斗模块代码
- 优化了 FightC 结构体,将 Info 字段改为指针类型 - 添加了 EffectNode 类型的 Type 方法,用于获取效果类型 - 修改了 BattlePetEntity 中的 Attribute 结构,移除了未使用的枚举类型 - 删除了 info.go 文件中未使用的结构体定义 - 在 effect_1.go 中更新了 Effect1 类的 PostDamage 方法,待重写实现
This commit is contained in:
@@ -78,7 +78,7 @@ func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *service.Player
|
|||||||
c.SendPack(ttt.Pack(&fight.FightOverInfo{
|
c.SendPack(ttt.Pack(&fight.FightOverInfo{
|
||||||
Reason: 0,
|
Reason: 0,
|
||||||
}))
|
}))
|
||||||
|
c.FightC = nil
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return nil, 0
|
return nil, 0
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type PlayerI interface {
|
|||||||
SendNoteReadyToFightInfo(info.NoteReadyToFightInfo)
|
SendNoteReadyToFightInfo(info.NoteReadyToFightInfo)
|
||||||
}
|
}
|
||||||
type FightC struct {
|
type FightC struct {
|
||||||
Info info.NoteReadyToFightInfo
|
Info *info.NoteReadyToFightInfo
|
||||||
Our PlayerI
|
Our PlayerI
|
||||||
Opp PlayerI
|
Opp PlayerI
|
||||||
}
|
}
|
||||||
@@ -64,11 +64,8 @@ func (f *FightC) ReadyFight(c PlayerI) {
|
|||||||
}
|
}
|
||||||
func (f *FightC) NewFight(i *info.NoteReadyToFightInfo, plays PlayerI) {
|
func (f *FightC) NewFight(i *info.NoteReadyToFightInfo, plays PlayerI) {
|
||||||
f.Our = plays
|
f.Our = plays
|
||||||
|
f.Info = i
|
||||||
|
|
||||||
// t12, _ := uuid.NewV7()
|
|
||||||
// uuid := strings.Replace(t12.String(), "-", "", -1) //绑定战斗ID
|
|
||||||
// /FightCache[uuid] = i
|
|
||||||
//先发送战斗准备包
|
|
||||||
f.Info.FightId = i.FightId
|
f.Info.FightId = i.FightId
|
||||||
switch i.FightId {
|
switch i.FightId {
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ func (this *Effect1) ID() int {
|
|||||||
func (this *Effect1) PostDamage() bool {
|
func (this *Effect1) PostDamage() bool {
|
||||||
|
|
||||||
off := this.GetSkill().DamageValue.Div(decimal.NewFromInt(2)) //伤害的一半
|
off := this.GetSkill().DamageValue.Div(decimal.NewFromInt(2)) //伤害的一半
|
||||||
this.GetOwnerPet().Hp += uint32(off.IntPart()) //这里是effect在对方挂载,故回血给自己回血
|
this.GetOwnerPet().HP += int(off.IntPart()) //这里是effect在对方挂载,故回血给自己回血
|
||||||
|
//待重写实现
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ type EffectNode struct {
|
|||||||
SideEffectArgs []int // 附加效果参数
|
SideEffectArgs []int // 附加效果参数
|
||||||
|
|
||||||
Success bool // 是否执行成功 成功XXX,失败XXX
|
Success bool // 是否执行成功 成功XXX,失败XXX
|
||||||
|
efftype int // 传出作用对象,默认0是自身,1是作用于对面
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,6 +27,13 @@ func (this *EffectNode) ID() int {
|
|||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 传出作用对象,默认0是自身,1是作用于对面
|
||||||
|
func (this *EffectNode) Type() int {
|
||||||
|
|
||||||
|
return this.efftype
|
||||||
|
|
||||||
}
|
}
|
||||||
func (this *EffectNode) Stack(t int) int {
|
func (this *EffectNode) Stack(t int) int {
|
||||||
if t != 0 {
|
if t != 0 {
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import (
|
|||||||
"blazing/modules/blazing/model"
|
"blazing/modules/blazing/model"
|
||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/tnnmigga/enum"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 战斗属性类型
|
// 战斗属性类型
|
||||||
@@ -17,16 +15,6 @@ type EnumAttrType int
|
|||||||
const Pet_O_Ctx = "PET_O"
|
const Pet_O_Ctx = "PET_O"
|
||||||
const Pet_T_Ctx = "PET_T"
|
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=状态ID,value=增量值)
|
// 属性封装结构:Ext 存储临时血量增量(key=状态ID,value=增量值)
|
||||||
type Attribute struct {
|
type Attribute struct {
|
||||||
//CanSet bool // 是否允许修改
|
//CanSet bool // 是否允许修改
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type Battle struct {
|
|||||||
Round int //回合数
|
Round int //回合数
|
||||||
BattleMode EnumBattleMode //战斗模式
|
BattleMode EnumBattleMode //战斗模式
|
||||||
opposite []BattleInputSourceEntity //不同阵营
|
opposite []BattleInputSourceEntity //不同阵营
|
||||||
Effects map[uint32]*NodeManagerE //挂载effect,实际上是给每个输入源,然后触发时候循环调用Effects ,
|
Effects NodeManagerE //挂载effect,实际上是给每个输入源,然后触发时候循环调用Effects ,
|
||||||
|
|
||||||
//A的effect->触发死亡->这时候就应该调用对手的切换,实现effect62
|
//A的effect->触发死亡->这时候就应该调用对手的切换,实现effect62
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user