fix(deckbuilder): лишние копии считаются по конкретному принту
CI / test (push) Successful in 2m55s
Details
CI / test (push) Successful in 2m55s
Details
- PlanExtras больше не суммирует разные принты одного названия: излишек считается как Count - 4 для каждого printingId отдельно. - Раньше при нескольких принтах одной карты предлагалось распылить почти всю коллекцию. - Тест на два принта; EditMode 71/71, standalone собран.
This commit is contained in:
parent
42e57f5ac1
commit
37fb875d42
|
|
@ -206,9 +206,8 @@ namespace Vanguard.UI
|
||||||
&& !string.Equals(trigger, "None", StringComparison.Ordinal);
|
&& !string.Equals(trigger, "None", StringComparison.Ordinal);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// План распыления лишних копий: всё сверх 4 на название. SP/TD не
|
/// План распыления лишних копий: всё сверх 4 на конкретный принт
|
||||||
/// распыляются, поэтому пропускаются. Сначала берутся карты с меньшей
|
/// (номер карты). SP/TD не распыляются, поэтому пропускаются.
|
||||||
/// ценой распыления, чтобы сохранить ценные.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static DismantlePlan PlanExtras(IEnumerable<CollectionItemDto> collection)
|
public static DismantlePlan PlanExtras(IEnumerable<CollectionItemDto> collection)
|
||||||
{
|
{
|
||||||
|
|
@ -216,24 +215,14 @@ namespace Vanguard.UI
|
||||||
if (collection == null)
|
if (collection == null)
|
||||||
return plan;
|
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 = item.Count - 4;
|
||||||
var extra = total - 4;
|
var dust = DustFor(item.Rarity);
|
||||||
if (extra <= 0)
|
if (extra <= 0 || dust <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
foreach (var item in group
|
plan.Add(item.PrintingId, extra, extra * dust);
|
||||||
.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return plan;
|
return plan;
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,23 @@ namespace Vanguard.Tests
|
||||||
Assert.AreEqual("a", plan.Items[0].PrintingId);
|
Assert.AreEqual("a", plan.Items[0].PrintingId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void PlanExtras_Counts_Extra_Copies_Per_Printing()
|
||||||
|
{
|
||||||
|
var collection = new List<CollectionItemDto>
|
||||||
|
{
|
||||||
|
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]
|
[Test]
|
||||||
public void Validate_Requires_Count_Triggers_And_Copy_Limit()
|
public void Validate_Requires_Count_Triggers_And_Copy_Limit()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue