```
feat(fight): 新增使用宠物物品功能 - 在Controller中新增UsePetItemInboundInfo方法,用于处理宠物物品使用请求 - 在FightI接口中添加UseItem方法定义,支持传入捕获时间和物品ID - 修改UseItemAction结构体,增加CacthTime字段以记录宠物捕获时间 - 新增UsePetItemInboundInfo结构体,定义宠物物品使用的消息格式 - 在FightC中实现UseItem方法,将使用物品的动作发送到actionChan ```
This commit is contained in:
@@ -198,3 +198,11 @@ func (h Controller) LoadPercent(data *fight.LoadPercentInboundInfo, c *player.Pl
|
||||
|
||||
return nil, -1
|
||||
}
|
||||
func (h Controller) UsePetItemInboundInfo(data *fight.UsePetItemInboundInfo, c *player.Player) (result *info.UsePetItemOutboundInfo, err errorcode.ErrorCode) {
|
||||
if c.FightC != nil {
|
||||
|
||||
c.FightC.UseItem(c, data.CatchTime, data.ItemId)
|
||||
}
|
||||
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ type FightI interface {
|
||||
Capture(c PlayerI, id uint32)
|
||||
GetRand() *rand.Rand
|
||||
LoadPercent(c PlayerI, percent int32)
|
||||
UseItem(c PlayerI, cacthid, itemid uint32)
|
||||
CanEscape() bool
|
||||
IsFirst(c PlayerI) bool
|
||||
}
|
||||
|
||||
@@ -77,7 +77,8 @@ func (a *ActiveSwitchAction) Priority() int {
|
||||
// UsePotionAction 使用药剂的战斗动作
|
||||
type UseItemAction struct {
|
||||
BaseAction
|
||||
ItemID uint32 // 药剂ID
|
||||
ItemID uint32 // 药剂ID
|
||||
CacthTime uint32
|
||||
TargetPet info.BattlePetEntity // 药剂作用目标宠物
|
||||
}
|
||||
|
||||
|
||||
@@ -80,3 +80,12 @@ 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的填充字段
|
||||
}
|
||||
|
||||
11
logic/service/fight/info/item.go
Normal file
11
logic/service/fight/info/item.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package info
|
||||
|
||||
// UsePetItemOutboundInfo 对应Java的UsePetItemOutboundInfo,实现OutboundMessage接口
|
||||
type UsePetItemOutboundInfo struct {
|
||||
UserID uint32 `description:"玩家ID" codec:"userId"` // @UInt long 对应Go的uint32(无符号64位)
|
||||
ItemID uint32 `description:"使用的物品ID" codec:"itemId"` // 结构体标签模拟@FieldDescription和@AutoCodec注解
|
||||
UserHp uint32 `description:"用户血量 这里是原始HP+药剂回复的HP总和 比如我只有20血使用了150药剂 这里应该是170 使用PP药剂 这里为原始HP" codec:"userHp"`
|
||||
//这里实现是int, 可以+血
|
||||
|
||||
ChangeHp int32 `description:"改变血量 药剂增加的血量 使用PP药剂这里为0 实际增加PP为Note USE Skill包" codec:"changeHp"`
|
||||
}
|
||||
@@ -93,6 +93,11 @@ func (f *FightC) Capture(c common.PlayerI, id uint32) {
|
||||
f.actionChan <- &action.UseItemAction{BaseAction: action.NewBaseAction(c.GetInfo().UserID), ItemID: id}
|
||||
}
|
||||
|
||||
func (f *FightC) UseItem(c common.PlayerI, cacthid, itemid uint32) {
|
||||
|
||||
f.actionChan <- &action.UseItemAction{BaseAction: action.NewBaseAction(c.GetInfo().UserID), ItemID: itemid, CacthTime: cacthid}
|
||||
}
|
||||
|
||||
// 战斗准备
|
||||
func (f *FightC) ReadyFight(c common.PlayerI) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user