feat(broadcast): 添加全服广播功能并完善相关逻辑

新增 Broadcast 结构体及 Server 的 Broadcast 方法,用于实现全服广播消息,
并在 RPC 客户端中增加对应接口。同时在 fight 模块中添加聊天信息结构体和处理逻辑。

refactor(pet_skill): 优化宠物技能设置逻辑

修复宠物技能替换判断条件错误的问题,并调整相关逻辑顺序以提高代码可读性与健壮性。

feat(chat): 实现战斗内聊天功能

新增战斗中的聊天指令结构体 ChatInfo 和对应的控制器方法 FightChat,
支持玩家在战斗中发送聊天消息。

refactor(item_buy): 调整金币购买道具的扣费方式

将原直接比较金币数量改为调用
This commit is contained in:
2025-11-25 16:36:55 +08:00
parent 40d72790ff
commit 3e1887c7b8
17 changed files with 115 additions and 30 deletions

View File

@@ -84,3 +84,12 @@ func (h Controller) UsePetItemInboundInfo(data *fight.UsePetItemInboundInfo, c *
return nil, -1
}
func (h Controller) FightChat(data *fight.ChatInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if c.FightC == nil {
return nil, errorcode.ErrorCodes.ErrBattleEnded
}
c.FightC.Chat(c, data.Message)
return nil, -1
}

View File

@@ -58,7 +58,7 @@ func (h Controller) BuyMItem(data *item.BuyMultiInboundInfo, c *player.Player) (
func (h Controller) BuyGoldItem(data *item.C2S_GOLD_BUY_PRODUCT, c *player.Player) (result *item.S2C_GoldBuyProductInfo, err errorcode.ErrorCode) {
r := xmlres.GoldProductMap[int(data.ProductID)]
if uint32(data.Count)*uint32(gconv.Uint32(r.Price)) > c.Info.GoldBean {
if !c.UseGold(uint32(data.Count) * uint32(gconv.Uint32(r.Price))) {
return nil, errorcode.ErrorCodes.ErrSystemError
}
c.ItemAdd(model.ItemInfo{ItemId: uint32(gconv.Uint32(r.ItemID)), ItemCnt: uint32(data.Count)})
@@ -69,6 +69,7 @@ func (h Controller) BuyGoldItem(data *item.C2S_GOLD_BUY_PRODUCT, c *player.Playe
PayGold: uint32(data.Count) * uint32(gconv.Uint32(r.Price)),
Reserved: 0,
}
return
}

View File

@@ -16,17 +16,16 @@ func (h Controller) SetPetSkill(data *pet.ChangeSkillInfo, c *player.Player) (re
}
_, onpet, ok := c.FindPet(data.CatchTime)
if ok {
_, HasSkill, ok := utils.FindWithIndex(onpet.SkillList, func(item model.SkillInfo) bool { //已经存在技能
return item.ID == data.ReplaceSkill
})
if !ok {
HasSkill.ID = data.ReplaceSkill
HasSkill.PP = uint32(xmlres.SkillMap[int(HasSkill.ID)].MaxPP)
}
if !ok {
return result, errorcode.ErrorCodes.ErrSystemBusy
}
_, HasSkill, ok := utils.FindWithIndex(onpet.SkillList, func(item model.SkillInfo) bool { //已经存在技能
return item.ID == data.HasSkill
})
if !ok {
HasSkill.ID = data.ReplaceSkill
HasSkill.PP = uint32(xmlres.SkillMap[int(HasSkill.ID)].MaxPP)
}
return &pet.ChangeSkillOutInfo{
CatchTime: data.CatchTime,
}, 0

View File

@@ -2,6 +2,7 @@ package controller
import (
"blazing/common/socket/errorcode"
"blazing/common/utils"
"blazing/cool"
"blazing/logic/service/item"
"blazing/logic/service/player"
@@ -51,7 +52,7 @@ func (h Controller) Chat(data *user.ChatInboundInfo, c *player.Player) (result *
result = &user.ChatOutboundInfo{
Message: string([]byte(data.Message)[:data.MessageLen-1]),
Message: utils.RemoveLast(data.Message),
SenderNickname: c.Info.Nick,
SenderId: c.Info.UserID,
}