All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
refactor(common/data/xmlres): 注释掉未使用的MonsterMap配置变量 - 将MonsterMap配置变量注释掉,因为当前不再使用该配置 - 相应地注释掉了初始化代码中的MonsterMap赋值逻辑 feat(logic/controller): 统一CanFight方法返回值为ErrorCode - 修改PlayerFightBoss等战斗控制器中的Can
41 lines
1.1 KiB
Go
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 {
|
|
r := p.CanFight()
|
|
if p.CanFight() != 0 {
|
|
return r
|
|
}
|
|
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() == 0 {
|
|
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))
|
|
}
|