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) } }