Esempio n. 1
0
        private void SubscribeItemPopupSubmit(Model.ItemCountAndPricePopup data)
        {
            if (!(data.Item.Value.ItemBase.Value is INonFungibleItem nonFungibleItem))
            {
                return;
            }

            if (SharedModel.State.Value == StateType.Buy)
            {
                if (!shopItems.SharedModel.TryGetShopItemFromItemSubTypeProducts(
                        nonFungibleItem.ItemId,
                        out var shopItem))
                {
                    return;
                }

                var props = new Value
                {
                    ["Price"] = shopItem.Price.Value.GetQuantityString(),
                };
                Mixpanel.Track("Unity/Buy", props);

                Game.Game.instance.ActionManager.Buy(
                    shopItem.SellerAgentAddress.Value,
                    shopItem.SellerAvatarAddress.Value,
                    shopItem.ProductId.Value);
                ResponseBuy(shopItem);
            }
            else
            {
                bool exist = shopItems.SharedModel.TryGetShopItemFromAgentProducts(nonFungibleItem.ItemId, out var shopItem);
                if (!exist || shopItem.ExpiredBlockIndex.Value != 0 &&
                    shopItem.ExpiredBlockIndex.Value < Game.Game.instance.Agent.BlockIndex)
                {
                    if (data.Price.Value.Sign * data.Price.Value.MajorUnit < Model.Shop.MinimumPrice)
                    {
                        throw new InvalidSellingPriceException(data);
                    }

                    Game.Game.instance.ActionManager.Sell(
                        (INonFungibleItem)data.Item.Value.ItemBase.Value,
                        data.Price.Value);
                    ResponseSell();

                    return;
                }

                Game.Game.instance.ActionManager.SellCancellation(
                    shopItem.SellerAvatarAddress.Value,
                    shopItem.ProductId.Value);
                ResponseSellCancellation(shopItem);
            }
        }
Esempio n. 2
0
 private void SubscribeItemPopupCancel(Model.ItemCountAndPricePopup data)
 {
     SharedModel.ItemCountAndPricePopup.Value.Item.Value = null;
     Find <ItemCountAndPricePopup>().Close();
 }
Esempio n. 3
0
 public InvalidSellingPriceException(Nekoyume.UI.Model.ItemCountAndPricePopup popup) :
     base(string.Format(MessageFormat,
                        popup.Item.Value.ItemBase.Value.GetLocalizedName(),
                        popup.Price.Value))
 {
 }