feat(fight): 实现精灵大乱斗模式并优化对战逻辑

新增大乱斗模式(PET_MELEE)支持,重构原有精灵王之战相关逻辑。
更新战斗初始化流程,添加随机精灵选择机制。
调整玩家匹配与取消邀请接口实现方式。
完善战斗结束处理函数,移除未实现异常抛出。
```
This commit is contained in:
2025-11-15 01:53:51 +08:00
parent d73eb9eb26
commit 0e1860bdf4
7 changed files with 123 additions and 67 deletions

View File

@@ -3,14 +3,24 @@ package controller
import (
"blazing/common/socket/errorcode"
"blazing/logic/service/fight"
"blazing/logic/service/fight/info"
"blazing/logic/service/player"
)
//精灵王之战
//大乱斗
func (h Controller) PvpKingFight(data *fight.StartPetWarInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
func (h Controller) PET_MELEE(data *fight.StartPetWarInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if !c.CanFight() {
return nil, errorcode.ErrorCodes.ErrPokemonNotEligible
}
c.PVPinfo = &info.PVPinfo{
Mode: info.BattleMode.PET_MELEE,
Status: info.BattleStatus.FIGHT_WITH_PLAYER}
g := c.PET_MELEE()
if g != nil {
fight.NewFight(info.BattleMode.PET_MELEE, info.BattleStatus.FIGHT_WITH_PLAYER, c.PET_MELEE(), c) ///开始对战,房主方以及被邀请方
}
return
}

View File

@@ -35,7 +35,7 @@ func (h Controller) OnPlayerInviteOtherFight(data *fight.InviteToFightInboundInf
// 取消和他人战斗
func (h Controller) OnPlayerCanceledOtherInviteFight(data *fight.InviteFightCancelInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
c.CancelBattle()
c.PVPinfo = nil
return nil, 0
}