Skip to content

Commit

Permalink
replace NonFungibleId property of Item
Browse files Browse the repository at this point in the history
  • Loading branch information
boscohyun committed May 16, 2024
1 parent df9e6b2 commit 4d668bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
3 changes: 0 additions & 3 deletions Mimir/Models/Items/Equipment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ namespace Mimir.Models.Items;

public class Equipment : Item
{
public Guid NonFungibleId { get; set; }
public int Level { get; set; }

public Equipment(Nekoyume.Model.Item.Equipment equipment) :
base(equipment, count: 1)
{
NonFungibleId = equipment.NonFungibleId;
Level = equipment.level;
}

public Equipment(BsonDocument equipment) : base(equipment)
{
NonFungibleId = Guid.Parse(equipment["NonFungibleId"].AsString);
Level = equipment["level"].AsInt32;
}
}
18 changes: 13 additions & 5 deletions Mimir/Models/Items/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ public class Item
public ItemSubType ItemSubType { get; set; }
public ElementalType ElementalType { get; set; }

public int? Count { get; set; }
public int Count { get; set; }

public Guid? NonFungibleId { get; set; }
public long? RequiredBlockIndex { get; set; }

public Item(ItemBase item, int? count)
public Item(ItemBase item, int count)
{
ItemSheetId = item.Id;
Grade = item.Grade;
Expand All @@ -24,10 +26,14 @@ public Item(ItemBase item, int? count)
ElementalType = item.ElementalType;

Count = count;

NonFungibleId = item is INonFungibleItem nonFungibleItem
? nonFungibleItem.NonFungibleId
: null;
RequiredBlockIndex = item switch
{
INonFungibleItem nonFungibleItem => nonFungibleItem.RequiredBlockIndex,
ITradableItem tradableItem => tradableItem.RequiredBlockIndex,
INonFungibleItem nfi => nfi.RequiredBlockIndex,
ITradableItem ti => ti.RequiredBlockIndex,
_ => null
};
}
Expand All @@ -40,7 +46,9 @@ public Item(BsonDocument item)
ItemSubType = (ItemSubType)item["ItemSubType"].AsInt32;
ElementalType = (ElementalType)item["ElementalType"].AsInt32;

Count = item["Count"].AsNullableInt32;
Count = item["Count"].AsInt32;

NonFungibleId = item["NonFungibleId"].AsNullableGuid;
RequiredBlockIndex = item["RequiredBlockIndex"].AsNullableInt64;
}
}

0 comments on commit 4d668bf

Please sign in to comment.