Skip to content

Commit

Permalink
Fix duplicate activated collection ids
Browse files Browse the repository at this point in the history
  • Loading branch information
ipdae committed Apr 3, 2024
1 parent 8dda29c commit 307023c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .Lib9c.Tests/Model/State/CollectionStateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public void Bencoded()
{
1,
2,
1,
2,
},
};

Expand All @@ -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<int> { 1, 2, }, deserialized.Ids);
}
}
}
5 changes: 4 additions & 1 deletion Lib9c/Model/State/CollectionState.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Bencodex;
using Bencodex.Types;
using Nekoyume.Model.Stat;
Expand All @@ -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<StatModifier> GetModifiers(CollectionSheet collectionSheet)
{
Expand Down

0 comments on commit 307023c

Please sign in to comment.