From 37fb875d42e56edacc4d250b54087f2eaa02755a Mon Sep 17 00:00:00 2001 From: MpakobecEx Date: Sun, 1 Nov 2026 22:50:22 +0500 Subject: [PATCH] =?UTF-8?q?fix(deckbuilder):=20=D0=BB=D0=B8=D1=88=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BF=D0=B8=D0=B8=20=D1=81=D1=87?= =?UTF-8?q?=D0=B8=D1=82=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20=D0=BF=D0=BE=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D0=BA=D1=80=D0=B5=D1=82=D0=BD=D0=BE=D0=BC?= =?UTF-8?q?=D1=83=20=D0=BF=D1=80=D0=B8=D0=BD=D1=82=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PlanExtras больше не суммирует разные принты одного названия: излишек считается как Count - 4 для каждого printingId отдельно. - Раньше при нескольких принтах одной карты предлагалось распылить почти всю коллекцию. - Тест на два принта; EditMode 71/71, standalone собран. --- .../Vanguard/Runtime/UI/DeckListFilter.cs | 25 ++++++------------- .../Vanguard/Tests/Editor/DeckBuilderTests.cs | 17 +++++++++++++ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/client/Assets/Vanguard/Runtime/UI/DeckListFilter.cs b/client/Assets/Vanguard/Runtime/UI/DeckListFilter.cs index 7f47d96..db33176 100644 --- a/client/Assets/Vanguard/Runtime/UI/DeckListFilter.cs +++ b/client/Assets/Vanguard/Runtime/UI/DeckListFilter.cs @@ -206,9 +206,8 @@ namespace Vanguard.UI && !string.Equals(trigger, "None", StringComparison.Ordinal); /// - /// План распыления лишних копий: всё сверх 4 на название. SP/TD не - /// распыляются, поэтому пропускаются. Сначала берутся карты с меньшей - /// ценой распыления, чтобы сохранить ценные. + /// План распыления лишних копий: всё сверх 4 на конкретный принт + /// (номер карты). SP/TD не распыляются, поэтому пропускаются. /// public static DismantlePlan PlanExtras(IEnumerable collection) { @@ -216,24 +215,14 @@ namespace Vanguard.UI if (collection == null) return plan; - foreach (var group in collection.GroupBy(item => item.NameId)) + foreach (var item in collection) { - var total = group.Sum(item => item.Count); - var extra = total - 4; - if (extra <= 0) + var extra = item.Count - 4; + var dust = DustFor(item.Rarity); + if (extra <= 0 || dust <= 0) continue; - foreach (var item in group - .Where(item => DustFor(item.Rarity) > 0 && item.Count > 0) - .OrderBy(item => DustFor(item.Rarity))) - { - if (extra <= 0) - break; - - var take = Math.Min(extra, item.Count); - plan.Add(item.PrintingId, take, take * DustFor(item.Rarity)); - extra -= take; - } + plan.Add(item.PrintingId, extra, extra * dust); } return plan; diff --git a/client/Assets/Vanguard/Tests/Editor/DeckBuilderTests.cs b/client/Assets/Vanguard/Tests/Editor/DeckBuilderTests.cs index 4a19572..4800c3d 100644 --- a/client/Assets/Vanguard/Tests/Editor/DeckBuilderTests.cs +++ b/client/Assets/Vanguard/Tests/Editor/DeckBuilderTests.cs @@ -159,6 +159,23 @@ namespace Vanguard.Tests Assert.AreEqual("a", plan.Items[0].PrintingId); } + [Test] + public void PlanExtras_Counts_Extra_Copies_Per_Printing() + { + var collection = new List + { + new CollectionItemDto { PrintingId = "a", NameId = "A", Rarity = "C", Count = 5 }, + new CollectionItemDto { PrintingId = "b", NameId = "A", Rarity = "R", Count = 6 }, + new CollectionItemDto { PrintingId = "c", NameId = "A", Rarity = "R", Count = 4 }, + }; + + var plan = DeckListModel.PlanExtras(collection); + + Assert.AreEqual(3, plan.CardCount); + Assert.AreEqual(25, plan.Dust); + Assert.AreEqual(2, plan.Items.Count); + } + [Test] public void Validate_Requires_Count_Triggers_And_Copy_Limit() {