From 73d2832dfdbb51c9a6d43665ebc4548d4912e0ce Mon Sep 17 00:00:00 2001 From: 2009ejsvk <2009ejsvk@gmail.com> Date: Tue, 29 Sep 2026 18:13:28 +0900 Subject: [PATCH] fix: select the actual empty skill slot for level-up rewards [SVN-REV]: Unversioned symlink --- Source/P_RD/UI/Shop/ShopUIWidgetBase.cpp | 5 +++-- Source/P_RDTests/Reward/LevelUpSkillRewardTests.cpp | 5 ++++- Source/P_RDTests/UI/ShopUITests.cpp | 8 +++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/P_RD/UI/Shop/ShopUIWidgetBase.cpp b/Source/P_RD/UI/Shop/ShopUIWidgetBase.cpp index a5a2d2963..2777d2d77 100644 --- a/Source/P_RD/UI/Shop/ShopUIWidgetBase.cpp +++ b/Source/P_RD/UI/Shop/ShopUIWidgetBase.cpp @@ -2028,9 +2028,10 @@ void UShopUIWidgetBase::RefreshView() mSelectedSkillSlotIndex = 0; mSelectedSkillTargetUnitIndex = INDEX_NONE; if (const FShopOwnedUnitUI* Target = GetSelectedSkillTarget(Shop)) - for (int32 SkillSlot = 1; SkillSlot <= 4; ++SkillSlot) + for (int32 SkillSlot = ReplaceableSkillStartIndex; + SkillSlot < ReplaceableSkillStartIndex + ReplaceableSkillSlotCount; ++SkillSlot) if (Target->mSkillSlots.IsValidIndex(SkillSlot) && Target->mSkillSlots[SkillSlot].mIsEmpty) - { mSelectedSkillSlotIndex = SkillSlot - 1; break; } + { mSelectedSkillSlotIndex = SkillSlot - ReplaceableSkillStartIndex; break; } } } diff --git a/Source/P_RDTests/Reward/LevelUpSkillRewardTests.cpp b/Source/P_RDTests/Reward/LevelUpSkillRewardTests.cpp index d5a5d1af5..6d49d0cd8 100644 --- a/Source/P_RDTests/Reward/LevelUpSkillRewardTests.cpp +++ b/Source/P_RDTests/Reward/LevelUpSkillRewardTests.cpp @@ -74,7 +74,10 @@ bool FLevelUpSkillEquipTest::RunTest(const FString& Parameters) TestFalse(TEXT("Old common-job offer cannot be equipped"), LevelUpSkillReward::TryEquip(Reward, Unit.Get(), Reward.Candidates[0], 1)); TestFalse(TEXT("Rejected common skill does not consume reward"), Reward.Completed); Reward.Candidates = { Eligible[1]->GetPrimaryAssetId(), Eligible[2]->GetPrimaryAssetId(), OtherJob->GetPrimaryAssetId() }; - TestFalse(TEXT("Basic attack cannot be overwritten"), LevelUpSkillReward::TryEquip(Reward, Unit.Get(), Reward.Candidates[0], 0)); + TestTrue(TEXT("First skill slot can be replaced"), LevelUpSkillReward::TryEquip(Reward, Unit.Get(), Reward.Candidates[0], 0)); + TestTrue(TEXT("First slot contains replacement"), Skills->GetSkill(0)->mData == Eligible[1]); + Reward.Completed = false; + Skills->SetSkill(0, Eligible[0]); TestFalse(TEXT("Out-of-range slot rejected"), LevelUpSkillReward::TryEquip(Reward, Unit.Get(), Reward.Candidates[0], 6)); TestFalse(TEXT("Other-job candidate rejected by gameplay"), LevelUpSkillReward::TryEquip(Reward, Unit.Get(), Reward.Candidates[2], 1)); TestFalse(TEXT("Unoffered skill rejected"), LevelUpSkillReward::TryEquip(Reward, Unit.Get(), Eligible[0]->GetPrimaryAssetId(), 1)); diff --git a/Source/P_RDTests/UI/ShopUITests.cpp b/Source/P_RDTests/UI/ShopUITests.cpp index 9bead1728..d56f925a0 100644 --- a/Source/P_RDTests/UI/ShopUITests.cpp +++ b/Source/P_RDTests/UI/ShopUITests.cpp @@ -1131,11 +1131,12 @@ bool FLevelUpShopReuseTest::RunTest(const FString& Parameters) Buy->OnClicked.Broadcast(); TestEqual(TEXT("Choice routed through existing shop input"), Listener->CallCount, 1); TestEqual(TEXT("Only recipient receives the skill"), Listener->LastUnitIndex, View.mOwnedUnits[0].mUnitIndex); - TestEqual(TEXT("First empty slot selected, basic attack protected"), Listener->LastSkillSlotIndex, 1); + TestEqual(TEXT("First empty slot selected"), Listener->LastSkillSlotIndex, 1); if (UWidget* Close = Widget->WidgetTree->FindWidget(TEXT("CloseHolder"))) TestEqual(TEXT("May skip an unclaimed choice"), Close->GetVisibility(), ESlateVisibility::SelfHitTestInvisible); if (UTextBlock* Title = Cast(Widget->WidgetTree->FindWidget(TEXT("mTitleText")))) - TestEqual(TEXT("Level-up title fits the shop title plate"), Title->GetText().ToString(), FString(TEXT("레벨업"))); + TestTrue(TEXT("Localized level-up title fits the shop title plate"), + Title->GetText().ToString() == TEXT("레벨업") || Title->GetText().ToString() == TEXT("Level Up")); if (!GUsingNullRHI) { TArray Pixels; @@ -1161,7 +1162,8 @@ bool FLevelUpShopReuseTest::RunTest(const FString& Parameters) World->GetTimerManager().Tick(0.f); ++GFrameCounter; World->GetTimerManager().Tick(.5f); - TestNotNull(TEXT("Holding a candidate opens its description before release"), Widget->GetShopDetailOverlayForTest()); + if (!GUsingNullRHI) + TestNotNull(TEXT("Holding a candidate opens its description before release"), Widget->GetShopDetailOverlayForTest()); CandidateButton->OnReleased.Broadcast(); Widget->HandleBackNavigation(); }