/// <summary>
        /// Loads and displays all cards of a given type from file / stored manual input.
        /// </summary>
        /// <param name="type"></param>
        private void LoadAndDisplay(InvestigatorCardType type)
        {
            try
            {
                IEnumerable <InvestigatorCard> cards;

                switch (type)
                {
                case InvestigatorCardType.Artifact:
                    cards = HTMLReader.GetArtifacts();
                    break;

                case InvestigatorCardType.Asset:
                    cards = HTMLReader.GetAssets();
                    break;

                case InvestigatorCardType.Spell:
                    cards = HTMLReader.GetSpells();
                    break;

                case InvestigatorCardType.Condition:
                    cards = HTMLReader.GetConditions();
                    break;

                case InvestigatorCardType.UniqueAsset:
                    cards = UniqueAssetsManual.GetAllUniqueAssets();
                    break;

                default:
                    throw new Exception("Type not handled: " + type);
                }

                MessageBox.Show(string.Format("{0} cards loaded.", cards.Count()));

                DataTable table = new DataTable("cardsTable");
                table.Columns.Add(new DataColumn("Name"));
                table.Columns.Add(new DataColumn("Traits"));
                table.Columns.Add(new DataColumn("Expansion"));

                foreach (InvestigatorCard card in cards)
                {
                    DataRow row = table.NewRow();
                    row.SetField("Name", card.Name);
                    row.SetField("Traits", string.Join(", ", card.Traits));
                    row.SetField("Expansion", card.Expansion.ToString());
                    table.Rows.Add(row);
                }

                CardDataGrid.DataSource = table;
                CardDataGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n---\n" + ex.StackTrace);
            }
        }
Exemple #2
0
        /// <summary>
        /// Loads cards from source files and manual input in memory.
        /// </summary>
        /// <returns></returns>
        public static CardCollection LoadFromSources()
        {
            CardCollection coll = new CardCollection();

            coll.InDeck.AddRange(HTMLReader.GetArtifacts());
            coll.InDeck.AddRange(HTMLReader.GetAssets());
            coll.InDeck.AddRange(HTMLReader.GetConditions());
            coll.InDeck.AddRange(HTMLReader.GetSpells());
            coll.InDeck.AddRange(UniqueAssetsManual.GetAllUniqueAssets());

            Quantifier.Quantify(coll.InDeck);

            foreach (InvestigatorCard card in coll.InDeck)
            {
                coll.Discards.Add(card, 0);
            }

            return(coll);
        }