From b46a1f442b3cbc619c0fea784b1486bde20d1031 Mon Sep 17 00:00:00 2001 From: xinian Date: Wed, 22 Apr 2026 14:12:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=88=98=E6=96=97?= =?UTF-8?q?=E5=B9=BF=E6=92=AD=E6=8A=80=E8=83=BDPP=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/fight/fightc.go | 7 ------- logic/service/fight/input/fight.go | 8 ++++++++ logic/service/fight/input/input.go | 4 +++- logic/service/fight/unified_test.go | 6 +++--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index ab98a679..e0368b2e 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -226,13 +226,6 @@ func (f *FightC) buildAttackValueForBroadcast(fighter *input.Input, fallbackActo if attackValue.UserID == 0 && fighter.Player != nil && fighter.Player.GetInfo() != nil { attackValue.UserID = fighter.Player.GetInfo().UserID } - if currentPet := fighter.CurrentPet(); currentPet != nil { - // 始终以当前战斗态回填血量和技能 PP,避免广播沿用旧缓存。 - attackValue.RemainHp = int32(currentPet.Info.Hp) - attackValue.MaxHp = currentPet.Info.MaxHp - attackValue.SkillList = append(attackValue.SkillList[:0], currentPet.Info.SkillList...) - attackValue.SkillListLen = uint32(len(attackValue.SkillList)) - } return attackValue } diff --git a/logic/service/fight/input/fight.go b/logic/service/fight/input/fight.go index ac93c203..8ad94485 100644 --- a/logic/service/fight/input/fight.go +++ b/logic/service/fight/input/fight.go @@ -107,6 +107,10 @@ func (our *Input) HealPP(value int) { } currentPet.Info.HealPP(value) + if our.AttackValue != nil { + our.AttackValue.SkillList = append(our.AttackValue.SkillList[:0], currentPet.Info.SkillList...) + our.AttackValue.SkillListLen = uint32(len(our.AttackValue.SkillList)) + } } func (our *Input) DelPP(value int) { @@ -123,6 +127,10 @@ func (our *Input) DelPP(value int) { } } + if our.AttackValue != nil { + our.AttackValue.SkillList = append(our.AttackValue.SkillList[:0], currentPet.Info.SkillList...) + our.AttackValue.SkillListLen = uint32(len(our.AttackValue.SkillList)) + } } diff --git a/logic/service/fight/input/input.go b/logic/service/fight/input/input.go index 1dc23b26..834a2f77 100644 --- a/logic/service/fight/input/input.go +++ b/logic/service/fight/input/input.go @@ -284,7 +284,9 @@ func (our *Input) GenInfo() { } our.RemainHp = int32(currentPet.Info.Hp) - our.SkillList = currentPet.Info.SkillList + our.MaxHp = currentPet.Info.MaxHp + our.SkillList = append(our.SkillList[:0], currentPet.Info.SkillList...) + our.SkillListLen = uint32(len(our.SkillList)) // f.Second.SkillList = f.Second.CurPet.Info.SkillList // f.Second.RemainHp = int32(f.Second.CurPet.Info.Hp) diff --git a/logic/service/fight/unified_test.go b/logic/service/fight/unified_test.go index 9e9c312b..ec1d1cc8 100644 --- a/logic/service/fight/unified_test.go +++ b/logic/service/fight/unified_test.go @@ -146,7 +146,7 @@ func TestBuildNoteUseSkillOutboundInfoUsesActionOrder(t *testing.T) { } } -func TestBuildNoteUseSkillOutboundInfoUsesCurrentPetSkillPP(t *testing.T) { +func TestBuildNoteUseSkillOutboundInfoUsesAttackValueSkillPP(t *testing.T) { player := &stubPlayer{info: model.PlayerInfo{UserID: 1001}} fighter := input.NewInput(nil, player) @@ -175,7 +175,7 @@ func TestBuildNoteUseSkillOutboundInfoUsesCurrentPetSkillPP(t *testing.T) { if len(result.FirstAttackInfo.SkillList) != 1 { t.Fatalf("expected one skill in broadcast snapshot, got %+v", result.FirstAttackInfo.SkillList) } - if result.FirstAttackInfo.SkillList[0].PP != 0 { - t.Fatalf("expected broadcast PP to come from current pet state, got %+v", result.FirstAttackInfo.SkillList) + if result.FirstAttackInfo.SkillList[0].PP != 1 { + t.Fatalf("expected broadcast PP to come from attack value cache, got %+v", result.FirstAttackInfo.SkillList) } }