From 6900c66cb02b239de0e8e412dc243014c850b98a Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 19 Sep 2025 06:58:42 +0000 Subject: [PATCH] =?UTF-8?q?feat(fight):=20=E4=BC=98=E5=8C=96=E7=B2=BE?= =?UTF-8?q?=E7=81=B5=E5=88=87=E6=8D=A2=E9=80=BB=E8=BE=91=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=88=87=E6=8D=A2=E5=8A=A8=E4=BD=9C=E9=98=9F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/fight/fightc.go | 23 +++++++++++++++++------ logic/service/fight/playeraction.go | 1 + 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index 16e7818d5..6c2b5547f 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -18,9 +18,11 @@ import ( type FightC struct { Info info.NoteReadyToFightInfo - ownerID uint32 // 战斗发起者ID - Our *input.Input //始终等于房主ID - Opp *input.Input //对手ID + ownerID uint32 // 战斗发起者ID + Our *input.Input //始终等于房主ID + Opp *input.Input //对手ID + Switch []*ActiveSwitchAction + rand *rand.Rand StartTime time.Time actionChan chan BattleActionI // 所有操作统一从这里进入 @@ -237,10 +239,12 @@ func (f *FightC) battleLoop() { } if a, isExpelled := action.(*ActiveSwitchAction); isExpelled { - //fmt.Println("对方死亡切换") - f.Broadcast(func(ff *input.Input) { - ff.Player.SendChangePet(a.Reason) + f.Broadcast(func(ff *input.Input) { + if ff.Player.ID() == a.PlayerID { //先给自身广播 + ff.Player.SendChangePet(a.Reason) + } + }) if f.GetInputByAction(action, false).CanChange { @@ -557,8 +561,15 @@ func (f *FightC) enterturn(fattack, sattack BattleActionI) { } f.Broadcast(func(ff *input.Input) { + for _, v := range f.Switch { + if ff.Player.ID() != v.PlayerID{ + ff.Player.SendChangePet(v.Reason) + } + + } ff.Player.SendAttackValue(ret) }) + f.Switch = []*ActiveSwitchAction{} } diff --git a/logic/service/fight/playeraction.go b/logic/service/fight/playeraction.go index af01da924..a55c38457 100644 --- a/logic/service/fight/playeraction.go +++ b/logic/service/fight/playeraction.go @@ -43,6 +43,7 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) { ret := &ActiveSwitchAction{ BaseAction: NewBaseAction(c.GetInfo().UserID), } + f.Switch = append(f.Switch, ret) f.GetInputByPlayer(c, false).CurrentPet, ret.Reason = f.GetInputByPlayer(c, false).GetPet(id)