```
fix(fight): 修复战斗逻辑中的一些潜在问题 - 在 `fight_leitai.go` 中增加玩家是否可以战斗的判断,避免非法挑战 - 注释掉部分冗余的日志打印与广播调用,并调整了擂台状态更新逻辑 - 修正 `effect_62.go` 中镇魂歌效果持续时间的处理方式,引入独立计数器 `duy` - 优化随机精灵生成逻辑,确保 CatchTime 正确设置 - 增加对数据库操作错误的 panic 处理,提高代码健壮性 - 调整部分结构体指针传递,统一返回结构体指针以避免拷贝问题 - 移除未使用的导入包和调试日志,清理无用代码 ```
This commit is contained in:
@@ -39,6 +39,9 @@ func (h Controller) ARENA_SET_OWENR(data *fight.ARENA_SET_OWENR, c *player.Playe
|
||||
// 并不会通知对方是否接受挑战。只要有人挑战就直接进入对战
|
||||
func (h Controller) ARENA_FIGHT_OWENR(data *fight.ARENA_FIGHT_OWENR, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
|
||||
if !c.CanFight() {
|
||||
return nil, errorcode.ErrorCodes.ErrNoEligiblePokemon
|
||||
}
|
||||
//原子操作,修改擂台状态
|
||||
if atomic.CompareAndSwapUint32(&c.GetSpace().Owner.Flag, 1, 2) {
|
||||
//成功发起擂台挑战后才修改我放状态
|
||||
@@ -51,14 +54,19 @@ func (h Controller) ARENA_FIGHT_OWENR(data *fight.ARENA_FIGHT_OWENR, c *player.P
|
||||
|
||||
if err <= 0 { //发起战斗成功
|
||||
atomic.StoreUint32(&c.GetSpace().Owner.ChallengerID, c.GetInfo().UserID) //传回的指针赋值给ID
|
||||
c.GetSpace().Broadcast(c, 2419, &c.GetSpace().Owner)
|
||||
c.SendPackCmd(2419, &c.GetSpace().Owner)
|
||||
//c.GetSpace().Broadcast(c, 2419, &c.GetSpace().Owner)
|
||||
//c.SendPackCmd(2419, &c.GetSpace().Owner)
|
||||
} else {
|
||||
//发起失败,改回1
|
||||
c.GetSpace().Owner.HostWins = 0 //连胜重置
|
||||
c.GetSpace().Owner.UserID = c.GetInfo().UserID //添加用户ID
|
||||
c.GetSpace().Owner.Nick = c.GetInfo().Nick
|
||||
c.GetSpace().ARENA_Player = c //添加用户
|
||||
atomic.StoreUint32(&c.GetSpace().Owner.Flag, 1)
|
||||
|
||||
}
|
||||
|
||||
c.GetSpace().Broadcast(c, 2419, &c.GetSpace().Owner)
|
||||
c.SendPackCmd(2419, &c.GetSpace().Owner)
|
||||
return
|
||||
}
|
||||
return nil, errorcode.ErrorCodes.ErrChampionExists
|
||||
|
||||
@@ -118,14 +118,14 @@ func (h *Controller) PetRelease(
|
||||
// 精灵展示
|
||||
func (h *Controller) PlayerShowPet(
|
||||
data *pet.PetShowInboundInfo, c *player.Player) (result *pet.PetShowOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
results := pet.PetShowOutboundInfo{}
|
||||
result = &pet.PetShowOutboundInfo{}
|
||||
|
||||
for _, pi := range c.Info.PetList {
|
||||
if pi.CatchTime == data.CatchTime {
|
||||
copier.Copy(&results, pi)
|
||||
results.Flag = data.Flag
|
||||
results.UserID = data.Head.UserID
|
||||
c.GetSpace().Broadcast(c, data.Head.CMD, results)
|
||||
copier.Copy(&result, pi)
|
||||
result.Flag = data.Flag
|
||||
result.UserID = data.Head.UserID
|
||||
c.GetSpace().Broadcast(c, data.Head.CMD, result)
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user