From 85d0dbf52728fc3289c3d7c0a3e890e879ab88fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Wed, 3 Sep 2025 01:54:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor(logic):=20=E9=87=8D=E6=9E=84=E7=8E=A9?= =?UTF-8?q?=E5=AE=B6=E6=88=98=E6=96=97=E7=8A=B6=E6=80=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除玩家对象上的 IsFighting 标志 - 使用 FightID 字段来表示玩家是否处于战斗状态 - 更新相关控制器中的战斗状态检查逻辑 - 删除 BattleInputSourceEntity 中的冗余代码 --- logic/controller/fight.go | 3 +-- logic/controller/map.go | 4 ++-- logic/service/fight/info/BattleInputSourceEntity.go | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/logic/controller/fight.go b/logic/controller/fight.go index c83c7f33..8d470953 100644 --- a/logic/controller/fight.go +++ b/logic/controller/fight.go @@ -15,7 +15,6 @@ import ( ) func (h Controller) OnPlayerFightNpcMonster(data *info.FightNpcMonsterInboundInfo, c *socket.Player) (result *info.NullOutboundInfo, err errorcode.ErrorCode) { - // c.IsFighting = true ttt := info.NoteReadyToFightInfo{ OwnerID: data.Head.UserID, @@ -79,7 +78,7 @@ func (h Controller) Escape(data *info.EscapeFightInboundInfo, c *socket.Player) c.SendPack(ttt.Pack(&info.FightOverInfo{ Reason: 0, })) - c.IsFighting = false + c.FightID = "" }() return nil, 0 diff --git a/logic/controller/map.go b/logic/controller/map.go index 8e263eac..dc88626a 100644 --- a/logic/controller/map.go +++ b/logic/controller/map.go @@ -33,7 +33,7 @@ func (h *Controller) MapEnter(data *maps.InInfo, c *socket.Player) (result *maps <-time.After(5 * time.Second) // 首次刷新 - if !c.IsFighting && c.Info.MapID != 0 { + if c.FightID == "" && c.Info.MapID != 0 { data.SpawnMonsters(c, true) } //循环刷新怪物 @@ -48,7 +48,7 @@ func (h *Controller) MapEnter(data *maps.InInfo, c *socket.Player) (result *maps return case <-ticker.C: // 刷新当前地图的怪物 - if !c.IsFighting && c.Info.MapID != 0 { + if c.FightID == "" && c.Info.MapID != 0 { data.SpawnMonsters(c, false) } diff --git a/logic/service/fight/info/BattleInputSourceEntity.go b/logic/service/fight/info/BattleInputSourceEntity.go index 291e52c3..abc93ba3 100644 --- a/logic/service/fight/info/BattleInputSourceEntity.go +++ b/logic/service/fight/info/BattleInputSourceEntity.go @@ -18,7 +18,7 @@ func (u *BattleInputSourceEntity) NewBattlePetEntity(ctx context.Context) { ret := BattlePetEntity{} - ret.UnitAttributes = make(map[EnumAttrType]*Attribute) + //ret.UnitAttributes = make(map[EnumAttrType]*Attribute) //todo 待实现精灵特性+加成的封装 ctx = context.WithValue(ctx, Input_ctx, &ret) //添加用户到上下文 ret.ctx = ctx