From 0aba7e7ccb52becef501bf86bb9b4fff7236746b Mon Sep 17 00:00:00 2001 From: xinian Date: Tue, 24 Mar 2026 01:38:02 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=AE=80=E5=8C=96=E6=88=98?= =?UTF-8?q?=E6=96=97=E5=AE=A0=E7=89=A9=E5=88=97=E8=A1=A8=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/fight_pvp_king.go | 9 ++------- logic/controller/fight_pvp_withplayer.go | 9 ++------- logic/controller/fight_擂台.go | 2 +- logic/service/fight/input.go | 8 ++++++-- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/logic/controller/fight_pvp_king.go b/logic/controller/fight_pvp_king.go index aac0df93..10b40369 100644 --- a/logic/controller/fight_pvp_king.go +++ b/logic/controller/fight_pvp_king.go @@ -93,13 +93,8 @@ func (h Controller) PetKing(data *fight.PetKingJoinInboundInfo, c *player.Player } err = c.JoinFight(func(p common.PlayerI) bool { - var u1, u2 []model.PetInfo - if c.Fightinfo.Mode == info.BattleMode.SINGLE_MODE { - u1, u2 = p.GetInfo().PetList[:1], c.GetInfo().PetList[:1] - } else { - u1, u2 = p.GetInfo().PetList, c.GetInfo().PetList - } - _, err = fight.NewFight(p, c, u1, u2, func(foi model.FightOverInfo) { + + _, err = fight.NewFight(p, c, p.GetInfo().PetList, c.GetInfo().PetList, func(foi model.FightOverInfo) { if foi.Reason == 0 { //我放获胜 switch data.Type { case 11: diff --git a/logic/controller/fight_pvp_withplayer.go b/logic/controller/fight_pvp_withplayer.go index f6c6b6a7..4baac430 100644 --- a/logic/controller/fight_pvp_withplayer.go +++ b/logic/controller/fight_pvp_withplayer.go @@ -54,13 +54,8 @@ func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInbou atomic.StoreUint32(&c.Fightinfo.Mode, 0) return } - var u1, u2 []model.PetInfo - if data.Mode == info.BattleMode.SINGLE_MODE { - u1, u2 = v.GetInfo().PetList[:1], c.GetInfo().PetList[:1] - } else { - u1, u2 = v.GetInfo().PetList, c.GetInfo().PetList - } - _, err = fight.NewFight(v, c, u1, u2, func(foi model.FightOverInfo) { + + _, err = fight.NewFight(v, c, v.GetInfo().PetList, c.GetInfo().PetList, func(foi model.FightOverInfo) { //println("好友对战测试", foi.Reason) diff --git a/logic/controller/fight_擂台.go b/logic/controller/fight_擂台.go index a441739e..1beab4bd 100644 --- a/logic/controller/fight_擂台.go +++ b/logic/controller/fight_擂台.go @@ -67,7 +67,7 @@ func (h Controller) ArenaFightOwner(data1 *fight.ARENA_FIGHT_OWENR, c *player.Pl c.Fightinfo.Mode = info.BattleMode.SINGLE_MODE c.Fightinfo.Status = info.BattleMode.FIGHT_ARENA - _, err = fight.NewFight(c, c.GetSpace().Owner.ARENA_Player, c.Info.PetList[:1], c.GetSpace().Owner.ARENA_Player.GetInfo().PetList[:1], func(foi model.FightOverInfo) { //我方邀请擂主挑战,我方先手 + _, err = fight.NewFight(c, c.GetSpace().Owner.ARENA_Player, c.Info.PetList, c.GetSpace().Owner.ARENA_Player.GetInfo().PetList, func(foi model.FightOverInfo) { //我方邀请擂主挑战,我方先手 if foi.Reason != 0 && foi.WinnerId == c.GetInfo().UserID { //异常退出 diff --git a/logic/service/fight/input.go b/logic/service/fight/input.go index 1f0e6507..6673342d 100644 --- a/logic/service/fight/input.go +++ b/logic/service/fight/input.go @@ -123,8 +123,6 @@ func (f *FightC) LoadPercent(c common.PlayerI, percent int32) { } -var meetpet = make(map[int]model.PetInfo) - func (f *FightC) initplayer(c common.PlayerI, b []model.PetInfo) (*input.Input, errorcode.ErrorCode) { r := c.CanFight() if c.CanFight() != 0 { @@ -146,6 +144,12 @@ func (f *FightC) initplayer(c common.PlayerI, b []model.PetInfo) (*input.Input, if len(in.AllPet) == 0 { return nil, errorcode.ErrorCodes.ErrNoEligiblePokemon } + switch f.Info.Mode { + case info.BattleMode.SINGLE_MODE: + in.AllPet = in.AllPet[:1] + + default: + } in.CurrentPet = in.AllPet[0] return in, 0