2025-11-14 23:09:16 +08:00
|
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/common/socket/errorcode"
|
|
|
|
|
|
|
|
|
|
|
|
"blazing/logic/service/fight"
|
|
|
|
|
|
"blazing/logic/service/fight/info"
|
|
|
|
|
|
"blazing/logic/service/player"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2025-12-23 10:46:17 +08:00
|
|
|
|
// checkFightStatus 检查战斗状态
|
|
|
|
|
|
func (h Controller) checkFightStatus(c *player.Player) errorcode.ErrorCode {
|
2025-11-21 02:40:27 +08:00
|
|
|
|
if c.FightC == nil {
|
2025-12-23 10:46:17 +08:00
|
|
|
|
return errorcode.ErrorCodes.ErrBattleEnded
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// OnReadyToFight 准备战斗
|
2026-04-05 07:24:36 +08:00
|
|
|
|
func (h Controller) OnReadyToFight(data *ReadyToFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-12-23 10:46:17 +08:00
|
|
|
|
if err := h.checkFightStatus(c); err != 0 {
|
|
|
|
|
|
return nil, err
|
2025-11-21 02:40:27 +08:00
|
|
|
|
}
|
2026-02-24 03:52:32 +08:00
|
|
|
|
go c.FightC.ReadyFight(c)
|
2025-11-14 23:09:16 +08:00
|
|
|
|
return nil, -1
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-23 10:46:17 +08:00
|
|
|
|
// UseSkill 使用技能包
|
2026-04-05 07:24:36 +08:00
|
|
|
|
func (h Controller) UseSkill(data *UseSkillInInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-12-23 10:46:17 +08:00
|
|
|
|
if err := h.checkFightStatus(c); err != 0 {
|
|
|
|
|
|
return nil, err
|
2025-11-14 23:09:16 +08:00
|
|
|
|
}
|
2026-04-06 00:58:23 +08:00
|
|
|
|
h.dispatchFightActionEnvelope(c, buildLegacyUseSkillEnvelope(data))
|
2025-11-14 23:09:16 +08:00
|
|
|
|
return nil, 0
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-05 02:25:44 +08:00
|
|
|
|
// UseSkillAt 组队/多战位技能包(cmd=7505)。
|
|
|
|
|
|
// 目标关系:0=对方 1=自己 2=队友。
|
2026-04-05 07:24:36 +08:00
|
|
|
|
func (h Controller) UseSkillAt(data *UseSkillAtInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2026-04-05 02:25:44 +08:00
|
|
|
|
if err := h.checkFightStatus(c); err != 0 {
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
}
|
2026-04-06 00:58:23 +08:00
|
|
|
|
h.dispatchFightActionEnvelope(c, buildIndexedUseSkillEnvelope(data))
|
2026-04-05 02:25:44 +08:00
|
|
|
|
return nil, 0
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-23 10:46:17 +08:00
|
|
|
|
// Escape 战斗逃跑
|
2026-04-05 07:24:36 +08:00
|
|
|
|
func (h Controller) Escape(data *EscapeFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-12-23 10:46:17 +08:00
|
|
|
|
if err := h.checkFightStatus(c); err != 0 {
|
|
|
|
|
|
return nil, err
|
2025-11-21 02:40:27 +08:00
|
|
|
|
}
|
2026-04-06 00:58:23 +08:00
|
|
|
|
h.dispatchFightActionEnvelope(c, buildLegacyEscapeEnvelope())
|
2025-11-14 23:09:16 +08:00
|
|
|
|
return nil, 0
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-23 10:46:17 +08:00
|
|
|
|
// ChangePet 切换精灵
|
2026-04-05 07:24:36 +08:00
|
|
|
|
func (h Controller) ChangePet(data *ChangePetInboundInfo, c *player.Player) (result *info.ChangePetInfo, err errorcode.ErrorCode) {
|
2025-12-23 10:46:17 +08:00
|
|
|
|
if err := h.checkFightStatus(c); err != 0 {
|
|
|
|
|
|
return nil, err
|
2025-11-14 23:09:16 +08:00
|
|
|
|
}
|
2026-04-06 00:58:23 +08:00
|
|
|
|
h.dispatchFightActionEnvelope(c, buildLegacyChangeEnvelope(data))
|
2025-11-14 23:09:16 +08:00
|
|
|
|
return nil, -1
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-23 10:46:17 +08:00
|
|
|
|
// Capture 捕捉精灵
|
2026-04-05 07:24:36 +08:00
|
|
|
|
func (h Controller) Capture(data *CatchMonsterInboundInfo, c *player.Player) (result *info.CatchMonsterOutboundInfo, err errorcode.ErrorCode) {
|
2025-12-23 10:46:17 +08:00
|
|
|
|
if err := h.checkFightStatus(c); err != 0 {
|
|
|
|
|
|
return nil, err
|
2025-11-21 02:40:27 +08:00
|
|
|
|
}
|
2026-02-24 00:27:17 +08:00
|
|
|
|
if c.GetSpace().IsTime {
|
2026-02-24 00:28:40 +08:00
|
|
|
|
if data.CapsuleId < 300009 {
|
2026-03-14 20:02:04 +08:00
|
|
|
|
go c.FightC.UseSkill(c, 0)
|
|
|
|
|
|
return nil, -1
|
2026-02-24 00:27:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-02-24 03:52:32 +08:00
|
|
|
|
go c.FightC.Capture(c, data.CapsuleId)
|
2025-11-14 23:09:16 +08:00
|
|
|
|
return nil, -1
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-23 10:46:17 +08:00
|
|
|
|
// LoadPercent 加载进度
|
2026-04-05 07:24:36 +08:00
|
|
|
|
func (h Controller) LoadPercent(data *LoadPercentInboundInfo, c *player.Player) (result *info.LoadPercentOutboundInfo, err errorcode.ErrorCode) {
|
2025-11-21 02:40:27 +08:00
|
|
|
|
if c.FightC == nil {
|
2025-11-28 00:16:51 +08:00
|
|
|
|
return nil, -1
|
2025-11-14 23:09:16 +08:00
|
|
|
|
}
|
2026-02-24 03:52:32 +08:00
|
|
|
|
go c.FightC.LoadPercent(c, int32(data.Percent))
|
2025-11-14 23:09:16 +08:00
|
|
|
|
return nil, -1
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-23 10:46:17 +08:00
|
|
|
|
// UsePetItemInboundInfo 使用宠物道具
|
2026-04-05 07:24:36 +08:00
|
|
|
|
func (h Controller) UsePetItemInboundInfo(data *UsePetItemInboundInfo, c *player.Player) (result *info.UsePetIteminfo, err errorcode.ErrorCode) {
|
2025-12-23 10:46:17 +08:00
|
|
|
|
if err := h.checkFightStatus(c); err != 0 {
|
|
|
|
|
|
return nil, err
|
2025-11-14 23:09:16 +08:00
|
|
|
|
}
|
2026-02-24 00:12:50 +08:00
|
|
|
|
if c.GetSpace().IsTime {
|
|
|
|
|
|
if data.ItemId < 300009 {
|
2026-03-14 20:02:04 +08:00
|
|
|
|
go c.FightC.UseSkill(c, 0)
|
2026-02-24 00:12:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-14 20:02:04 +08:00
|
|
|
|
|
2026-04-06 00:58:23 +08:00
|
|
|
|
h.dispatchFightActionEnvelope(c, buildLegacyUseItemEnvelope(data))
|
2025-11-14 23:09:16 +08:00
|
|
|
|
return nil, -1
|
|
|
|
|
|
}
|
2025-12-23 10:46:17 +08:00
|
|
|
|
|
|
|
|
|
|
// FightChat 战斗聊天
|
2026-04-05 07:24:36 +08:00
|
|
|
|
func (h Controller) FightChat(data *ChatInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-12-23 10:46:17 +08:00
|
|
|
|
if err := h.checkFightStatus(c); err != 0 {
|
|
|
|
|
|
return nil, err
|
2025-11-25 16:36:55 +08:00
|
|
|
|
}
|
2026-04-06 00:58:23 +08:00
|
|
|
|
h.dispatchFightActionEnvelope(c, buildChatEnvelope(data))
|
2025-11-25 16:36:55 +08:00
|
|
|
|
return nil, -1
|
|
|
|
|
|
}
|