Files
bl/logic/service/player/fight.go
昔念 502d497dce ```
refactor(controller): 重构控制器函数命名和代码注释

- 重命名 EGG 函数为 EggGamePlay,更新宠物生成逻辑
- 重命名 Leiyi 函数为 GetLeiyiTrainStatus
- 重命名 Cacthpet 函数为 CatchPet,添加详细函数注释
- 为 ArenaSetOwner、ArenaFightOwner、ArenaGetInfo、ArenaUpfight、ArenaOwnerAcce
  等擂台相关函数添加注释前缀
- 重命名 PETKing 函数为 PetKing
- 重命名 FRESH_CHOICE_FIGHT_LEVEL 函数为 FreshChoiceFightLevel,添加详细参数说明
- 重命名 BuyMItem 函数为 BuyMultipleItems
- 重命名 ITEM_S
2025-12-24 19:03:11 +08:00

41 lines
1.1 KiB
Go

package player
import (
"blazing/common/socket/errorcode"
"blazing/logic/service/common"
"blazing/logic/service/fight/info"
"sync/atomic"
)
// JoinFight 加入战斗队列
func (p *Player) JoinFight(handler func(p common.PlayerI) bool) errorcode.ErrorCode {
//加入队列前就开始判断一次
if !p.CanFight() {
return errorcode.ErrorCodes.ErrNoEligiblePokemon
}
if p.GetSpace().Owner.UserID == p.Info.UserID {
return errorcode.ErrorCodes.ErrSystemError
}
p.GetSpace().User.Range(func(key uint32, opponent common.PlayerI) bool {
if opponent.GetInfo().UserID != p.Info.UserID {
//确认是乱斗模式
if opponent.Getfightinfo() == p.Getfightinfo() && p.CanFight() {
success := handler(opponent)
if success {
atomic.StoreUint32(&opponent.(*Player).Fightinfo.Mode, 0)
atomic.StoreUint32(&p.Fightinfo.Mode, 0)
}
return success //如果发起成功就停止,否则继续遍历队列
}
}
return false
})
return 0
}
// SendLoadPercent 发送加载进度
func (p *Player) SendLoadPercent(loadInfo info.LoadPercentOutboundInfo) {
p.SendPack(common.NewTomeeHeader(2441, p.Info.UserID).Pack(&loadInfo))
}