feat(fight): 实现玩家间战斗邀请与处理功能

新增战斗邀请与处理逻辑,包括邀请发送、邀请接受/拒绝流程。
添加战斗模式支持(1v1 和 6v6)及相关数据结构定义。
优化玩家战斗准备逻辑,完善战斗初始化流程。
修复玩家离线保存数据时的空指针问题。
调整战斗相关枚举类型,统一管理战斗模式。
完善邀请战斗消息结构体及通信协议。
```
This commit is contained in:
2025-09-20 00:17:29 +08:00
parent d9a98515f1
commit 9c25ccc214
13 changed files with 635 additions and 331 deletions

View File

@@ -74,9 +74,19 @@ func (h Controller) OnReadyToFight(data *fight.ReadyToFightInboundInfo, c *playe
// 接收战斗或者取消战斗的包
func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if ok, p1 := c.AgreeBattle(data.UserID, data.Flag, data.Mode); ok {
fight.NewFight(info.EnumBattleMode(data.Mode), p1, c) ///开始对战,房主方以及被邀请方
}
return nil, -1
}
// 邀请其他人进行战斗
func (h Controller) OnPlayerInviteOtherFight(data *fight.InviteToFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
c.InvitePlayerToBattle(data.UserID, info.EnumBattleMode(data.Mode))
return nil, 0
}
// 使用技能包
func (h Controller) UseSkill(data *fight.UseSkillInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
c.FightC.UseSkill(c, int32(data.SkillId))

View File

@@ -88,7 +88,7 @@ func (h *Controller) MapList(data *maps.ListMapPlayerInboundInfo, c *player.Play
space.GetSpace(c.Info.MapID).Range(func(userID uint32, player common.PlayerI) bool {
result1 := maps.NewOutInfo()
copier.Copy(result1, player)
copier.Copy(result1, player.GetInfo())
result.Player = append(result.Player, *result1)
return true
})

24
logic/controller/user.go Normal file
View File

@@ -0,0 +1,24 @@
package controller
import (
"blazing/common/socket/errorcode"
"blazing/logic/service/player"
"blazing/logic/service/user"
"github.com/jinzhu/copier"
)
func (h Controller) UserSimInfo(data *user.SimUserInfoInboundInfo, c *player.Player) (result *user.SimUserInfoOutboundInfo, err errorcode.ErrorCode) {
ret := &user.SimUserInfoOutboundInfo{}
copier.Copy(ret, c.Service.PersonOther(data.UserId))
return ret, 0
}
func (h Controller) UserMoreInfo(data *user.MoreUserInfoInboundInfo, c *player.Player) (result *user.MoreUserInfoOutboundInfo, err errorcode.ErrorCode) {
ret := &user.MoreUserInfoOutboundInfo{}
info := c.Service.PersonOther(data.UserId)
copier.Copy(ret, info)
//todo 待实现
return ret, 0
}