- 在多个战斗控制器方法中添加 defer 调用,确保战斗操作正确延迟执行 - 修改 ChangePet 方法返回值类型,增强接口一致性 - 修复战斗准备阶段逻辑,重构战斗开始信息构建过程 - 移除冗余广播调用,调整 PVE 战斗初始化流程 - 更新 README 中的 pprof 命令地址并完善项目介绍部分 fix(effect): 修复效果叠加逻辑与ID解析问题 - 效果叠加时默认增加一层,而非直接相加参数 - 修正 EffectIDCombiner 类型、CatchTime 的掩码偏移计算错误 - 添加重复效果日志输出,便于调试追踪 feat(boss): 完善BOSS特性实现逻辑 - 修正 NewSel17 特性
96 lines
2.7 KiB
Go
96 lines
2.7 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
"sync/atomic"
|
|
|
|
"blazing/logic/service/fight"
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/player"
|
|
)
|
|
|
|
// 准备战斗
|
|
func (h Controller) OnReadyToFight(data *fight.ReadyToFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
if c.FightC == nil {
|
|
return nil, errorcode.ErrorCodes.ErrBattleEnded
|
|
}
|
|
defer c.FightC.ReadyFight(c)
|
|
return nil, -1
|
|
}
|
|
|
|
// 使用技能包
|
|
func (h Controller) UseSkill(data *fight.UseSkillInInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
if c.FightC == nil {
|
|
return nil, errorcode.ErrorCodes.ErrBattleEnded
|
|
}
|
|
defer c.FightC.UseSkill(c, data.SkillId)
|
|
return nil, 0
|
|
}
|
|
|
|
// 战斗逃跑
|
|
func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
if c.FightC == nil {
|
|
return nil, errorcode.ErrorCodes.ErrBattleEnded
|
|
}
|
|
|
|
if atomic.LoadUint32(&c.Fightinfo.Mode) == 0 {
|
|
|
|
return nil, errorcode.ErrorCodes.ErrBattleNotStarted //,没开始对战
|
|
}
|
|
if atomic.LoadUint32(&c.Fightinfo.Mode) == 1 { //用户对战不能逃跑
|
|
|
|
return nil, errorcode.ErrorCodes.ErrCannotFleePlayerBattle
|
|
}
|
|
defer c.FightC.Over(c, info.BattleOverReason.PlayerEscape)
|
|
return nil, 0
|
|
}
|
|
|
|
// 切换精灵
|
|
func (h Controller) ChangePet(data *fight.ChangePetInboundInfo, c *player.Player) (result *info.ChangePetInfo, err errorcode.ErrorCode) {
|
|
if c.FightC == nil {
|
|
return nil, errorcode.ErrorCodes.ErrBattleEnded
|
|
}
|
|
|
|
defer c.FightC.ChangePet(c, data.CatchTime)
|
|
return nil, -1
|
|
}
|
|
|
|
// 切换精灵
|
|
func (h Controller) Capture(data *fight.CatchMonsterInboundInfo, c *player.Player) (result *info.CatchMonsterOutboundInfo, err errorcode.ErrorCode) {
|
|
if c.FightC == nil {
|
|
return nil, errorcode.ErrorCodes.ErrBattleEnded
|
|
}
|
|
defer c.FightC.Capture(c, data.CapsuleId)
|
|
return nil, -1
|
|
}
|
|
|
|
// 加载进度
|
|
func (h Controller) LoadPercent(data *fight.LoadPercentInboundInfo, c *player.Player) (result *info.LoadPercentOutboundInfo, err errorcode.ErrorCode) {
|
|
if c.FightC == nil {
|
|
return nil, -1
|
|
}
|
|
|
|
defer c.FightC.LoadPercent(c, int32(data.Percent))
|
|
return nil, -1
|
|
}
|
|
func (h Controller) UsePetItemInboundInfo(data *fight.UsePetItemInboundInfo, c *player.Player) (result *info.UsePetIteminfo, err errorcode.ErrorCode) {
|
|
|
|
if c.FightC == nil {
|
|
return nil, errorcode.ErrorCodes.ErrBattleEnded
|
|
}
|
|
|
|
defer c.FightC.UseItem(c, data.CatchTime, data.ItemId)
|
|
|
|
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
|
|
}
|
|
|
|
defer c.FightC.Chat(c, data.Message)
|
|
|
|
return nil, -1
|
|
}
|