diff --git a/src/OpenTheBox/Program.cs b/src/OpenTheBox/Program.cs index f325ea3..15ab677 100644 --- a/src/OpenTheBox/Program.cs +++ b/src/OpenTheBox/Program.cs @@ -212,13 +212,19 @@ public static class Program return; } - var boxNames = boxes.Select(b => GetLocalizedName(b.DefinitionId)).ToList(); + // Group boxes by type so the list isn't bloated with duplicates + var grouped = boxes.GroupBy(b => b.DefinitionId).ToList(); + var boxNames = grouped.Select(g => + { + var name = GetLocalizedName(g.Key); + return g.Count() > 1 ? $"{name} (x{g.Count()})" : name; + }).ToList(); boxNames.Add(_loc.Get("menu.back")); int choice = _renderer.ShowSelection(_loc.Get("prompt.choose_box"), boxNames); - if (choice >= boxes.Count) return; + if (choice >= grouped.Count) return; - var boxInstance = boxes[choice]; + var boxInstance = grouped[choice].First(); var openAction = new OpenBoxAction(boxInstance.Id) { @@ -322,8 +328,9 @@ public static class Program { var def = _registry.GetItem(g.Key); var bDef = def is null ? _registry.GetBox(g.Key) : null; + var baseName = GetLocalizedName(g.Key); return ( - name: GetLocalizedName(g.Key), + name: g.Count() > 1 ? $"{baseName} (x{g.Count()})" : baseName, rarity: (def?.Rarity ?? bDef?.Rarity ?? ItemRarity.Common).ToString(), category: (def?.Category ?? ItemCategory.Box).ToString() );