예제 #1
0
        /// <summary>
        /// Converts a text file that is known to match this Game into a ConverterDeck which has all ConverterMappings populated with potential cards from the converterSets
        /// </summary>
        /// <param name="fullPathName">The full path name of the Deck file to convert</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 defined, but not yet populated with potential matching OCTGN cards</returns>
        protected override ConverterDeck ConvertFile(string fullPathName, IEnumerable <string> deckSectionNames)
        {
            ConverterDeck        converterDeck = null;
            string               contents      = System.IO.File.ReadAllText(fullPathName);
            IEnumerable <string> lines         = TextConverter.SplitLines(contents);

            if (File.SpellBookBuilderText.DoesFileMatchSpellBookBuilderTextDeckFormat(lines))
            {
                File.SpellBookBuilderText spellBookBuilderTextConverter = this.CompatibleFileConverters.First() as File.SpellBookBuilderText;
                converterDeck = spellBookBuilderTextConverter.Convert(lines, deckSectionNames);
            }
            else
            {
                // The file format didn't match any known MW format, so just try the generic format
                converterDeck = MW.ConvertGenericFile(lines, deckSectionNames);
            }
            MW.AddMageStatsCard(converterDeck);
            return(converterDeck);
        }
예제 #2
0
        /// <summary>
        /// Converts a URL that is known to match this Game into a ConverterDeck which has all ConverterMappings populated with potential cards from the converterSets
        /// </summary>
        /// <param name="url">The URL of the Deck</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 defined, but not yet populated with potential matching OCTGN cards</returns>
        protected override ConverterDeck ConvertURL(string url, IEnumerable <string> deckSectionNames)
        {
            ConverterDeck converterDeck = null;

            // Try to find a pre-defined WebpageConverter to handle ConvertFile
            Webpage.WebpageConverter webpageConverter = this.FindMatchingWebpageConverter(url);

            if (webpageConverter != null)
            {
                converterDeck = webpageConverter.Convert(url, deckSectionNames, null);
            }
            else
            {
                throw new InvalidOperationException("There was a problem importing the deck from the given url, or the website has not been implemented yet");
            }

            MW.AddMageStatsCard(converterDeck);
            return(converterDeck);
        }
예제 #3
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);
        }