public bool TryGetAddedItemFrom(Inventory inventory, out ItemUsable outAddedItem) { //FIXME TryGetNonFungibleItem 내부에서 사용되는 아이템 비교방식때문에 오동작처리됨. //https://app.asana.com/0/958521740385861/1131813492738090/ var newItem = _items.FirstOrDefault(i => !inventory.Items.Contains(i)); outAddedItem = null; if (newItem is null) { return(false); } try { outAddedItem = (ItemUsable)newItem.item; } catch (InvalidCastException) { var item = newItem.item; Log.Error("Item {0}: {1} is not ItemUsable.", item.ItemType, item.Id); } return(!(outAddedItem is null)); }
public ShopItem(Address sellerAvatarAddress, Guid productId, ItemUsable itemUsable, BigInteger price) { SellerAvatarAddress = sellerAvatarAddress; ProductId = productId; ItemUsable = itemUsable; Price = price; }
private Item AddNonFungibleItem(ItemUsable itemBase) { var nonFungibleItem = new Item(itemBase); _items.Add(nonFungibleItem); return(nonFungibleItem); }
public ShopItem(Dictionary serialized) { SellerAvatarAddress = serialized["sellerAvatarAddress"].ToAddress(); ProductId = serialized["productId"].ToGuid(); ItemUsable = (ItemUsable)ItemFactory.Deserialize( (Dictionary)serialized["itemUsable"] ); Price = serialized["price"].ToBigInteger(); }
public ShopItem(Dictionary serialized) { SellerAgentAddress = serialized["sellerAgentAddress"].ToAddress(); SellerAvatarAddress = serialized["sellerAvatarAddress"].ToAddress(); ProductId = serialized["productId"].ToGuid(); ItemUsable = (ItemUsable)ItemFactory.Deserialize( (Dictionary)serialized["itemUsable"] ); Price = serialized["price"].ToFungibleAssetValue(); }
public ShopItem(Dictionary serialized) { SellerAgentAddress = serialized["sellerAgentAddress"].ToAddress(); SellerAvatarAddress = serialized["sellerAvatarAddress"].ToAddress(); ProductId = serialized["productId"].ToGuid(); Price = serialized["price"].ToFungibleAssetValue(); ItemUsable = serialized.ContainsKey("itemUsable") ? (ItemUsable)ItemFactory.Deserialize((Dictionary)serialized["itemUsable"]) : null; Costume = serialized.ContainsKey("costume") ? (Costume)ItemFactory.Deserialize((Dictionary)serialized["costume"]) : null; }
public ShopItem(Address sellerAgentAddress, Address sellerAvatarAddress, Guid productId, FungibleAssetValue price, Costume costume) { SellerAgentAddress = sellerAgentAddress; SellerAvatarAddress = sellerAvatarAddress; ProductId = productId; Price = price; ItemUsable = null; Costume = costume; }
public ShopItem( Address sellerAgentAddress, Address sellerAvatarAddress, Guid productId, ItemUsable itemUsable, FungibleAssetValue price) { SellerAgentAddress = sellerAgentAddress; SellerAvatarAddress = sellerAvatarAddress; ProductId = productId; ItemUsable = itemUsable; Price = price; }
public bool TryGetNonFungibleItemFromLast(out ItemUsable outNonFungibleItem) { foreach (var item in Enumerable.Reverse(_items)) { if (!(item.item is ItemUsable nonFungibleItem)) { continue; } outNonFungibleItem = nonFungibleItem; return(true); } outNonFungibleItem = null; return(false); }
public bool TryGetNonFungibleItem(Guid itemId, out ItemUsable outNonFungibleItem) { foreach (var item in _items) { if (!(item.item is ItemUsable nonFungibleItem)) { continue; } if (nonFungibleItem.ItemId != itemId) { continue; } outNonFungibleItem = nonFungibleItem; return(true); } outNonFungibleItem = null; return(false); }
protected bool Equals(ItemUsable other) { return(base.Equals(other) && Equals(ItemId, other.ItemId)); }
public bool TryGetNonFungibleItem(ItemUsable itemUsable, out Item outNonFungibleItem) { return(TryGetNonFungibleItem(itemUsable.ItemId, out outNonFungibleItem)); }
public Item(ItemUsable itemUsable, int count = 1) { item = itemUsable; this.count = count; }
public bool RemoveNonFungibleItem(ItemUsable itemUsable) { return(TryGetNonFungibleItem(itemUsable, out Item item) && _items.Remove(item)); }