Example #1
0
        public void getBlackmarketPrices(MarketplaceAvailableOffersListViewMessage msg)
        {
            for (int i = 0; i < this.bmprice.Length; i++)
            {
                this.bmprice[i] = 0;
            }

            MarketplaceTypeAvailability[] available = msg.available;
            DateTime tme = DateTime.Now;

            for (int i = 0; i < available.Length; i++)
            {
                MarketplaceTypeAvailability mta = available[i];
                int index = helpf.cardidToArrayIndex(mta.type);
                if (index >= 0)
                {
                    this.bmprice[index] = mta.price;
                }
            }
        }
Example #2
0
        public void handleMessage(Message msg)
        {
            if (msg is MessageMessage)
            {
                MessageMessage omsg = (MessageMessage)msg;
                if (omsg.type == MessageMessage.Type.SOLD_MARKET_SCROLLS)
                {
                    this.needSoldAucs = true;
                    App.Communicator.send(new MarketplaceSoldListViewMessage());
                }
            }

            if (msg is OkMessage)
            {
                OkMessage omsg = (OkMessage)msg;
                if (Helpfunktions.Instance.createAuctionMenu)
                {
                    if (omsg.op == "MarketplaceCreateOffer" && this.sellingCard != null)
                    {
                        Helpfunktions.Instance.cardIDToNumberOwned[this.sellingType]--;
                        Helpfunktions.Instance.cardIDToNumberOwnedTiered[this.sellingType] -= (int)Math.Pow(3, sellingTypeLevel);
                        PlayerStore.Instance.createCardsFilter.filtersChanged = true;
                        PlayerStore.Instance.sellOfferFilter.filtersChanged   = true;

                        this.dataOffer   = 0;
                        this.sellingCard = null;
                        App.Communicator.send(new MarketplaceOffersViewMessage());
                        //App.Communicator.send(new MarketplaceSoldListViewMessage());
                        App.Communicator.sendRequest(new LibraryViewMessage());
                    }
                    if (omsg.op == "MarketplaceCancelOffer")
                    {
                        Helpfunktions.Instance.cardIDToNumberOwned[this.cancelType]++;
                        Helpfunktions.Instance.cardIDToNumberOwnedTiered[this.cancelType] += (int)Math.Pow(3, cancelTypeLevel);
                        PlayerStore.Instance.createCardsFilter.filtersChanged              = true;
                        PlayerStore.Instance.sellOfferFilter.filtersChanged = true;

                        this.dataOffer = 0;
                        App.Communicator.send(new MarketplaceOffersViewMessage());
                        //App.Communicator.send(new MarketplaceSoldListViewMessage());
                        App.Communicator.sendRequest(new LibraryViewMessage());
                    }

                    if (omsg.op == "MarketplaceClaim")
                    {
                        if (transactionBeingClaimed == null)
                        {
                            return;
                        }
                        if (this.workthreadclaimall)
                        {
                            this.claimeditemstaxes += this.transactionBeingClaimed.fee;
                            this.claimeditemsmoney += this.transactionBeingClaimed.sellPrice;
                            System.Threading.Thread.Sleep(150);
                            this.claimlast();
                            return;
                        }
                        App.AudioScript.PlaySFX("Sounds/hyperduck/UI/ui_coin_tally_end");
                        CardType cardType = CardTypeManager.getInstance().get(this.transactionBeingClaimed.cardType);
                        this.dataOffer    = 0;
                        this.needSoldAucs = true;
                        App.Communicator.send(new MarketplaceOffersViewMessage());
                        App.Communicator.send(new MarketplaceSoldListViewMessage());
                        App.Communicator.sendRequest(new LibraryViewMessage());
                        App.Popups.ShowOk(this, "claimgold", "Gold added", string.Concat(new object[]
                        {
                            "<color=#bbaa88>Tier ",
                            (int)(this.transactionBeingClaimed.level + 1),
                            " ",
                            cardType.name,
                            " sold for ",
                            this.transactionBeingClaimed.sellPrice,
                            " gold!\nEarned <color=#ffd055>",
                            this.transactionBeingClaimed.sellPrice - this.transactionBeingClaimed.fee,
                            " gold</color> (the fence collects ",
                            this.transactionBeingClaimed.fee,
                            ").</color>"
                        }), "Ok");
                        this.transactionBeingClaimed = null;
                    }
                }

                if (Helpfunktions.Instance.playerStoreMenu)
                {
                    if (omsg.op == "MarketplaceMakeDeal")
                    {
                        App.Communicator.sendRequest(new GetStoreItemsMessage());
                        App.Communicator.sendRequest(new LibraryViewMessage());
                        App.Popups.ShowOk(this, "dealmade", "Purchase complete!", clickedItemName + " has been added to your collection.", "Ok");
                        Helpfunktions.Instance.cardIDToNumberOwned[this.clickedItemtypeid]++;
                        Helpfunktions.Instance.cardIDToNumberOwnedTiered[this.clickedItemtypeid] += (int)Math.Pow(3, clickedItemLevel);
                        PlayerStore.Instance.createCardsFilter.filtersChanged = true;
                        PlayerStore.Instance.sellOfferFilter.filtersChanged   = true;
                        clickedItemBuyID = -1;
                    }
                }
            }

            if (msg is FailMessage)
            {
                FailMessage failMessage = (FailMessage)msg;
                if (failMessage.isType(typeof(MarketplaceMakeDealMessage)))
                {
                    App.Popups.ShowOk(this, "dealNOTmade", "Purchase failed", failMessage.info, "Ok");
                    PlayerStore.Instance.createCardsFilter.filtersChanged = true;
                    PlayerStore.Instance.sellOfferFilter.filtersChanged   = true;
                    clickedItemBuyID = -1;
                }

                if (failMessage.isType(typeof(MarketplaceCreateOfferMessage)) && this.sellingCard != null)
                {
                    App.Popups.ShowOk(this, "cantcreate", "Create failed", failMessage.info, "Ok");
                    this.sellingCard = null;
                }

                if (failMessage.isType(typeof(MarketplaceClaimMessage)))
                {
                    if (transactionBeingClaimed == null)
                    {
                        return;
                    }
                    if (this.workthreadclaimall)
                    {
                        System.Threading.Thread.Sleep(150);
                        this.claimlast();
                        return;
                    }
                    this.dataOffer    = 0;
                    this.needSoldAucs = true;
                    App.Communicator.send(new MarketplaceOffersViewMessage());
                    App.Communicator.send(new MarketplaceSoldListViewMessage());
                    App.Communicator.sendRequest(new LibraryViewMessage());
                    transactionBeingClaimed = null;
                }
            }

            if (msg is CheckCardDependenciesMessage && sellingCard != null)
            {
                CheckCardDependenciesMessage checkCardDependenciesMessage = (CheckCardDependenciesMessage)msg;
                if (checkCardDependenciesMessage.dependencies == null || checkCardDependenciesMessage.dependencies.Length == 0)
                {
                    this.GetCreateOfferInfo();
                }
                else
                {
                    App.Popups.ShowOkCancel(this, "deckinvalidationwarning", "Notice", "Selling this scroll will make the following decks illegal:\n\n" + DeckUtil.GetFormattedDeckNames(checkCardDependenciesMessage.GetDeckNames()), "Ok", "Cancel");
                }
            }

            if (msg is MarketplaceCreateOfferInfoMessage && sellingCard != null)
            {
                MarketplaceCreateOfferInfoMessage marketplaceCreateOfferInfoMessage = (MarketplaceCreateOfferInfoMessage)msg;
                App.Popups.ShowSellCard(this, "sellcard", this.sellingCard, marketplaceCreateOfferInfoMessage.lowestPrice, marketplaceCreateOfferInfoMessage.suggestedPrice, marketplaceCreateOfferInfoMessage.copiesForSale, marketplaceCreateOfferInfoMessage.tax);
            }

            if (msg is MarketplaceOffersSearchViewMessage)
            {
                MarketplaceOffersSearchViewMessage marketplaceOffersViewMessage = (MarketplaceOffersSearchViewMessage)msg;
                clickedItemForSales = marketplaceOffersViewMessage.copiesForSale;
                clickedItemLevel    = marketplaceOffersViewMessage.offer.card.level;
                clickedItemPrice    = marketplaceOffersViewMessage.offer.price;
                clickedItemBuyID    = marketplaceOffersViewMessage.offer.id;
                clickedItemName     = marketplaceOffersViewMessage.offer.card.getName();
                clickedItemtypeid   = marketplaceOffersViewMessage.offer.card.getType();
            }

            if (msg is MarketplaceOffersViewMessage)
            {
                //if (this.dataisreadyOwnOffers) return;

                MarketplaceOffersViewMessage marketplaceOffersViewMessage = (MarketplaceOffersViewMessage)msg;
                MarketplaceOffer[]           offers = marketplaceOffersViewMessage.offers;
                this.pstoreOwnAucs.Clear();
                DateTime tme = DateTime.Now;
                tme = tme.AddMilliseconds(1000);
                for (int i = 0; i < offers.Length; i++)
                {
                    MarketplaceOffer marketplaceOffer = offers[i];
                    Auction          a = new Auction(App.MyProfile.ProfileInfo.name, tme, Auction.OfferType.SELL, marketplaceOffer.card, "" + marketplaceOffer.id, marketplaceOffer.price);
                    tme = tme.AddMilliseconds(1);
                    //Console.WriteLine("add owm auction: " + a.card.getName() + " " + a.price);
                    this.pstoreOwnAucs.Add(a);
                }

                this.dataOffer++;

                if (this.dataOffer >= 2 || !this.needSoldAucs)
                {
                    this.dataisreadyOwnOffers = true;
                }
                if (this.dataOffer >= 2)
                {
                    this.needSoldAucs = false;
                }
            }

            if (msg is MarketplaceSoldListViewMessage)
            {
                //if (this.dataisreadyOwnOffers) return;

                MarketplaceSoldListViewMessage marketplaceOffersViewMessage = (MarketplaceSoldListViewMessage)msg;
                TransactionInfo[] offers = marketplaceOffersViewMessage.sold;
                this.pstoreSOLDAucs.Clear();
                this.soldScrollTransactions.Clear();
                DateTime tme = DateTime.Now;

                for (int i = 0; i < offers.Length; i++)
                {
                    TransactionInfo marketplaceOffer = offers[i];
                    if (!marketplaceOffer.claimed)
                    {
                        this.soldScrollTransactions.Add(marketplaceOffer.cardId, marketplaceOffer);
                    }
                    CardType type       = CardTypeManager.getInstance().get(marketplaceOffer.cardType);
                    Card     c          = new Card(marketplaceOffer.cardId, type, true);
                    string   aucmessage = "sold " + marketplaceOffer.fee;
                    if (marketplaceOffer.claimed)
                    {
                        aucmessage += " claimed";
                        continue;
                    }
                    Auction a = new Auction(App.MyProfile.ProfileInfo.name, tme, Auction.OfferType.SELL, c, aucmessage, marketplaceOffer.sellPrice, marketplaceOffer.cardId);
                    tme = tme.AddMilliseconds(1);
                    //Console.WriteLine("add owm auction: " + a.card.getName() + " " + a.price);
                    this.pstoreSOLDAucs.Add(a);
                }
                this.dataOffer++;
                if (this.dataOffer >= 2)
                {
                    this.dataisreadyOwnOffers = true;
                }
                this.needSoldAucs = false;
            }

            if (msg is MarketplaceAvailableOffersListViewMessage)
            {
                Prices.Instance.getBlackmarketPrices(msg as MarketplaceAvailableOffersListViewMessage);
                if (this.dataisready)
                {
                    return;
                }

                MarketplaceAvailableOffersListViewMessage marketplaceAvailableOffersListViewMessage = (MarketplaceAvailableOffersListViewMessage)msg;

                MarketplaceTypeAvailability[] available = marketplaceAvailableOffersListViewMessage.available;
                this.pstoreAucs.Clear();
                DateTime tme = DateTime.Now;
                for (int i = 0; i < available.Length; i++)
                {
                    MarketplaceTypeAvailability mta = available[i];
                    CardType type = CardTypeManager.getInstance().get(mta.type);
                    Card     card = new Card(1, type, true);
                    card.level = mta.level;
                    Auction a = new Auction("BlackMarket", tme, Auction.OfferType.SELL, card, "", mta.price);
                    tme = tme.AddMilliseconds(-1);
                    //Console.WriteLine("add auction: " + a.card.getName() + " " + a.price);
                    this.pstoreAucs.Add(a);
                }

                this.dataisready = true;
            }
            return;
        }
Example #3
0
        public void getBlackmarketPrices(MarketplaceAvailableOffersListViewMessage msg)
        {
            for (int i = 0; i < this.bmprice.Length; i++)
            {
                this.bmprice[i] = 0;
            }

            MarketplaceTypeAvailability[] available = msg.available;
            DateTime tme = DateTime.Now;
            for (int i = 0; i < available.Length; i++)
            {
                MarketplaceTypeAvailability mta = available[i];
                int index = helpf.cardidToArrayIndex(mta.type);
                if (index >= 0)
                {
                    this.bmprice[index]=mta.price;
                }
            }

        }