From 5b804d07dbc64effe8e6cd30a1fdcb6e0d6fb4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Thu, 11 Dec 2025 12:16:32 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(fight):=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E4=B8=BB=E5=8A=A8=E5=88=87=E6=8D=A2=E5=AE=A0=E7=89=A9=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=B9=B6=E4=BC=98=E5=8C=96=E7=9B=B8=E5=85=B3=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E4=BD=93=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 `ActiveSwitchAction` 中新增 `Cid` 字段用于标识要切换的宠物 ID - 调整 `ChangePet` 方法逻辑,移除旧有输入处理,改为在 loop 中统一处理 - 更新 `collectPlayerActions` 方法以正确设置当前宠物及发送指令 - 优化 `PetInfo` 结构体字段标签,去除冗余描述,并重命名部分字段提升可读性 - 增加 `ExtSkin` 字段支持记录可用皮肤信息 - 移除玩家信息中的 `LastResetTime` 注释字段 ``` --- logic/service/fight/action.go | 6 +----- logic/service/fight/action/BattleAction.go | 1 + logic/service/fight/loop.go | 2 ++ modules/blazing/model/pet.go | 14 +++++++------- modules/blazing/model/player.go | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/logic/service/fight/action.go b/logic/service/fight/action.go index 46cffe47b..d3b00bf9b 100644 --- a/logic/service/fight/action.go +++ b/logic/service/fight/action.go @@ -62,13 +62,9 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) { //todo 待实现无法切精灵的情况 ret := &action.ActiveSwitchAction{ BaseAction: action.NewBaseAction(c.GetInfo().UserID), + Cid: id, } - selfinput := f.GetInputByPlayer(c, false) - - selfinput.CurrentPet, ret.Reason = selfinput.GetPet(id) - c.SendPackCmd(2407, &ret.Reason) - f.actionChan <- ret } diff --git a/logic/service/fight/action/BattleAction.go b/logic/service/fight/action/BattleAction.go index ff2b17392..03fec62d9 100644 --- a/logic/service/fight/action/BattleAction.go +++ b/logic/service/fight/action/BattleAction.go @@ -61,6 +61,7 @@ func (a *BaseAction) GetPlayerID() uint32 { // ActiveSwitchAction 主动切换宠物的战斗动作 type ActiveSwitchAction struct { BaseAction + Cid uint32 Reason info.ChangePetInfo // CurrentPet BattlePetEntity // 当前在场宠物 diff --git a/logic/service/fight/loop.go b/logic/service/fight/loop.go index bd3a1009e..89b08bd6a 100644 --- a/logic/service/fight/loop.go +++ b/logic/service/fight/loop.go @@ -151,6 +151,8 @@ func (f *FightC) collectPlayerActions(ourID, oppID uint32) map[uint32]action.Bat } + selfinput.CurrentPet, ret.Reason = selfinput.GetPet(ret.Cid) + selfinput.Player.SendPackCmd(2407, &ret.Reason) InitAttackValue := *selfinput.AttackValue oldpet := selfinput.CurrentPet f.Switch[selfinput.UserID] = ret diff --git a/modules/blazing/model/pet.go b/modules/blazing/model/pet.go index 08590ef3b..af4788b23 100644 --- a/modules/blazing/model/pet.go +++ b/modules/blazing/model/pet.go @@ -64,16 +64,16 @@ type PetInfo struct { Level uint32 `fieldDesc:"等级" ` // 当前等级已获得经验(@UInt long → uint32) - Exp uint32 `fieldDesc:"当前等级已经获得的经验 2538" ` + Exp uint32 // 当前等级所需经验(@UInt long → uint32) - LvExp uint32 `fieldDesc:"当前等级所需的经验" ` + LvExp uint32 // 升到下一级的经验(@UInt long → uint32) - NextLvExp uint32 `fieldDesc:"升到下一级的经验" ` + NextLvExp uint32 // 当前生命(@UInt long → uint32) - Hp uint32 `fieldDesc:"当前生命" ` + Hp uint32 // 最大生命(@UInt long → uint32) MaxHp uint32 `fieldDesc:"最大生命" ` @@ -108,12 +108,12 @@ type PetInfo struct { SkinID uint32 `fieldDesc:"皮肤id默认为0" ` // 是否闪光(@UInt long → uint32,0=否,1=是) - ShinyLen uint32 `struc:"sizeof=Shiny"` - Shiny []GlowFilter + ShinyLen uint32 `json:"ShinyLen,omitempty" struc:"sizeof=ShinyInfo"` + ShinyInfo []GlowFilter `json:"ShinyInfo,omitempty"` //时间轮转,然后effect根据type同时只共存一个,特性是1 特质是1,柱子是两种,魂印是一个,然后异色字段,然后特训技能字段 ExtSKill []uint32 `struc:"skip"` //特训技能 - + ExtSkin []uint32 `struc:"skip"` //可用皮肤 } // 定义常量,提升可维护性(避免魔法数字) diff --git a/modules/blazing/model/player.go b/modules/blazing/model/player.go index 20fa4ba09..5feb86581 100644 --- a/modules/blazing/model/player.go +++ b/modules/blazing/model/player.go @@ -112,7 +112,7 @@ func (m *PlayerInfo) GetTask(i int) TaskStatus { type PlayerInfo struct { ExpPool uint32 `struc:"skip" json:"exp_pool"` // 累计经验池 - //LastResetTime time.Time `struc:"skip" json:"last_reset_time"` // 重置时间,比如电池和每日任务 + OnlineTime uint32 `struc:"skip" json:"online_time"` //在线分钟数 // OutInfo 字段 UserID uint32 `struc:"uint32" json:"user_id"` // 米米号 通过sid拿到