Beispiel #1
0
 private void manageDecksToolStripMenuItem_Click(object sender, EventArgs e)
 {
     frmSelectDeck deck_selector = new frmSelectDeck();
     deck_selector.ManageMode();
     deck_selector.StartPosition = FormStartPosition.Manual;
     deck_selector.Location = new Point(this.Location.X + (this.Width - deck_selector.Width) / 2, this.Location.Y + (this.Height - deck_selector.Height) / 2);
     deck_selector.Show();
     deck_selector.RefreshDecks();
 }
Beispiel #2
0
        private void DeckSelector(ref Button btn)
        {
            GameClient.Current.CheckLogin();
            if (GameClient.Current.opts == null)
                return;

            Cursor cur = this.Cursor;
            this.Cursor = Cursors.WaitCursor;
            frmSelectDeck SelectDeck = new frmSelectDeck();

            SelectDeck.AddDeck("None", "", "", "");

            Utils.StartMethodMultithreadedAndWait(() =>
            {
                string json = GameClient.Current.GetGameData(ref GameClient.Current.opts, "card", "GetCardGroup", false);
                GameClient.Current.GetUsersCards();
                GameClient.Current.GetUsersRunes();

                JObject decks = JObject.Parse(json);

                for (int iPass = 0; iPass <= 1; iPass++)
                {
                    int iAbsoluteDeckOrdinal = 0;
                    int iAdjustedDeckNumber = 0;

                    foreach (JObject deck in decks["data"]["Groups"])
                    {
                        iAbsoluteDeckOrdinal++;
                        if (Utils.CInt(decks["data"]["legionWarGroupId"]) != Utils.CInt(deck["GroupId"]))
                            iAdjustedDeckNumber++;
                        string deck_EKUnleashed_ID = iAdjustedDeckNumber.ToString();
                        string deck_name = iAdjustedDeckNumber.ToString() + ". Deck";
                        if (Utils.CInt(decks["data"]["legionWarGroupId"]) == Utils.CInt(deck["GroupId"]))
                        {
                            deck_EKUnleashed_ID = "KW";
                            deck_name = "Kingdom War Deck";
                        }

                        if ((iPass == 0 && deck_EKUnleashed_ID == "KW") || (iPass == 1 && deck_EKUnleashed_ID != "KW"))
                        {
                            string pretty_cards_used = "";
                            //foreach (string unique_user_card_id in Utils.SubStrings(deck["UserCardIds"].ToString(), "_"))
                            foreach (JObject card in deck["UserCardInfo"])
                            {
                                try
                                {
                                    if (Utils.CInt(card["CardId"]) > 0)
                                    {
                                        pretty_cards_used += ", " + GameClient.Current.ShortCardInfo(Utils.CInt(card["CardId"]), Utils.CInt(card["Level"]), true);
                                    }
                                }
                                catch { }
                            }
                            pretty_cards_used = pretty_cards_used.TrimStart(new char[] { ',', ' ' });

                            string pretty_runes_used = "";
                            try
                            {
                                foreach (JObject rune in deck["UserRuneInfo"])
                                {
                                    try
                                    {
                                        if (Utils.CInt(rune["RuneId"]) > 0)
                                        {
                                            pretty_runes_used += ", " + GameClient.Current.ShortRuneInfo(Utils.CInt(rune["RuneId"]), Utils.CInt(rune["Level"]), true);
                                        }
                                    }
                                    catch { }
                                }
                            }
                            catch { }

                            //foreach (string unique_user_rune_id in Utils.SubStrings(deck["UserRuneIds"].ToString(), "_"))
                            //    pretty_runes_used += ", " + this.ShortRuneInfo(unique_user_rune_id, true);
                            pretty_runes_used = pretty_runes_used.TrimStart(new char[] { ',', ' ' });

                            SelectDeck.AddDeck((iPass == 0) ? "KW" : iAdjustedDeckNumber.ToString(), deck["GroupId"].ToString(), pretty_cards_used, pretty_runes_used);
                        }
                    }
                }
            }, 15); // wait up to 15 seconds

            this.Cursor = cur;
            if (SelectDeck.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (!string.IsNullOrEmpty(SelectDeck.SelectedDeckName))
                {
                    btn.Text = SelectDeck.SelectedDeckName;

                    if (btn.Text.Trim().ToUpper().StartsWith("K"))
                        btn.Tag = "KW";
                    else if (Utils.CInt(Utils.ChopperBlank(btn.Text, " ", null)) > 0)
                        btn.Tag = Utils.CInt(Utils.ChopperBlank(btn.Text, " ", null)).ToString();
                    else
                    {
                        btn.Text = "(click to select a deck)";
                        btn.Tag = "";
                    }
                }
                else
                {
                    btn.Text = "(click to select a deck)";
                    btn.Tag = "";
                }
            }
        }