fix: 修复空提交问题

This commit is contained in:
1
2025-11-19 00:09:12 +00:00
parent 24f2a6d7c8
commit 31439b707c
12 changed files with 88 additions and 98 deletions

View File

@@ -2,6 +2,7 @@ package controller
import (
"blazing/common/socket/errorcode"
"sync/atomic"
"blazing/logic/service/fight"
"blazing/logic/service/fight/info"
@@ -26,11 +27,11 @@ func (h Controller) UseSkill(data *fight.UseSkillInInfo, c *player.Player) (resu
// 战斗逃跑
func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if c.FightC == nil {
if atomic.LoadUint32(&c.Fightinfo.Status) == 0 {
return nil, 0
return nil, errorcode.ErrorCodes.ErrBattleNotStarted //,没开始对战
}
if !c.FightC.CanEscape() { //用户对战不能逃跑
if atomic.LoadUint32(&c.Fightinfo.Status) == 1 { //用户对战不能逃跑
return nil, errorcode.ErrorCodes.ErrCannotFleePlayerBattle
}

View File

@@ -34,7 +34,7 @@ func (h Controller) ARENA_FIGHT_OWENR(data *fight.ARENA_FIGHT_OWENR, c *player.P
return nil, errorcode.ErrorCodes.ErrPokemonNotEligible
}
space.GetSpace(c.Info.MapID).Can_ARENA(func(ownerID common.PlayerI) common.PlayerI {
space.GetSpace(c.Info.MapID).ARENA_join(func(ownerID common.PlayerI) common.PlayerI {
c.Fightinfo = &info.Fightinfo{
Mode: info.BattleMode.SINGLE_MODE,
Status: info.BattleStatus.FIGHT_WITH_PLAYER,
@@ -55,7 +55,7 @@ func (h Controller) ARENA_FIGHT_OWENR(data *fight.ARENA_FIGHT_OWENR, c *player.P
// 获取星际擂台信息的包 进入空间站地图前端会发送请求包 或者 有人站到星际擂台上后 广播回包
// 前端到后端无数据内容
// 后端到前端
func (h Controller) ARENA_GET_INFO(data *fight.ARENA_GET_INFO, c *player.Player) (result *space.S2C_ARENA_GET_INFO, err errorcode.ErrorCode) {
func (h Controller) ARENA_GET_INFO(data *fight.ARENA_GET_INFO, c *player.Player) (result *space.ARENA, err errorcode.ErrorCode) {
result = &space.GetSpace(c.Info.MapID).ARENA
return

View File

@@ -11,13 +11,12 @@ import (
//大乱斗
func (h Controller) PET_MELEE(data *fight.StartPetWarInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if !c.CanFight() {
if !c.CanFight(1) {
return nil, errorcode.ErrorCodes.ErrPokemonNotEligible
}
c.Fightinfo = &info.Fightinfo{
Mode: info.BattleMode.PET_MELEE,
Status: info.BattleStatus.FIGHT_WITH_PLAYER}
c.Fightinfo.Mode = info.BattleMode.PET_MELEE
c.Fightinfo.PlayerID = 0
g := c.Pet_joinFight()
if g != nil {
fight.NewFight(g, c, func(foi *info.FightOverInfo) {

View File

@@ -12,9 +12,7 @@ import (
// 接收战斗或者取消战斗的包
func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
// if !c.CanFight() {
// return nil, errorcode.ErrorCodes.ErrPokemonNotEligible
// }
if !atomic.CompareAndSwapUint32(&c.Fightinfo.Status, 0, 1) { //邀请前提是自己没在战斗
return nil, errorcode.ErrorCodes.ErrInBattle