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) {