/// <summary>
        /// Converts a text file into a ConverterDeck which has all ConverterMappings populated with potential cards from the ConverterGame
        /// </summary>
        /// <param name="fullPathName">The full path name of the Deck file to convert</param>
        /// <param name="converterGame">The ConverterGame instance that will be used for searching for matches</param>
        /// <returns>Returns a ConverterDeck which has all ConverterMappings populated with potential OCTGN cards from the converterSets</returns>
        public ConverterDeck ConvertFile(string fullPathName, ConverterGame converterGame)
        {
            this.ThrowIfConverterGameDoesntMatch(converterGame);

            ConverterDeck converterDeck = this.ConvertFile(fullPathName, converterGame.DeckSectionNames);

            converterDeck.PopulateConverterMappings(converterGame.Sets);

            return(converterDeck);
        }
        /// <summary>
        /// Converts a URL into a ConverterDeck which has all ConverterMappings populated with potential cards from the ConverterGame
        /// </summary>
        /// <param name="url">The URL of the Deck</param>
        /// <param name="converterGame">The ConverterGame instance that will be used for searching for matches</param>
        /// <returns>A ConverterDeck which represents the data that is converted using the contents of the file</returns>
        public ConverterDeck ConvertURL(string url, ConverterGame converterGame)
        {
            this.ThrowIfConverterGameDoesntMatch(converterGame);

            ConverterDeck converterDeck = this.ConvertURL(url, converterGame.DeckSectionNames);

            converterDeck.PopulateConverterMappings(converterGame.Sets);

            return(converterDeck);
        }
        /// <summary>
        /// Converts user input text into a ConverterDeck which has all ConverterMappings populated with potential cards from the converterSets
        /// </summary>
        /// <param name="sectionsText">A collection of section names (keys), and the user input text of all cards in the section (values)</param>
        /// <param name="converterSets">List of all ConverterSets. Only those with flag IncludeInSearches will be used.</param>
        /// <param name="deckSectionNames">List of the name of each section for the deck being converted.</param>
        /// <returns>Returns a ConverterDeck which has all ConverterMappings populated with potential cards from the converterSets</returns>
        public static ConverterDeck ConvertText(Dictionary <string, string> sectionsText, Dictionary <Guid, ConverterSet> converterSets, IEnumerable <string> deckSectionNames)
        {
            Dictionary <string, IEnumerable <string> > sectionsLines = new Dictionary <string, IEnumerable <string> >();

            // Key = Section Name
            // Value = Section card lines as a blob of text
            foreach (KeyValuePair <string, string> section in sectionsText)
            {
                sectionsLines.Add(section.Key, TextConverter.SplitLines(section.Value));
            }

            ConverterDeck converterDeck = TextConverter.ConvertDeckWithSeparateSections(sectionsLines, deckSectionNames);

            converterDeck.PopulateConverterMappings(converterSets);
            return(converterDeck);
        }
Esempio n. 4
0
        /// <summary>
        /// Converts user input text that is known to match this Game into a ConverterDeck which has all ConverterMappings populated with potential cards from the converterSets
        /// </summary>
        /// <param name="sectionsText">A collection of section names (keys), and the user input text of all cards in the section (values)</param>
        /// <param name="converterSets">List of all ConverterSets. Only those with flag IncludeInSearches will be used.</param>
        /// <param name="deckSectionNames">List of the name of each section for the deck being converted.</param>
        /// <returns>Returns a ConverterDeck which has all ConverterMappings populated with potential cards from the converterSets</returns>
        protected override ConverterDeck ConvertText(Dictionary <string, string> sectionsText, Dictionary <Guid, ConverterSet> converterSets, IEnumerable <string> deckSectionNames)
        {
            ConverterDeck converterDeck = null;

            // If the text is in SpellBookBuilderText format, convert it with that.  Otherwise, convert using normal text format
            IEnumerable <string> lines = sectionsText.SelectMany(st => TextConverter.SplitLines(st.Value));

            if (File.SpellBookBuilderText.DoesFileMatchSpellBookBuilderTextDeckFormat(lines))
            {
                File.SpellBookBuilderText spellBookBuilderTextConverter = this.CompatibleFileConverters.First() as File.SpellBookBuilderText;
                converterDeck = spellBookBuilderTextConverter.Convert(lines, deckSectionNames);
                converterDeck.PopulateConverterMappings(converterSets);
            }
            else
            {
                converterDeck = TextConverter.ConvertText(sectionsText, converterSets, deckSectionNames);
            }

            MW.AddMageStatsCard(converterDeck);
            return(converterDeck);
        }