From 307023c85aa858b408b3a605d251dce28f686dce Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Wed, 3 Apr 2024 21:11:30 +0900 Subject: [PATCH] Fix duplicate activated collection ids --- .Lib9c.Tests/Model/State/CollectionStateTest.cs | 4 +++- Lib9c/Model/State/CollectionState.cs | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.Lib9c.Tests/Model/State/CollectionStateTest.cs b/.Lib9c.Tests/Model/State/CollectionStateTest.cs index b02dc0cf4b..bdd8d6d862 100644 --- a/.Lib9c.Tests/Model/State/CollectionStateTest.cs +++ b/.Lib9c.Tests/Model/State/CollectionStateTest.cs @@ -18,6 +18,8 @@ public void Bencoded() { 1, 2, + 1, + 2, }, }; @@ -27,7 +29,7 @@ public void Bencoded() Assert.Equal(expected, serialized); var deserialized = new CollectionState(serialized); - Assert.Equal(state.Ids, deserialized.Ids); + Assert.Equal(new List { 1, 2, }, deserialized.Ids); } } } diff --git a/Lib9c/Model/State/CollectionState.cs b/Lib9c/Model/State/CollectionState.cs index d77581e5da..6966218390 100644 --- a/Lib9c/Model/State/CollectionState.cs +++ b/Lib9c/Model/State/CollectionState.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using Bencodex; using Bencodex.Types; using Nekoyume.Model.Stat; @@ -24,13 +25,15 @@ public CollectionState(List serialized) { Ids.Add((Integer)value); } + + Ids = Ids.Distinct().ToList(); } public CollectionState(IValue bencoded) : this((List)bencoded) { } - public IValue Bencoded => List.Empty.Add(new List(Ids)); + public IValue Bencoded => List.Empty.Add(new List(Ids.Distinct())); public List GetModifiers(CollectionSheet collectionSheet) {