Exemple #1
0
        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));
        }
Exemple #2
0
 public ShopItem(Address sellerAvatarAddress, Guid productId, ItemUsable itemUsable, BigInteger price)
 {
     SellerAvatarAddress = sellerAvatarAddress;
     ProductId           = productId;
     ItemUsable          = itemUsable;
     Price = price;
 }
Exemple #3
0
        private Item AddNonFungibleItem(ItemUsable itemBase)
        {
            var nonFungibleItem = new Item(itemBase);

            _items.Add(nonFungibleItem);
            return(nonFungibleItem);
        }
Exemple #4
0
 public ShopItem(Dictionary serialized)
 {
     SellerAvatarAddress = serialized["sellerAvatarAddress"].ToAddress();
     ProductId           = serialized["productId"].ToGuid();
     ItemUsable          = (ItemUsable)ItemFactory.Deserialize(
         (Dictionary)serialized["itemUsable"]
         );
     Price = serialized["price"].ToBigInteger();
 }
Exemple #5
0
 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();
 }
Exemple #6
0
 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;
 }
Exemple #7
0
 public ShopItem(Address sellerAgentAddress,
                 Address sellerAvatarAddress,
                 Guid productId,
                 FungibleAssetValue price,
                 Costume costume)
 {
     SellerAgentAddress  = sellerAgentAddress;
     SellerAvatarAddress = sellerAvatarAddress;
     ProductId           = productId;
     Price      = price;
     ItemUsable = null;
     Costume    = costume;
 }
Exemple #8
0
 public ShopItem(
     Address sellerAgentAddress,
     Address sellerAvatarAddress,
     Guid productId,
     ItemUsable itemUsable,
     FungibleAssetValue price)
 {
     SellerAgentAddress  = sellerAgentAddress;
     SellerAvatarAddress = sellerAvatarAddress;
     ProductId           = productId;
     ItemUsable          = itemUsable;
     Price = price;
 }
Exemple #9
0
        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);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
 protected bool Equals(ItemUsable other)
 {
     return(base.Equals(other) && Equals(ItemId, other.ItemId));
 }
Exemple #12
0
 public bool TryGetNonFungibleItem(ItemUsable itemUsable, out Item outNonFungibleItem)
 {
     return(TryGetNonFungibleItem(itemUsable.ItemId, out outNonFungibleItem));
 }
Exemple #13
0
 public Item(ItemUsable itemUsable, int count = 1)
 {
     item       = itemUsable;
     this.count = count;
 }
Exemple #14
0
 public bool RemoveNonFungibleItem(ItemUsable itemUsable)
 {
     return(TryGetNonFungibleItem(itemUsable, out Item item) && _items.Remove(item));
 }