Example #1
0
            public int CompareLVIs(ListViewItem lvi1, ListViewItem lvi2)
            {
                if (this._SortOrder == System.Windows.Forms.SortOrder.None)
                {
                    return(0);
                }

                int sort_result = -1;

                GameObjs.Card card1 = (GameObjs.Card)lvi1.Tag;
                GameObjs.Card card2 = (GameObjs.Card)lvi2.Tag;

                if (this._ComparerType == ComparerTypes.EK_Card_Level)
                {
                    if (card1.Level == card2.Level)
                    {
                        sort_result = card1.EvolvedTimes.CompareTo(card2.EvolvedTimes);
                    }
                    else
                    {
                        sort_result = card1.Level.CompareTo(card2.Level);
                    }
                }
                else if (this._ComparerType == ComparerTypes.Standard_Numeric)
                {
                    sort_result = Utils.CInt(lvi1.SubItems[_SortedColumn].Text).CompareTo(Utils.CInt(lvi2.SubItems[_SortedColumn].Text));
                }
                else
                {
                    sort_result = string.Compare(lvi1.SubItems[_SortedColumn].Text, lvi2.SubItems[_SortedColumn].Text);
                }

                return((this._SortOrder == System.Windows.Forms.SortOrder.Ascending) ? sort_result : -sort_result);
            }
Example #2
0
        private void enchantToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.lstCards.SelectedItems.Count <= 0)
            {
                return;
            }

            int EnchantLevel = Utils.CInt(Utils.Input_Text("To What Level?", "Enchant this card to what level (1 - 10 or 1 - 15):"));

            if ((EnchantLevel < 1) || (EnchantLevel > 15))
            {
                return;
            }

            try
            {
                GameObjs.Card card = (GameObjs.Card) this.lstCards.SelectedItems[0].Tag;

                Utils.StartMethodMultithreaded(() =>
                {
                    GameClient.Current.EnchantCard(card.Name, EnchantLevel, card.ID_User);
                });
            }
            catch { }
        }
Example #3
0
        private void previewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.lstCards.SelectedItems.Count <= 0)
            {
                return;
            }

            try
            {
                GameObjs.Card card = (GameObjs.Card) this.lstCards.SelectedItems[0].Tag;

                frmMain.ext().PopupCardPreviewWindow(card.ID_Generic, card.Level, Cursor.Position, "", 0, 0, 0, 0, null, null, null, null, card.EvolvedTimes, card.EvolvedSkillID);
            }
            catch { }
        }
        private void exportAllCardsToTextFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string output_txt = "";
            string output_csv = "";

            Cursor cur = this.Cursor;

            this.Cursor = Cursors.WaitCursor;

            Utils.StartMethodMultithreadedAndWait(() =>
            {
                GameObjs.Card.RefreshCardsInDeckCache();

                JObject cards = GameClient.Current.GetUsersCards();

                output_txt += String.Format("{0, -25}  {1, -5}  {2, -12}  {3, -5}  {4, -20}  {5, -14}  {6, -14}\r\n", "Card Name", "Stars", "Element", "Level", "Evolved Skill", "Card ID", "Unique Card ID");
                output_txt += String.Format("{0, -25}  {1, -5}  {2, -12}  {3, -5}  {4, -20}  {5, -14}  {6, -14}\r\n", "-------------------------", "-----", "------------", "-----", "--------------------", "--------------", "--------------");
                output_csv += String.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\"\r\n", "Card Name", "Stars", "Element", "Level", "Evolved Skill", "Card ID", "Unique Card ID");

                foreach (var jCard in cards["data"]["Cards"])
                {
                    try
                    {
                        GameObjs.Card TempCard = new GameObjs.Card(jCard);

                        if (!TempCard.Valid)
                        {
                            continue;
                        }
                        if (!Utils.ValidText(TempCard.Name))
                        {
                            continue;
                        }

                        output_txt += String.Format("{0, -25}  {1, -5}  {2, -12}  {3, -5}  {4, -20}  {5, -14}  {6, -14}\r\n", TempCard.Name, TempCard.Stars.ToString(), TempCard.ElementType.ToString(), TempCard.Level.ToString(), TempCard.EvolvedSkill, TempCard.ID_Generic.ToString(), TempCard.ID_User.ToString());
                        output_csv += String.Format("\"{0}\",{1},\"{2}\",{3},\"{4}\",{5},{6}\r\n", TempCard.Name, TempCard.Stars.ToString(), TempCard.ElementType.ToString(), TempCard.Level.ToString(), TempCard.EvolvedSkill, TempCard.ID_Generic.ToString(), TempCard.ID_User.ToString());
                    }
                    catch { }
                }

                Utils.FileOverwrite(Utils.AppFolder + @"\\Game Data\" + GameClient.GameAbbreviation(GameClient.Current.Service) + " card collection (" + Utils.GetAppSetting("Login_Account").Trim().Replace("@", ".") + ").txt", output_txt);
                Utils.FileOverwrite(Utils.AppFolder + @"\\Game Data\" + GameClient.GameAbbreviation(GameClient.Current.Service) + " card collection (" + Utils.GetAppSetting("Login_Account").Trim().Replace("@", ".") + ").csv", output_csv);
            });

            this.Cursor = cur;

            MessageBox.Show("Done exporting!", "Finished", MessageBoxButtons.OK);
        }
Example #5
0
        private void showEvolutionSkillsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <ListViewItem> items = this.AllSelectedItems;

            if (items.Count <= 0)
            {
                return;
            }

            try
            {
                foreach (var lvi in items)
                {
                    GameObjs.Card card = (GameObjs.Card)lvi.Tag;

                    if (this.lstCards.Columns.Count == 11)
                    {
                        for (int i = 1; i <= iEvoMaxChoices; i++)
                        {
                            this.lstCards.Columns.Add("Evo Choice #" + i.ToString(), 100);
                            this.lstCards.Items[lvi.Index].SubItems.Add(card.EvoSkillChoice(i));
                        }
                    }
                    else
                    {
                        if (this.lstCards.Items[lvi.Index].SubItems.Count == 11)
                        {
                            for (int i = 1; i <= iEvoMaxChoices; i++)
                            {
                                this.lstCards.Items[lvi.Index].SubItems.Add(card.EvoSkillChoice(i));
                            }
                        }
                        else
                        {
                            for (int i = 1; i <= iEvoMaxChoices; i++)
                            {
                                this.lstCards.Items[lvi.Index].SubItems[10 + i].Text = card.EvoSkillChoice(i);
                            }
                        }
                    }
                }
            }
            catch { }
        }
