feat(broadcast): 添加全服广播功能并完善相关逻辑 新增 Broadcast 结构体及 Server 的 Broadcast 方法,用于实现全服广播消息, 并在 RPC 客户端中增加对应接口。同时在 fight 模块中添加聊天信息结构体和处理逻辑。 refactor(pet_skill): 优化宠物技能设置逻辑 修复宠物技能替换判断条件错误的问题,并调整相关逻辑顺序以提高代码可读性与健壮性。 feat(chat): 实现战斗内聊天功能 新增战斗中的聊天指令结构体 ChatInfo 和对应的控制器方法 FightChat, 支持玩家在战斗中发送聊天消息。 refactor(item_buy): 调整金币购买道具的扣费方式 将原直接比较金币数量改为调用
126 lines
4.2 KiB
Go
126 lines
4.2 KiB
Go
package fight
|
||
|
||
import (
|
||
"blazing/logic/service/common"
|
||
_ "blazing/logic/service/fight/effect"
|
||
)
|
||
|
||
// 野怪对战包
|
||
type FightNpcMonsterInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2408" struc:"skip"`
|
||
// Number 地图刷新怪物结构体对应的序号(1-9的位置序号)
|
||
|
||
Number uint32 `fieldDesc:"地图刷新怪物结构体对应的序号 1 - 9 的位置序号" `
|
||
}
|
||
type ChallengeBossInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2411" struc:"skip"`
|
||
BossId uint32 `json:"bossId"`
|
||
}
|
||
type NullOutboundInfo struct {
|
||
}
|
||
|
||
// 准备战斗包
|
||
type ReadyToFightInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2404" struc:"skip"`
|
||
}
|
||
|
||
// 战斗逃跑
|
||
type EscapeFightInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2410" struc:"skip"`
|
||
}
|
||
|
||
// 精灵王
|
||
type StartPetWarInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2431" struc:"skip"`
|
||
}
|
||
|
||
type ARENA_SET_OWENR struct {
|
||
Head common.TomeeHeader `cmd:"2417" struc:"skip"`
|
||
}
|
||
type ARENA_FIGHT_OWENR struct {
|
||
Head common.TomeeHeader `cmd:"2418" struc:"skip"`
|
||
}
|
||
|
||
type ARENA_GET_INFO struct {
|
||
Head common.TomeeHeader `cmd:"2419" struc:"skip"`
|
||
}
|
||
|
||
type ARENA_UPFIGHT struct {
|
||
Head common.TomeeHeader `cmd:"2420" struc:"skip"`
|
||
}
|
||
type ARENA_OWENR_ACCE struct {
|
||
Head common.TomeeHeader `cmd:"2422" struc:"skip"`
|
||
}
|
||
|
||
// 表示"宠物王加入"的入站消息数据
|
||
type PetKingJoinInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2413" struc:"skip"`
|
||
Type uint32 // 战斗类型:5=单精灵,6=多精灵,11=精灵大师赛 (对应Java的@UInt long type)
|
||
FightType uint32 // 仅当Type为11时有效 (对应Java的@UInt long fightType)
|
||
}
|
||
|
||
// HandleFightInviteInboundInfo 处理战斗邀请的入站消息
|
||
|
||
type HandleFightInviteInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2403" struc:"skip"`
|
||
UserID uint32 `json:"userId" codec:"userId,uint"` // 邀请我对战人的userid
|
||
Flag uint32 `json:"flag" codec:"flag,uint"` // 1为同意对战 0为取消对战
|
||
Mode uint32 `json:"mode" codec:"mode,uint"` // 战斗类型 1 = 1v1 2 = 6v6
|
||
}
|
||
|
||
type InviteToFightInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2401" struc:"skip"`
|
||
|
||
UserID uint32
|
||
|
||
// Mode 战斗类型 1 = 1v1 2 = 6v6
|
||
Mode uint32
|
||
}
|
||
type InviteFightCancelInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2402" struc:"skip"`
|
||
}
|
||
|
||
// 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 common.TomeeHeader `cmd:"2405" struc:"skip"`
|
||
// 技能id,
|
||
SkillId uint32
|
||
}
|
||
type ChangePetInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2407" struc:"skip"`
|
||
// CatchTime 捕捉时间
|
||
CatchTime uint32 `json:"catchTime"`
|
||
}
|
||
type CatchMonsterInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2409" struc:"skip"`
|
||
// CapsuleId 胶囊id
|
||
|
||
CapsuleId uint32 `json:"capsuleId" fieldDescription:"胶囊id" uint:"true"`
|
||
}
|
||
|
||
type LoadPercentInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2441" struc:"skip"`
|
||
Percent uint32 `fieldDescription:"加载百分比"`
|
||
}
|
||
|
||
// UsePetItemInboundInfo 对应Java的UsePetItemInboundInfo,实现InboundMessage接口
|
||
type UsePetItemInboundInfo struct {
|
||
Head common.TomeeHeader `cmd:"2406" struc:"skip"`
|
||
// 字段首字母大写以导出(对应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的填充字段
|
||
}
|
||
type ChatInfo struct {
|
||
Head common.TomeeHeader `cmd:"50002" struc:"skip"`
|
||
Reserve uint32 `json:"reserve" fieldDescription:"填充 默认值为0" uint:"true"` // @UInt long reserve,无符号长整数
|
||
MessageLen uint32 `struc:"sizeof=Message"`
|
||
Message string `json:"message" fieldDescription:"消息内容, 结束符为utf-8的数字0"` // 消息内容,包含utf-8空字符('\x00')作为结束符
|
||
}
|