refactor(fight): 重构战斗准备逻辑并优化战斗启动流程 将 ReadyFight 方法拆分为多个职责清晰的子方法: - buildFightStartInfo: 构建战斗初始信息 - checkBothPlayersReady: 检查PVP双方是否就绪 - handleNPCFightSpecial: 处理NPC战斗特殊逻辑(如可捕捉标记) - startBattle: 统一启动战斗流程 同时修复部分逻辑顺序问题,增强代码可读性和扩展性。 feat(fight): 新增精灵王挑战协议支持 增加 StartPetWarInboundInfo 结构体用于接收精灵王挑战请求, 为后续实现相关功能提供基础。 fix(effect): 修正多个技能效果数值引用错误 - effect_37: 技能威力计算使用正确参数索引 - effect_50: 固定减伤比例调整为除以2 - effect_65: 正确比较技能分类类型 - effect_68: 致死保护改为锁定剩余1点生命值 - effect_77: 回复目标由敌方改为己方 - effect_93: 固定伤害值直接取参数 refactor(effect): 移除冗余效果类文件 删除 effect_133.go 和 effect_90.go 文件,其功能已被统一条件伤害和倍率系统取代; 移除 effect_74.go、effect_75.go 中重复的状态随机施加逻辑。 refactor(effect): 更新能力操作枚举命名一致性 重命名 AbilityOpType 枚举项名称,去除前缀,提升语义清晰度: - AbilityOpStealStrengthen → StealStrengthen - AbilityOpReverse → Reverse - AbilityOpBounceWeaken → BounceWeaken chore(fight): 完善 BattlePetEntity 属性初始化逻辑 在创建 BattlePetEntity 时即设置 PType,避免后续多次查询 PetMAP; 移除 Type() 方法中的冗余配置查找逻辑。 fix(skill): 确保必中技能不参与命中率计算 在 AttackTimeC 方法中添加 return 防止必中技能继续执行命中率公式计算。 refactor(fight): 调整战斗回合结束逻辑 进入新回合时允许玩家更换精灵,并提前跳出循环防止多余处理。 style(effect): 更正拼写及变量命名风格 修改 BaseSataus.Switch 方法签名中的参数命名; 更正 Effect58 中 can 字段首字母大写;
96 lines
3.1 KiB
Go
96 lines
3.1 KiB
Go
package fight
|
||
|
||
import (
|
||
_ "blazing/logic/service/fight/effect"
|
||
"blazing/logic/service/fight/info"
|
||
"blazing/logic/service/player"
|
||
)
|
||
|
||
// 野怪对战包
|
||
type FightNpcMonsterInboundInfo struct {
|
||
Head player.TomeeHeader `cmd:"2408" struc:"[0]pad"`
|
||
// Number 地图刷新怪物结构体对应的序号(1-9的位置序号)
|
||
|
||
Number uint32 `fieldDesc:"地图刷新怪物结构体对应的序号 1 - 9 的位置序号" `
|
||
}
|
||
type ChallengeBossInboundInfo struct {
|
||
Head player.TomeeHeader `cmd:"2411" struc:"[0]pad"`
|
||
BossId uint32 `json:"bossId"`
|
||
}
|
||
type NullOutboundInfo struct {
|
||
}
|
||
|
||
// 准备战斗包
|
||
type ReadyToFightInboundInfo struct {
|
||
Head player.TomeeHeader `cmd:"2404" struc:"[0]pad"`
|
||
}
|
||
|
||
// 战斗逃跑
|
||
type EscapeFightInboundInfo struct {
|
||
Head player.TomeeHeader `cmd:"2410" struc:"[0]pad"`
|
||
}
|
||
|
||
// 精灵王
|
||
type StartPetWarInboundInfo struct {
|
||
Head player.TomeeHeader `cmd:"2431" struc:"[0]pad"`
|
||
}
|
||
|
||
// HandleFightInviteInboundInfo 处理战斗邀请的入站消息
|
||
|
||
type HandleFightInviteInboundInfo struct {
|
||
Head player.TomeeHeader `cmd:"2403" struc:"[0]pad"`
|
||
UserID uint32 `json:"userId" codec:"userId,uint"` // 邀请我对战人的userid
|
||
Flag uint32 `json:"flag" codec:"flag,uint"` // 1为同意对战 0为取消对战
|
||
Mode info.EnumBattleMode `json:"mode" codec:"mode,uint"` // 战斗类型 1 = 1v1 2 = 6v6
|
||
}
|
||
|
||
type InviteToFightInboundInfo struct {
|
||
Head player.TomeeHeader `cmd:"2401" struc:"[0]pad"`
|
||
|
||
UserID uint32 `codec:"true"`
|
||
|
||
// Mode 战斗类型 1 = 1v1 2 = 6v6
|
||
Mode info.EnumBattleMode `codec:"true"`
|
||
}
|
||
type InviteFightCancelInboundInfo struct {
|
||
Head player.TomeeHeader `cmd:"2402" struc:"[0]pad"`
|
||
}
|
||
|
||
// 2502的回复包 PVP邀请消息
|
||
type NoteHandleFightInviteOutboundInfo struct {
|
||
UserID uint32
|
||
Nickname string `struc:"[16]byte"` // 固定长度16字节
|
||
Result uint32 // 0=拒绝 1=同意 2=在线超6小时 3=无出战精灵 4=不在线
|
||
}
|
||
|
||
type UseSkillInInfo struct {
|
||
Head player.TomeeHeader `cmd:"2405" struc:"[0]pad"`
|
||
// 技能id,
|
||
SkillId uint32
|
||
}
|
||
type ChangePetInboundInfo struct {
|
||
Head player.TomeeHeader `cmd:"2407" struc:"[0]pad"`
|
||
// CatchTime 捕捉时间
|
||
CatchTime uint32 `json:"catchTime"`
|
||
}
|
||
type CatchMonsterInboundInfo struct {
|
||
Head player.TomeeHeader `cmd:"2409" struc:"[0]pad"`
|
||
// CapsuleId 胶囊id
|
||
|
||
CapsuleId uint32 `json:"capsuleId" fieldDescription:"胶囊id" uint:"true"`
|
||
}
|
||
|
||
type LoadPercentInboundInfo struct {
|
||
Head player.TomeeHeader `cmd:"2441" struc:"[0]pad"`
|
||
Percent uint32 `fieldDescription:"加载百分比"`
|
||
}
|
||
|
||
// UsePetItemInboundInfo 对应Java的UsePetItemInboundInfo,实现InboundMessage接口
|
||
type UsePetItemInboundInfo struct {
|
||
Head player.TomeeHeader `cmd:"2406" struc:"[0]pad"`
|
||
// 字段首字母大写以导出(对应Java的可访问性,配合@Data的getter/setter)
|
||
CatchTime uint32 `description:"精灵捕获时间" codec:"catchTime"` // @UInt long 对应Go的uint32(无符号64位)
|
||
ItemId uint32 `description:"使用的物品ID" codec:"itemId"` // 结构体标签模拟@FieldDescription和@AutoCodec注解
|
||
Reversed1 uint32 `description:"填充字段 0" codec:"reversed1"` // reversed1对应原Java的填充字段
|
||
}
|