Example #6
0
        private void sellToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <ListViewItem> items = this.AllSelectedItems;

            if (items.Count <= 0)
            {
                return;
            }

            if (MessageBox.Show("Do you really want to sell " + items.Count.ToString("#,##0") + " " + Utils.PluralWord(items.Count, "card", "cards") + "?", "Confirm Card Sale", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }

            string cards_to_sell   = "";
            int    gold_amount     = 0;
            int    gold_cards_sold = items.Count;

            foreach (ListViewItem lvi in items)
            {
                GameObjs.Card card = (GameObjs.Card)lvi.Tag;

                cards_to_sell += card.ID_User.ToString() + "_";
                gold_amount   += card.SellWorth;
            }

            cards_to_sell = cards_to_sell.Trim(new char[] { '_' });

            Cursor cur = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            Utils.StartMethodMultithreadedAndWait(() =>
            {
                GameClient.Current.GetGameData("card", "SaleCardRunes", "Cards=" + cards_to_sell);
                GameClient.Current.GameVitalsUpdate(GameClient.Current.GetGameData("user", "GetUserInfo"));
                GameClient.Current.UserCards_CachedData = null;
                Utils.LoggerNotifications("<color=#ffa000>Sold " + gold_cards_sold.ToString("#,##0") + " " + Utils.PluralWord(gold_cards_sold, "card", "cards") + " for " + gold_amount.ToString("#,##0") + " gold.</color>");
            });
            this.Cursor = cur;
            this.InitCards();
        }
        public void Play_DoDailyEnchantAndSell()
        {
            lock (this.locker_gamedata)
            {
                // buy a gold pack
                // (assume this has already been done by buying a free gold pack)

                // grab a fresh user card list
                this.UserCards_CachedData = null;
                JObject cards = GameClient.Current.GetUsersCards();

                // find a 1* card
                GameObjs.Card card_A = null;
                foreach (var jCard in cards["data"]["Cards"])
                {
                    GameObjs.Card temp_card = new GameObjs.Card(jCard);
                    if ((temp_card.CurrentXP == 0) && (temp_card.Stars == 1))
                    {
                        card_A = temp_card;
                        break;
                    }
                }

                // couldn't find a destination card to enchant
                if (card_A == null)
                    return;

                // find a different 1* card
                GameObjs.Card card_B = null;
                foreach (var jCard in cards["data"]["Cards"])
                {
                    GameObjs.Card temp_card = new GameObjs.Card(jCard);
                    if ((temp_card.ID_User != card_A.ID_User) && (temp_card.CurrentXP == 0) && (temp_card.Stars == 1))
                    {
                        card_B = temp_card;
                        break;
                    }
                }

                // couldn't find a source card to enchant with
                if (card_B == null)
                    return;

                // enchant the first 1* card with the second 1* card
                 this.GetGameData("streng", "Card", "UserCardId1=" + card_A.ID_User.ToString() + "&UserCardId2=" + card_B.ID_User.ToString(), false);

                // sell the first 1* card
                GameClient.Current.GetGameData("card", "SaleCardRunes", "Cards=" + card_A.ID_User.ToString());

                // clear the user card list cache
                this.UserCards_CachedData = null;
            }
        }
        public void Play_DailyFreeCards()
        {
            lock (this.locker_gamedata)
            {
                JObject shop_data = JObject.Parse(this.GetGameData("shopnew", "GetGoods", true));

                try
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        try
                        {
                            JToken shop_item = shop_data["data"]["oldgood"][i.ToString()];

                            if (Utils.CInt(shop_item["MaxFreeTimes"]) > 0)
                            {
                                // something they can get for free

                                if ((Utils.CInt(shop_item["RemainTime"]) == 0) && (Utils.CInt(shop_item["FreeTimes"]) < Utils.CInt(shop_item["MaxFreeTimes"])))
                                {
                                    // ... and cooldown is up and they have remaining attempts

                                    int goods_id = Utils.CInt(shop_item["GoodsId"]);

                                    JObject cards_received = JObject.Parse(this.GetGameData("shopnew", "FreeBuy", "GoodsId=" + goods_id.ToString()));

                                    string[] card_ids = Utils.SubStringsDups(cards_received["data"]["CardIds"].ToString(), "_");
                                    string all_cards = "";
                                    bool bFiveStar = false;
                                    bool bEventCard = false;
                                    bool bTreasureCard = false;
                                    bool bFoodCard = false;

                                    foreach (string card_id in card_ids)
                                    {
                                        all_cards += ", [Card #" + card_id + "]";

                                        GameObjs.Card card = new GameObjs.Card(Utils.CInt(card_id));

                                        if (card.Stars == 5)
                                            bFiveStar = true;
                                        if (card.EventCard)
                                            bEventCard = true;
                                        if (card.TreasureCard)
                                            bTreasureCard = true;
                                        if (card.FoodCard)
                                            bFoodCard = true;
                                    }

                                    all_cards = all_cards.Trim(new char[] { ' ', ',' });

                                    Utils.LoggerNotifications("<color=#ffa000>You bought a <b><u>free</u></b> " + shop_item["Name"].ToString() + " and received...</color>");
                                    Utils.LoggerNotifications("<color=#ffa000>      " + all_cards + "</color>");
                                    if (bFiveStar)
                                        Utils.LoggerNotifications("<color=#ffff40>      <b>CONGRATULATIONS</b> on your new 5★ card!</color>");
                                    if (bEventCard)
                                        Utils.LoggerNotifications("<color=#ffff40>      <b>CONGRATULATIONS</b> on your new event card!</color>");
                                    if (bTreasureCard)
                                        Utils.LoggerNotifications("<color=#ffff40>      <b>CONGRATULATIONS</b> on your new treasure card!</color>");
                                    if (bFoodCard)
                                        Utils.LoggerNotifications("<color=#ffff40>      <b>CONGRATULATIONS</b> on your new food card!</color>");
                                }
                            }
                        }
                        catch { }
                    }
                }
                catch { }
            }
        }
        public void NewestCardReport()
        {
            Utils.LoggerNotifications("<color=#005f8f>------------------------------------------------------------------------------------------------------------------------</color>");
            Utils.LoggerNotifications("<color=#00efff><fs+><b>New Card Report</b> (the thirty most recent 4★ and 5★ cards and resources)<fs-></color>");
            Utils.LoggerNotifications("<color=#00a0d8>only unleveled cards will appear in this list :: newest cards on top</color>");
            Utils.LoggerNotifications("<color=#005f8f>------------------------------------------------------------------------------------------------------------------------</color>");

            try
            {
                JObject users_cards = this.GetUsersCards();

                int iCardStop = 0;
                JArray cards = (JArray)users_cards["data"]["Cards"];

                for (int cardIndex = cards.Count - 1; cardIndex >= 0; cardIndex--)
                {
                    JObject this_card = (JObject)cards[cardIndex];
                    JObject generic_card_details = this.GetCardByID(Utils.CInt(this_card["CardId"]));

                    GameObjs.Card card = new GameObjs.Card(this_card);

                    if (card.CurrentXP == 0)
                    {
                        if ((card.Stars >= 4) || (card.Cost == 99) || (card.ElementType == GameObjs.Card.ElementTypes.Activity) || (card.ElementType == GameObjs.Card.ElementTypes.Treasure) || (card.ElementType == GameObjs.Card.ElementTypes.Food))
                        {
                            string card_pretty_details = "";
                            string card_color_start = "<color=#c0c0c0>";
                            string card_color_end = "</color>";

                            if ((card.Cost == 99) || (card.ElementType == GameObjs.Card.ElementTypes.Activity) || (card.ElementType == GameObjs.Card.ElementTypes.Treasure) || (card.ElementType == GameObjs.Card.ElementTypes.Food))
                            {
                                if (card.FoodCard)
                                {
                                    card_pretty_details = card.Stars.ToString() + "★ food worth " + card.EnchantingWorth.ToString("#,##0") + " EXP when enchanting another card";

                                    card_color_start = "<color=#40ff40>";
                                }
                                else if (card.TreasureCard)
                                {
                                    card_pretty_details = card.Stars.ToString() + "★ treasure worth " + Utils.CInt(generic_card_details["Price"]).ToString("#,##0") + " gold when selling";

                                    card_color_start = "<color=#ffa000>";
                                }
                                else
                                {
                                    card_pretty_details = card.Stars.ToString() + "★ activity useful during a special event";

                                    card_color_start = "<color=#ff40d0>";
                                }
                            }
                            else
                            {
                                card_pretty_details = card.Stars.ToString() + "★ " + card.Element + " with a " + card.Wait.ToString() + "-turn wait and " + card.Cost.ToString() + " COST";

                                if (card.Stars >= 5)
                                    card_color_start = "<color=#ffffff>";
                            }

                            if ((card.Cost != 99 && card.Stars >= 5) || (card.Cost == 99 && card.Stars >= 4))
                            {
                                card_color_start = "<i><b><fs+>" + card_color_start;
                                card_color_end = card_color_end + "<fs-></b></i>";
                            }

                            Utils.LoggerNotifications("<color=#00efff>" + card_color_start + card.Name + card_color_end + "  " + card_pretty_details + "</color>");

                            if (++iCardStop >= 30)
                                break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.LoggerNotifications(Errors.GetAllErrorDetails(ex));
            }

            Utils.LoggerNotifications("<color=#005f8f>------------------------------------------------------------------------------------------------------------------------</color>");
        }
        public void EnchantCard(string card_name, int card_level, int unique_card_id_to_enchant = 0)
        {
            JObject EnchantThisCard = this.GetCardByName(card_name);

            if (EnchantThisCard == null)
            {
                Utils.LoggerNotifications("<color=#ffa000>Couldn't find a matching card to enchant.</color>");
                return;
            }

            JObject user_data = JObject.Parse(this.GetGameData("user", "GetUserInfo", false));
            int UserGold = Utils.CInt(user_data["data"]["Coins"]);

            lock (this._LockedCardsLocker)
            {
                this._LockedCards.Clear();
                try
                {
                    JArray locked_cards = (JArray)user_data["data"]["LockedUserCardIds"];

                    foreach (var locked_card in locked_cards)
                    {
                        this._LockedCards.Add(locked_card.ToString().Replace("\"", "").Trim());
                    }
                }
                catch { }
            }

            this.UserCards_CachedData = null;
            this.GetUsersCards();

            GameObjs.Card CardToEnchant = null;
            List<GameObjs.Card> CardsToEat = new List<GameObjs.Card>();

            if (unique_card_id_to_enchant == 0)
            {
                for (int iLevelCap = card_level - 1; iLevelCap >= 0; iLevelCap--)
                {
                    foreach (var jCard in this.UserCards_CachedData["data"]["Cards"])
                    {
                        GameObjs.Card TempCard = new GameObjs.Card(jCard);

                        if ((TempCard.Level == iLevelCap) && (TempCard.ID_Generic == Utils.CInt(EnchantThisCard["CardId"])))
                        {
                            if (TempCard.MaxLevel >= card_level)
                            {
                                Utils.LoggerNotifications("<color=#ffa000>Found a level " + TempCard.Level.ToString() + " " + TempCard.Name + " to enchant to level " + card_level.ToString() + "!</color>");
                                Utils.LoggerNotifications("<color=#ffa000>... it will cost " + TempCard.EnchantToLevelCostXP(card_level).ToString("#,##0") + " XP to enchant</color>");
                                Utils.LoggerNotifications("<color=#ffa000>... it will cost " + TempCard.EnchantToLevelCostGold(card_level).ToString("#,##0") + " gold to enchant</color>");

                                CardToEnchant = TempCard;
                                break;
                            }
                        }
                    }

                    if (CardToEnchant != null)
                        break;
                }
            }
            else
            {
                foreach (var jCard in this.UserCards_CachedData["data"]["Cards"])
                {
                    GameObjs.Card TempCard = new GameObjs.Card(jCard);

                    if (TempCard.Level < TempCard.MaxLevel)
                    {
                        if (TempCard.MaxLevel >= card_level)
                        {
                            if (TempCard.ID_User == unique_card_id_to_enchant)
                            {
                                Utils.LoggerNotifications("<color=#ffa000>Enchanting your level " + TempCard.Level.ToString() + " " + TempCard.Name + " to level " + card_level.ToString() + "!</color>");
                                Utils.LoggerNotifications("<color=#ffa000>... it will cost " + TempCard.EnchantToLevelCostXP(card_level).ToString("#,##0") + " XP to enchant</color>");
                                Utils.LoggerNotifications("<color=#ffa000>... it will cost " + TempCard.EnchantToLevelCostGold(card_level).ToString("#,##0") + " gold to enchant</color>");

                                CardToEnchant = TempCard;
                                break;
                            }
                        }
                    }
                }
            }

            if (CardToEnchant == null)
            {
                Utils.LoggerNotifications("<color=#ffa000>You don't have an eligible " + EnchantThisCard["CardName"].ToString().Trim() + " to enchant.</color>");
            }
            else if (((double)UserGold) < (((double)CardToEnchant.EnchantToLevelCostGold(card_level)) * 1.05))
            {
                Utils.LoggerNotifications("<color=#ffa000>You need more gold to enchant this card.</color>");
            }
            else
            {
                GameObjs.Card.StarsAllowedToEnchantWith = Utils.SubStrings(Utils.GetAppSetting("Enchant_Cards_WithStars").Replace(" ", ""), ",");
                GameObjs.Card.CardsExcludedFromEnchantingWith = Utils.SubStrings(Utils.GetAppSetting("Enchant_Cards_Excluded").Replace(" ", ""), ",");
                List<string> temp = new List<string>();
                foreach (string s in GameObjs.Card.CardsExcludedFromEnchantingWith)
                {
                    JObject card = this.GetCardByName(s);
                    if (card != null)
                        temp.Add(Utils.CInt(card["CardId"]).ToString());
                }
                GameObjs.Card.CardsExcludedFromEnchantingWith = temp.ToArray();

                int XPRunningTotal = 0;

                Dictionary<int,int> cardCount = new Dictionary<int,int>();

                foreach (var jCard in this.UserCards_CachedData["data"]["Cards"])
                {
                    GameObjs.Card TempCard = new GameObjs.Card(jCard);

                    if (!cardCount.ContainsKey(TempCard.ID_Generic))
                        cardCount.Add(TempCard.ID_Generic, 1);
                    else
                        cardCount[TempCard.ID_Generic]++;
                }

                Dictionary<int,int> cardUsed = new Dictionary<int,int>();
                int iDontUseMoreThanThreshold = Utils.GetAppValue("Enchant_Cards_ReserveThreshold", 5);

                GameObjs.Card.RefreshCardsInDeckCache();

                for (int iPassNum = 0; iPassNum <= 1; iPassNum++)
                {
                    foreach (var jCard in this.UserCards_CachedData["data"]["Cards"])
                    {
                        GameObjs.Card TempCard = new GameObjs.Card(jCard);

                        if ((iPassNum == 0) && (!TempCard.FoodCard)) continue;

                        if (TempCard.OkayToConsume)
                        {
                            if (TempCard.FoodCard)
                            {
                                try
                                {

                                    int remaining_XP = CardToEnchant.EnchantToLevelCostXP(card_level) - XPRunningTotal;
                                    if (remaining_XP > 0)
                                    {
                                        double food_card_waste_percent = ((double)TempCard.EnchantingWorth) * 100.0 / ((double)remaining_XP);

                                        // using a 2,000 XP card for less than 1,000 XP need, etc.
                                        if (food_card_waste_percent >= 100.0)
                                            continue;
                                    }
                                }
                                catch
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                int iUsedSoFar = 0;
                                if (cardUsed.ContainsKey(TempCard.ID_Generic))
                                    iUsedSoFar = cardUsed[TempCard.ID_Generic];

                                if (cardCount[TempCard.ID_Generic] - iUsedSoFar <= iDontUseMoreThanThreshold)
                                    continue;
                            }

                            //Utils.LoggerNotifications("Found a level " + TempCard.Level.ToString() + " " + TempCard.Name + " to enchant with for " + TempCard.EnchantingWorth.ToString("#,##0") + " XP");

                            XPRunningTotal += TempCard.EnchantingWorth;
                            CardsToEat.Add(TempCard);

                            if (!cardUsed.ContainsKey(TempCard.ID_Generic))
                                cardUsed.Add(TempCard.ID_Generic, 1);
                            else
                                cardUsed[TempCard.ID_Generic]++;

                            if (XPRunningTotal >= CardToEnchant.EnchantToLevelCostXP(card_level))
                                break;
                        }
                    }
                }

                bool bEnchantAnyway = false;

                if ((CardsToEat.Count > 0) && (XPRunningTotal < CardToEnchant.EnchantToLevelCostXP(card_level)))
                    if (MessageBox.Show("Enchanting needs consume at least " + CardToEnchant.EnchantToLevelCostXP(card_level).ToString("#,##0") + " XP and " + CardToEnchant.EnchantToLevelCostGold(card_level).ToString("#,##0") + " gold in costs.  The " + CardsToEat.Count.ToString("#,##0") + " cards available to enchant with only add up to " + XPRunningTotal.ToString("#,##0") + " XP.\r\n\r\nWould you like to enchant as much as you can with the available cards?", "Partially Enchant?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                        bEnchantAnyway = true;

                if ((bEnchantAnyway) || ((XPRunningTotal >= CardToEnchant.EnchantToLevelCostXP(card_level)) && (CardsToEat.Count > 0)))
                {
                    Utils.LoggerNotifications("<color=#ffa000>Enchanting will consume " + CardsToEat.Count.ToString("#,##0") + " cards, totalling at least " + CardToEnchant.EnchantToLevelCostXP(card_level).ToString("#,##0") + " XP and " + CardToEnchant.EnchantToLevelCostGold(card_level).ToString("#,##0") + " gold in costs.</color>");

                    string cards_to_eat_list = "";
                    foreach (GameObjs.Card TempCard in CardsToEat)
                        cards_to_eat_list += "_" + TempCard.ID_User.ToString();

                    if (cards_to_eat_list.Length > 0)
                    {
                        cards_to_eat_list = cards_to_eat_list.Substring(1);

                        string upgrade_preview_json = this.GetGameData("streng", "CardPreview", "UserCardId1=" + CardToEnchant.ID_User.ToString() + "&UserCardId2=" + cards_to_eat_list, false);

                        Utils.Logger(upgrade_preview_json);

                        JObject upgrade_preview = JObject.Parse(upgrade_preview_json);

                        string message = "";
                        try
                        {
                            if (Utils.CInt(upgrade_preview["status"]) == 0)
                                message = upgrade_preview["message"].ToString();
                        }
                        catch { }

                        if (Utils.ValidText(message))
                        {
                            Utils.LoggerNotifications("<color=#ffa000>Card enchantment preview failure!</color>");
                            Utils.LoggerNotifications("<color=#ffa000>... " + message + "</color>");
                        }
                        else if ((Utils.CInt(upgrade_preview["data"]["CardLevel"]) != card_level) && (!bEnchantAnyway))
                        {
                            Utils.LoggerNotifications("<color=#ffa000>Card enchantment preview failure!</color>");
                            Utils.LoggerNotifications("<color=#ffa000>... is one of the enchantment cards in use?</color>");
                        }
                        else
                        {
                            Utils.LoggerNotifications("<color=#ffa000>... actual preview cost is " + Utils.CInt(upgrade_preview["data"]["Exp"]).ToString("#,##0") + " XP and " + Utils.CInt(upgrade_preview["data"]["Coins"]).ToString("#,##0") + " gold in costs.</color>");

                            if (Utils.CInt(upgrade_preview["data"]["Coins"]) > UserGold)
                            {
                                Utils.LoggerNotifications("<color=#ffa000>You need more gold to enchant this card.</color>");
                            }
                            else
                            {
                                string enchant_result_json = this.GetGameData("streng", "Card", "UserCardId1=" + CardToEnchant.ID_User.ToString() + "&UserCardId2=" + cards_to_eat_list, false);

                                Utils.Logger(enchant_result_json);

                                JObject enchant_result = JObject.Parse(enchant_result_json);

                                Utils.LoggerNotifications("<color=#ffa000>Card has been enchanted to level " + upgrade_preview["data"]["CardLevel"].ToString() + "!</color>");
                            }
                        }
                    }
                    else
                    {
                        // logic error: shouldn't be able to get here

                        Utils.LoggerNotifications("<color=#ffa000>Enchanting needs consume at least " + CardToEnchant.EnchantToLevelCostXP(card_level).ToString("#,##0") + " XP and " + CardToEnchant.EnchantToLevelCostGold(card_level).ToString("#,##0") + " gold in costs.  The " + CardsToEat.Count.ToString("#,##0") + " cards available to enchant with only add up to " + XPRunningTotal.ToString("#,##0") + " XP.</color>");
                    }
                }
                else if (CardsToEat.Count > 0)
                {
                    Utils.LoggerNotifications("<color=#ffa000>Enchanting needs consume at least " + CardToEnchant.EnchantToLevelCostXP(card_level).ToString("#,##0") + " XP and " + CardToEnchant.EnchantToLevelCostGold(card_level).ToString("#,##0") + " gold in costs.  The " + CardsToEat.Count.ToString("#,##0") + " cards available to enchant with only add up to " + XPRunningTotal.ToString("#,##0") + " XP.</color>");
                }
                else
                {
                    Utils.LoggerNotifications("<color=#ffa000>Enchanting needs consume at least " + CardToEnchant.EnchantToLevelCostXP(card_level).ToString("#,##0") + " XP and " + CardToEnchant.EnchantToLevelCostGold(card_level).ToString("#,##0") + " gold in costs.  There are not enough available cards to enchant with in your collection.  Check your collection and/or your settings to make sure EK Unleashed is allowed to enchant with 1* and 2* cards, for example.</color>");
                }
            }

            Utils.LoggerNotifications("<color=#ffa000>Auto-enchant finished.</color>");
        }
Example #11
0
        private void InitCards()
        {
            Cursor cur = this.Cursor;
            this.Cursor = Cursors.WaitCursor;

            Utils.DontDrawControl(this.lstCards);

            bool want_evo_choices = this.chkEvoChoices.Checked;

            if ((this.lstCards.Columns.Count == 11) && (want_evo_choices))
            {
                for (int i = 1; i <= iEvoMaxChoices; i++)
                    this.lstCards.Columns.Add("Evo Choice #" + i.ToString(), 100);
            }
            else if ((this.lstCards.Columns.Count == 11 + iEvoMaxChoices) && (!want_evo_choices))
            {
                for (int i = 1; i <= iEvoMaxChoices; i++)
                    this.lstCards.Columns.RemoveAt(11);
            }

            Utils.StartMethodMultithreadedAndWait(() =>
            {
                GameObjs.Card.RefreshCardsInDeckCache();

                JObject cards = GameClient.Current.GetUsersCards();

                this.ClearList();

                List<GameObjs.Card> cardobjs = new List<GameObjs.Card>();

                foreach (var jCard in cards["data"]["Cards"])
                {
                    try
                    {
                        GameObjs.Card TempCard = new GameObjs.Card(jCard);

                        if (!TempCard.Valid) continue;
                        if (!Utils.ValidText(TempCard.Name)) continue;

                        if ((TempCard.Stars == 1) && (!this.chk1Star.Checked)) continue;
                        if ((TempCard.Stars == 2) && (!this.chk2Star.Checked)) continue;
                        if ((TempCard.Stars == 3) && (!this.chk3Star.Checked)) continue;
                        if ((TempCard.Stars == 4) && (!this.chk4Star.Checked)) continue;
                        if ((TempCard.Stars == 5) && (!this.chk5Star.Checked)) continue;

                        cardobjs.Add(TempCard);
                    }
                    catch (Exception ex)
                    {
                        Utils.Chatter(Errors.GetShortErrorDetails(ex));
                    }
                }

                this.AddCards(cardobjs, want_evo_choices);
            });

            this.lstCards.Sort();

            Utils.DrawControl(this.lstCards);

            this.Cursor = cur;
        }
Example #12
0
        private void SellCards(SellCardsMode sell_mode, string sell_desc)
        {
            GameObjs.Card.RefreshCardsInDeckCache();

            JObject cards = GameClient.Current.GetUsersCards();

            List<GameObjs.Card> items = new List<GameObjs.Card>();
            int iTotalIncludingNonqualifyingCards = 0;

            Dictionary<int, int> cardCount = new Dictionary<int, int>();

            foreach (var jCard in cards["data"]["Cards"])
            {
                GameObjs.Card TempCard = new GameObjs.Card(jCard);

                if (!cardCount.ContainsKey(TempCard.ID_Generic))
                    cardCount.Add(TempCard.ID_Generic, 1);
                else
                    cardCount[TempCard.ID_Generic]++;
            }

            Dictionary<int, int> cardUsed = new Dictionary<int, int>();
            int iDontUseMoreThanThreshold = Utils.GetAppValue("Sell_Cards_ReserveThreshold", 10);

            foreach (var jCard in cards["data"]["Cards"])
            {
                try
                {
                    GameObjs.Card TempCard = new GameObjs.Card(jCard);

                    if (!TempCard.Valid) continue;
                    if (!Utils.ValidText(TempCard.Name)) continue;

                    if (TempCard.Level != 0) continue;
                    if (TempCard.Locked) continue;
                    if (TempCard.InAnyDeck) continue;
                    if (TempCard.ElementType == GameObjs.Card.ElementTypes.Food) continue;
                    if (TempCard.ElementType == GameObjs.Card.ElementTypes.Activity) continue;

                    switch (sell_mode)
                    {
                        case SellCardsMode.Stars1:
                            if (TempCard.Stars != 1) continue;
                            break;

                        case SellCardsMode.Stars2:
                            if (TempCard.Stars != 2) continue;
                            break;

                        case SellCardsMode.Stars3:
                            if (TempCard.Stars != 3) continue;
                            break;

                        case SellCardsMode.Stars4:
                            if (TempCard.Stars != 4) continue;
                            break;

                        case SellCardsMode.Treasure:
                            if (TempCard.ElementType != GameObjs.Card.ElementTypes.Treasure) continue;
                            break;

                    }

                    iTotalIncludingNonqualifyingCards++;

                    // Test threshold (if we're not selling treasure cards)
                    if (sell_mode != SellCardsMode.Treasure)
                    {
                        int iUsedSoFar = 0;
                        if (cardUsed.ContainsKey(TempCard.ID_Generic))
                            iUsedSoFar = cardUsed[TempCard.ID_Generic];
                        if (cardCount[TempCard.ID_Generic] - iUsedSoFar <= iDontUseMoreThanThreshold) continue;

                        items.Add(TempCard);

                        if (!cardUsed.ContainsKey(TempCard.ID_Generic))
                            cardUsed.Add(TempCard.ID_Generic, 1);
                        else
                            cardUsed[TempCard.ID_Generic]++;
                    }
                    else
                        items.Add(TempCard); // always sell all treasure cards if they meet the normal qualifications
                }
                catch { }
            }

            if (items.Count == 0)
            {
                MessageBox.Show("You don't have any qualifying " + sell_desc + " cards to sell." + ((iTotalIncludingNonqualifyingCards == 0) ? string.Empty : "\r\n\r\nYour reserve of " + iDontUseMoreThanThreshold.ToString("#,##0") + " caused " + (iTotalIncludingNonqualifyingCards - items.Count).ToString("#,##0") + " cards to be skipped."), "No " + sell_desc + " Cards", MessageBoxButtons.OK);
                return;
            }

            if (MessageBox.Show("Do you really want to sell " + items.Count.ToString("#,##0") + " " + sell_desc + " " + Utils.PluralWord(items.Count, "card", "cards") + "?" + ((iTotalIncludingNonqualifyingCards == items.Count) ? string.Empty : "\r\n\r\nYour reserve of " + iDontUseMoreThanThreshold.ToString("#,##0") + " caused " + (iTotalIncludingNonqualifyingCards - items.Count).ToString("#,##0") + " cards to be skipped."), "Confirm Card Sale", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != System.Windows.Forms.DialogResult.Yes)
                return;

            string cards_to_sell = "";
            int gold_amount = 0;
            int gold_cards_sold = items.Count;

            foreach (GameObjs.Card card in items)
            {
                cards_to_sell += card.ID_User.ToString() + "_";
                gold_amount += card.SellWorth;
            }

            cards_to_sell = cards_to_sell.Trim(new char[] { '_' });

            Cursor cur = this.Cursor;
            this.Cursor = Cursors.WaitCursor;
            Utils.StartMethodMultithreadedAndWait(() =>
            {
                GameClient.Current.GetGameData("card", "SaleCardRunes", "Cards=" + cards_to_sell);
                GameClient.Current.GameVitalsUpdate(GameClient.Current.GetGameData("user", "GetUserInfo"));
                GameClient.Current.UserCards_CachedData = null;
                Utils.LoggerNotifications("<color=#ffa000>Sold " + gold_cards_sold.ToString("#,##0") + " " + sell_desc + " " + Utils.PluralWord(gold_cards_sold, "card", "cards") + " for " + gold_amount.ToString("#,##0") + " gold.</color>");
            });

            this.Cursor = cur;
        }
Example #13
0
        private void InitCards()
        {
            Cursor cur = this.Cursor;

            this.Cursor = Cursors.WaitCursor;

            Utils.DontDrawControl(this.lstCards);

            bool want_evo_choices = this.chkEvoChoices.Checked;

            if ((this.lstCards.Columns.Count == 11) && (want_evo_choices))
            {
                for (int i = 1; i <= iEvoMaxChoices; i++)
                {
                    this.lstCards.Columns.Add("Evo Choice #" + i.ToString(), 100);
                }
            }
            else if ((this.lstCards.Columns.Count == 11 + iEvoMaxChoices) && (!want_evo_choices))
            {
                for (int i = 1; i <= iEvoMaxChoices; i++)
                {
                    this.lstCards.Columns.RemoveAt(11);
                }
            }

            Utils.StartMethodMultithreadedAndWait(() =>
            {
                GameObjs.Card.RefreshCardsInDeckCache();

                JObject cards = GameClient.Current.GetUsersCards();

                this.ClearList();

                List <GameObjs.Card> cardobjs = new List <GameObjs.Card>();

                foreach (var jCard in cards["data"]["Cards"])
                {
                    try
                    {
                        GameObjs.Card TempCard = new GameObjs.Card(jCard);

                        if (!TempCard.Valid)
                        {
                            continue;
                        }
                        if (!Utils.ValidText(TempCard.Name))
                        {
                            continue;
                        }

                        if ((TempCard.Stars == 1) && (!this.chk1Star.Checked))
                        {
                            continue;
                        }
                        if ((TempCard.Stars == 2) && (!this.chk2Star.Checked))
                        {
                            continue;
                        }
                        if ((TempCard.Stars == 3) && (!this.chk3Star.Checked))
                        {
                            continue;
                        }
                        if ((TempCard.Stars == 4) && (!this.chk4Star.Checked))
                        {
                            continue;
                        }
                        if ((TempCard.Stars == 5) && (!this.chk5Star.Checked))
                        {
                            continue;
                        }

                        cardobjs.Add(TempCard);
                    }
                    catch (Exception ex)
                    {
                        Utils.Chatter(Errors.GetShortErrorDetails(ex));
                    }
                }

                this.AddCards(cardobjs, want_evo_choices);
            });

            this.lstCards.Sort();

            Utils.DrawControl(this.lstCards);

            this.Cursor = cur;
        }
        private void SellCards(SellCardsMode sell_mode, string sell_desc)
        {
            GameObjs.Card.RefreshCardsInDeckCache();

            JObject cards = GameClient.Current.GetUsersCards();

            List <GameObjs.Card> items            = new List <GameObjs.Card>();
            int iTotalIncludingNonqualifyingCards = 0;

            Dictionary <int, int> cardCount = new Dictionary <int, int>();

            foreach (var jCard in cards["data"]["Cards"])
            {
                GameObjs.Card TempCard = new GameObjs.Card(jCard);

                if (!cardCount.ContainsKey(TempCard.ID_Generic))
                {
                    cardCount.Add(TempCard.ID_Generic, 1);
                }
                else
                {
                    cardCount[TempCard.ID_Generic]++;
                }
            }

            Dictionary <int, int> cardUsed = new Dictionary <int, int>();
            int iDontUseMoreThanThreshold  = Utils.GetAppValue("Sell_Cards_ReserveThreshold", 10);

            foreach (var jCard in cards["data"]["Cards"])
            {
                try
                {
                    GameObjs.Card TempCard = new GameObjs.Card(jCard);

                    if (!TempCard.Valid)
                    {
                        continue;
                    }
                    if (!Utils.ValidText(TempCard.Name))
                    {
                        continue;
                    }

                    if (TempCard.Level != 0)
                    {
                        continue;
                    }
                    if (TempCard.Locked)
                    {
                        continue;
                    }
                    if (TempCard.InAnyDeck)
                    {
                        continue;
                    }
                    if (TempCard.ElementType == GameObjs.Card.ElementTypes.Food)
                    {
                        continue;
                    }
                    if (TempCard.ElementType == GameObjs.Card.ElementTypes.Activity)
                    {
                        continue;
                    }

                    switch (sell_mode)
                    {
                    case SellCardsMode.Stars1:
                        if (TempCard.Stars != 1)
                        {
                            continue;
                        }
                        break;

                    case SellCardsMode.Stars2:
                        if (TempCard.Stars != 2)
                        {
                            continue;
                        }
                        break;

                    case SellCardsMode.Stars3:
                        if (TempCard.Stars != 3)
                        {
                            continue;
                        }
                        break;

                    case SellCardsMode.Stars4:
                        if (TempCard.Stars != 4)
                        {
                            continue;
                        }
                        break;

                    case SellCardsMode.Treasure:
                        if (TempCard.ElementType != GameObjs.Card.ElementTypes.Treasure)
                        {
                            continue;
                        }
                        break;
                    }

                    iTotalIncludingNonqualifyingCards++;

                    // Test threshold (if we're not selling treasure cards)
                    if (sell_mode != SellCardsMode.Treasure)
                    {
                        int iUsedSoFar = 0;
                        if (cardUsed.ContainsKey(TempCard.ID_Generic))
                        {
                            iUsedSoFar = cardUsed[TempCard.ID_Generic];
                        }
                        if (cardCount[TempCard.ID_Generic] - iUsedSoFar <= iDontUseMoreThanThreshold)
                        {
                            continue;
                        }

                        items.Add(TempCard);

                        if (!cardUsed.ContainsKey(TempCard.ID_Generic))
                        {
                            cardUsed.Add(TempCard.ID_Generic, 1);
                        }
                        else
                        {
                            cardUsed[TempCard.ID_Generic]++;
                        }
                    }
                    else
                    {
                        items.Add(TempCard); // always sell all treasure cards if they meet the normal qualifications
                    }
                }
                catch { }
            }

            if (items.Count == 0)
            {
                MessageBox.Show("You don't have any qualifying " + sell_desc + " cards to sell." + ((iTotalIncludingNonqualifyingCards == 0) ? string.Empty : "\r\n\r\nYour reserve of " + iDontUseMoreThanThreshold.ToString("#,##0") + " caused " + (iTotalIncludingNonqualifyingCards - items.Count).ToString("#,##0") + " cards to be skipped."), "No " + sell_desc + " Cards", MessageBoxButtons.OK);
                return;
            }

            if (MessageBox.Show("Do you really want to sell " + items.Count.ToString("#,##0") + " " + sell_desc + " " + Utils.PluralWord(items.Count, "card", "cards") + "?" + ((iTotalIncludingNonqualifyingCards == items.Count) ? string.Empty : "\r\n\r\nYour reserve of " + iDontUseMoreThanThreshold.ToString("#,##0") + " caused " + (iTotalIncludingNonqualifyingCards - items.Count).ToString("#,##0") + " cards to be skipped."), "Confirm Card Sale", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }

            string cards_to_sell   = "";
            int    gold_amount     = 0;
            int    gold_cards_sold = items.Count;

            foreach (GameObjs.Card card in items)
            {
                cards_to_sell += card.ID_User.ToString() + "_";
                gold_amount   += card.SellWorth;
            }

            cards_to_sell = cards_to_sell.Trim(new char[] { '_' });

            Cursor cur = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            Utils.StartMethodMultithreadedAndWait(() =>
            {
                GameClient.Current.GetGameData("card", "SaleCardRunes", "Cards=" + cards_to_sell);
                GameClient.Current.GameVitalsUpdate(GameClient.Current.GetGameData("user", "GetUserInfo"));
                GameClient.Current.UserCards_CachedData = null;
                Utils.LoggerNotifications("<color=#ffa000>Sold " + gold_cards_sold.ToString("#,##0") + " " + sell_desc + " " + Utils.PluralWord(gold_cards_sold, "card", "cards") + " for " + gold_amount.ToString("#,##0") + " gold.</color>");
            });

            this.Cursor = cur;
        }
Example #15
0
        private void goldPacksToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Utils.StartMethodMultithreaded(() =>
            {
                JObject user_data = JObject.Parse(Game.GetGameData("user", "GetUserInfo", false));
                int iGold = Utils.CInt(user_data["data"]["Coins"]);

                JObject shop_data = JObject.Parse(Game.GetGameData("shopnew", "GetGoods", "version=new", false));

                int iConsecutiveErrors = 0;

                JObject shop_1pack = frmMain.GetStoreType(shop_data, StoreTypes.Gold);
                JObject shop_10pack = frmMain.GetStoreType(shop_data, StoreTypes.Gold10);

                if (shop_1pack != null)
                {
                    try
                    {
                        int iGoldCost = Utils.CInt(shop_1pack["Coins"]);

                        if (iGoldCost > 0)
                        {
                            string pack_name = shop_1pack["Name"].ToString();

                            if (pack_name.ToLower().EndsWith("ard")) pack_name = pack_name + "s";
                            else if (pack_name.ToLower().EndsWith("ack")) pack_name = pack_name + "s";
                            else if (pack_name.ToLower().EndsWith("acks") || pack_name.Contains(" X ")) ; // intentional empty statement
                            else pack_name = pack_name + "card packs";

                            int iHowMany = Utils.CInt(Utils.Input_Text("Buy How Many", "How many " + pack_name + " would you like to buy?"));
                            if (iHowMany < 1)
                                return;

                            if (MessageBox.Show("You have " + iGold.ToString("#,##0") + " gold and it will cost " + (iGoldCost * iHowMany).ToString("#,##0") + " to buy " + iHowMany.ToString("#,##0") + " x " + shop_1pack["Name"].ToString() + ".\r\n\r\nContinue?", "Really Spend " + (iGoldCost * iHowMany).ToString("#,##0") + " Gold?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                            {
                                for (int iAmountBought = 0; iAmountBought < iHowMany;)
                                {
                                    int iAmountToBuy = 1;

                                    try
                                    {
                                        if (shop_10pack != null && Utils.CInt(shop_10pack["Coins"]) > 0)
                                            if (iAmountBought + 10 <= iHowMany)
                                                iAmountToBuy = 10;

                                        JObject cards_received;

                                        if (iAmountToBuy == 10)
                                            cards_received = JObject.Parse(Game.GetGameData("shopnew", "Buy", "version=new&GoodsId=" + shop_10pack["GoodsId"].ToString(), false));
                                        else
                                            cards_received = JObject.Parse(Game.GetGameData("shopnew", "Buy", "version=new&GoodsId=" + shop_1pack["GoodsId"].ToString(), false));

                                        string[] card_ids = Utils.SubStringsDups(cards_received["data"]["CardIds"].ToString(), "_");
                                        string all_cards = "";
                                        bool bFiveStar = false;
                                        bool bEventCard = false;
                                        bool bTreasureCard = false;
                                        bool bFoodCard = false;

                                        foreach (string card_id in card_ids)
                                        {
                                            all_cards += ", [Card #" + card_id + "]";

                                            GameObjs.Card card = new GameObjs.Card(Utils.CInt(card_id));

                                            if (card.Stars == 5)
                                                bFiveStar = true;
                                            if (card.EventCard)
                                                bEventCard = true;
                                            if (card.TreasureCard)
                                                bTreasureCard = true;
                                            if (card.FoodCard)
                                                bFoodCard = true;
                                        }

                                        all_cards = all_cards.Trim(new char[] { ' ', ',' });

                                        if (iAmountToBuy == 10)
                                            Utils.LoggerNotifications("<color=#ffa000>You bought " + shop_10pack["Name"].ToString() + " and received...</color>");
                                        else
                                            Utils.LoggerNotifications("<color=#ffa000>You bought a " + shop_1pack["Name"].ToString() + " pack and received...</color>");

                                        Utils.LoggerNotifications("<color=#ffa000>      " + all_cards + "</color>");
                                        if (bFiveStar)
                                            Utils.LoggerNotifications("<color=#ffff40>      <b>CONGRATULATIONS</b> on your new 5★ card!</color>");
                                        if (bEventCard)
                                            Utils.LoggerNotifications("<color=#ffff40>      <b>CONGRATULATIONS</b> on your new event card!</color>");
                                        if (bTreasureCard)
                                            Utils.LoggerNotifications("<color=#ffff40>      <b>CONGRATULATIONS</b> on your new treasure card!</color>");
                                        if (bFoodCard)
                                            Utils.LoggerNotifications("<color=#ffff40>      <b>CONGRATULATIONS</b> on your new food card!</color>");

                                        iConsecutiveErrors = 0;
                                    }
                                    catch
                                    {
                                        iConsecutiveErrors++;

                                        if (iConsecutiveErrors > 5)
                                            break;

                                        continue;
                                    }

                                    iAmountBought += iAmountToBuy;
                                }

                                user_data = JObject.Parse(Game.GetGameData("user", "GetUserInfo", false));
                                this.GameVitalsUpdateUI(user_data, null, null);

                            }
                        }
                    }
                    catch { }
                }
            });
        }
        private int FindBestUserCardByName_IndexID(string name, JObject users_cards = null)
        {
            try
            {
                if (users_cards == null)
                    users_cards = this.GetUsersCards();

                string card_required_name = name;
                int card_required_level = -1;
                string card_required_evolved_skill_name = "";
                List<int> card_required_evolved_skill_IDs = null;

                if (name.Contains(":"))
                {
                    try
                    {
                        string[] card_search_parts = Utils.SubStringsDups(name, ":");

                        card_required_name = card_search_parts[0].Trim();

                        if (card_search_parts.Length == 2)
                        {
                            if (Utils.ValidNumber(card_search_parts[1]))
                            {
                                // name and level
                                card_required_level = Utils.CInt(card_search_parts[1]);
                            }
                            else
                            {
                                // name and skill
                                card_required_evolved_skill_name = card_search_parts[1].Trim();
                            }
                        }
                        else if (card_search_parts.Length >= 3)
                        {
                            if (Utils.ValidNumber(card_search_parts[1]))
                            {
                                // name, level, and skill
                                card_required_level = Utils.CInt(card_search_parts[1]);
                                card_required_evolved_skill_name = card_search_parts[2].Trim();
                            }
                            else
                            {
                                // name and skill
                                card_required_evolved_skill_name = card_search_parts[1].Trim();

                                if (Utils.ValidNumber(card_search_parts[2]))
                                {
                                    // name, skill, and level
                                    card_required_level = Utils.CInt(card_search_parts[2]);
                                }
                            }

                        }

                    }
                    catch (Exception ex)
                    {
                        Utils.DebugLogger("Couldn't parse: " + name);
                        Utils.DebugLogger(Errors.GetShortErrorDetails(ex));
                    }

                    if (Utils.ValidText(card_required_evolved_skill_name))
                    {
                        if ((card_required_evolved_skill_name.ToLower() == "none") || (card_required_evolved_skill_name.ToLower() == "n/a"))
                            card_required_evolved_skill_IDs = new List<int>(new int[] { 0 });
                        else
                            card_required_evolved_skill_IDs = new List<int>(this.GetSkillsByName(card_required_evolved_skill_name));
                    }
                }

                card_required_name = GameClient.DropLevelFromName(card_required_name);

                /*
                if (evolved_skill_IDs != null)
                {
                    Utils.LoggerNotifications("Skills matching \"" + evolved_skill_name + "\":");
                    foreach (int skill_id in evolved_skill_IDs)
                    {
                        JObject skill = this.GetSkillByID(skill_id);
                        Utils.LoggerNotifications("... " + skill["Name"].ToString());
                    }
                }
                */

                if (card_required_level == -1)
                {
                    if (!Utils.ValidText(card_required_evolved_skill_name))
                        Utils.DebugLogger("FILLING DECK: looking for card <b>" + card_required_name + "</b> at <b>best</b> level");
                    else
                        Utils.DebugLogger("FILLING DECK: looking for card <b>" + card_required_name + "</b> at <b>best</b> level with evolved skill <b>" + card_required_evolved_skill_name + "</b>");
                }
                else
                {
                    if (!Utils.ValidText(card_required_evolved_skill_name))
                        Utils.DebugLogger("FILLING DECK: looking for card <b>" + card_required_name + "</b> only at level <b>" + card_required_level.ToString() + "</b>");
                    else
                        Utils.DebugLogger("FILLING DECK: looking for card <b>" + card_required_name + "</b> only at level <b>" + card_required_level.ToString() + "</b> with evolved skill <b>" + card_required_evolved_skill_name + "</b>");
                }

                int card_required_GID = Utils.CInt(this.GetCardByName(card_required_name)["CardId"]);

                for (int Level = 15; Level > -1; Level--)
                {
                    int CurrentCardIndexID = -1;

                    if (card_required_level != -1)
                        if (Level != card_required_level)
                            continue;

                    foreach (var card in users_cards["data"]["Cards"])
                    {
                        CurrentCardIndexID++;

                        try
                        {
                            if (Utils.CInt(card["CardId"]) == card_required_GID)
                            {
                                if (Utils.CInt(card["Level"]) == Level)
                                {
                                    int iEvolvedSkillID = 0; try { if (Level >= 10) iEvolvedSkillID = Utils.CInt(card["SkillNew"]); } catch { }

                                    if ((card_required_evolved_skill_IDs == null) || (card_required_evolved_skill_IDs.Contains(iEvolvedSkillID)))
                                    {
                                        GameObjs.Card this_card = new GameObjs.Card(card);

                                        if (this_card.EvolvedSkillID == 0)
                                            Utils.DebugLogger("FILLING DECK: found card <b>" + this_card.Name + "</b> at level <b>" + this_card.Level.ToString() + "</b>");
                                        else
                                            Utils.DebugLogger("FILLING DECK: found card <b>" + this_card.Name + "</b> at level <b>" + this_card.Level.ToString() + "</b> with evolved skill <b>" + this_card.EvolvedSkill + "</b>");

                                        return CurrentCardIndexID;
                                    }
                                }
                            }
                        }
                        catch { }
                    }
                }

                return -1;
            }
            catch { }

            return -1;
        }
Example #17
0
        private void fireTokensPackToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Utils.StartMethodMultithreaded(() =>
            {
                JObject user_data = JObject.Parse(Game.GetGameData("user", "GetUserInfo", false));
                int iTickets = Utils.CInt(user_data["data"]["Ticket"]);

                JObject shop_data = JObject.Parse(Game.GetGameData("shop", "GetGoods", false));

                int iConsecutiveErrors = 0;

                JObject shop = frmMain.GetStoreType(shop_data, StoreTypes.FireTokens);
                if (shop != null)
                {
                    try
                    {
                        int iTicketCost = Utils.CInt(shop["Ticket"]);

                        string pack_name = shop["Name"].ToString();

                        if (pack_name.ToLower().EndsWith("ard")) pack_name = pack_name + "s";
                        else if (pack_name.ToLower().EndsWith("ack")) pack_name = pack_name + "s";
                        else if (pack_name.ToLower().EndsWith("oken")) pack_name = pack_name + " cards";
                        else if (pack_name.ToLower().EndsWith("oupon")) pack_name = pack_name + " cards";
                        else pack_name = pack_name + " card packs";

                        string fire_token = "Fire Token";
                        if (Game.Service == GameClient.GameService.Lies_of_Astaroth || Game.Service == GameClient.GameService.Elves_Realm)
                                fire_token = "Magic Coupon";

                        int iHowMany = Utils.CInt(Utils.Input_Text("Buy How Many", "How many " + pack_name + " would you like to buy?"));
                        if (iHowMany < 1)
                            return;

                        if (MessageBox.Show("You have " + iTickets.ToString("#,##0") + " " + Utils.Pluralize(fire_token.ToLower(), iTickets) + " and it will cost " + (iTicketCost * iHowMany).ToString("#,##0") + " to buy " + iHowMany.ToString("#,##0") + " x " + shop["Name"].ToString() + " " + Utils.Pluralize("pack", iHowMany) + ".\r\n\r\nContinue?", "Really Spend " + (iTicketCost * iHowMany).ToString("#,##0") + " " + Utils.Pluralize(fire_token, iTicketCost * iHowMany) + "?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                        {
                            for (int i = 0; i < iHowMany; i++)
                            {
                                try
                                {
                                    JObject cards_received = JObject.Parse(Game.GetGameData("shop", "Buy", "GoodsId=" + shop["GoodsId"].ToString(), false));

                                    string[] card_ids = Utils.SubStringsDups(cards_received["data"].ToString(), "_");
                                    string all_cards = "";
                                    bool bFiveStar = false;
                                    bool bEventCard = false;
                                    bool bTreasureCard = false;
                                    bool bFoodCard = false;

                                    foreach (string card_id in card_ids)
                                    {
                                        all_cards += ", [Card #" + card_id + "]";

                                        GameObjs.Card card = new GameObjs.Card(Utils.CInt(card_id));

                                        if (card.Stars == 5)
                                            bFiveStar = true;
                                        if (card.EventCard)
                                            bEventCard = true;
                                        if (card.TreasureCard)
                                            bTreasureCard = true;
                                        if (card.FoodCard)
                                            bFoodCard = true;
                                    }

                                    all_cards = all_cards.Trim(new char[] { ' ', ',' });

                                    Utils.LoggerNotifications("<color=#ffa000>You bought a " + shop["Name"].ToString() + " pack and received...</color>");
                                    Utils.LoggerNotifications("<color=#ffa000>      " + all_cards + "</color>");
                                    if (bFiveStar)
                                        Utils.LoggerNotifications("<color=#ffff40>      <b>CONGRATULATIONS</b> on your new 5★ card!</color>");
                                    if (bEventCard)
                                        Utils.LoggerNotifications("<color=#ffff40>      <b>CONGRATULATIONS</b> on your new event card!</color>");
                                    if (bTreasureCard)
                                        Utils.LoggerNotifications("<color=#ffff40>      <b>CONGRATULATIONS</b> on your new treasure card!</color>");
                                    if (bFoodCard)
                                        Utils.LoggerNotifications("<color=#ffff40>      <b>CONGRATULATIONS</b> on your new food card!</color>");

                                    iConsecutiveErrors = 0;
                                }
                                catch
                                {
                                    i--;
                                    iConsecutiveErrors++;

                                    if (iConsecutiveErrors > 5)
                                        break;
                                }
                            }

                            user_data = JObject.Parse(Game.GetGameData("user", "GetUserInfo", false));
                            this.GameVitalsUpdateUI(user_data, null, null);
                        }
                    }
                    catch { }
                }
            });
        }
Example #18
0
        private void exportAllCardsToTextFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string output_txt = "";
            string output_csv = "";

            Cursor cur = this.Cursor;
            this.Cursor = Cursors.WaitCursor;

            Utils.StartMethodMultithreadedAndWait(() =>
            {
                GameObjs.Card.RefreshCardsInDeckCache();

                JObject cards = GameClient.Current.GetUsersCards();

                output_txt += String.Format("{0, -25}  {1, -5}  {2, -12}  {3, -5}  {4, -20}  {5, -14}  {6, -14}\r\n", "Card Name", "Stars", "Element", "Level", "Evolved Skill", "Card ID", "Unique Card ID");
                output_txt += String.Format("{0, -25}  {1, -5}  {2, -12}  {3, -5}  {4, -20}  {5, -14}  {6, -14}\r\n", "-------------------------", "-----", "------------", "-----", "--------------------", "--------------", "--------------");
                output_csv += String.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\"\r\n", "Card Name", "Stars", "Element", "Level", "Evolved Skill", "Card ID", "Unique Card ID");

                foreach (var jCard in cards["data"]["Cards"])
                {
                    try
                    {
                        GameObjs.Card TempCard = new GameObjs.Card(jCard);

                        if (!TempCard.Valid) continue;
                        if (!Utils.ValidText(TempCard.Name)) continue;

                        output_txt += String.Format("{0, -25}  {1, -5}  {2, -12}  {3, -5}  {4, -20}  {5, -14}  {6, -14}\r\n", TempCard.Name, TempCard.Stars.ToString(), TempCard.ElementType.ToString(), TempCard.Level.ToString(), TempCard.EvolvedSkill, TempCard.ID_Generic.ToString(), TempCard.ID_User.ToString());
                        output_csv += String.Format("\"{0}\",{1},\"{2}\",{3},\"{4}\",{5},{6}\r\n", TempCard.Name, TempCard.Stars.ToString(), TempCard.ElementType.ToString(), TempCard.Level.ToString(), TempCard.EvolvedSkill, TempCard.ID_Generic.ToString(), TempCard.ID_User.ToString());

                    }
                    catch { }
                }

                Utils.FileOverwrite(Utils.AppFolder + @"\\Game Data\" + GameClient.GameAbbreviation(GameClient.Current.Service) + " card collection (" + Utils.GetAppSetting("Login_Account").Trim().Replace("@", ".") + ").txt", output_txt);
                Utils.FileOverwrite(Utils.AppFolder + @"\\Game Data\" + GameClient.GameAbbreviation(GameClient.Current.Service) + " card collection (" + Utils.GetAppSetting("Login_Account").Trim().Replace("@", ".") + ").csv", output_csv);
            });

            this.Cursor = cur;

            MessageBox.Show("Done exporting!", "Finished", MessageBoxButtons.OK);
        }