/// <summary>
 /// Checks if the GameGuid matches the ConverterGame Guid.  If it doesn't, an InvalidOperationException is thrown.
 /// </summary>
 /// <param name="converterGame">The ConverterGame instance to check for matching Game Guid</param>
 private void ThrowIfConverterGameDoesntMatch(ConverterGame converterGame)
 {
     if (converterGame.Game.Id != this.GameGuid)
     {
         throw new InvalidOperationException("converterGame is not the correct Game");
     }
 }
        /// <summary>
        /// Converts user input text into a ConverterDeck which has all ConverterMappings populated with potential cards from the ConverterGame
        /// </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="converterGame">The ConverterGame instance that will be used for searching for matches</param>
        /// <returns>Returns a ConverterDeck which has all ConverterMappings populated with potential cards from the converterSets</returns>
        public ConverterDeck ConvertText(Dictionary <string, string> sectionsText, ConverterGame converterGame)
        {
            this.ThrowIfConverterGameDoesntMatch(converterGame);

            ConverterDeck converterDeck = this.ConvertText(sectionsText, converterGame.Sets, converterGame.DeckSectionNames);

            return(converterDeck);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the InlineDialogPage_ChooseIncludedSetsVM class.
        /// </summary>
        /// <param name="converterGame">The ConverterGame to choose included sets from.</param>
        public InlineDialogPage_ChooseIncludedSetsVM(ConverterGame converterGame)
        {
            if (converterGame == null)
            {
                throw new ArgumentNullException("converterGame");
            }

            this._ConverterGame = converterGame;
        }
        /// <summary>
        /// Initializes a new instance of the InlineDialogPage_ChooseAnotherCardVM class.
        /// </summary>
        /// <param name="converterMapping">The Converter Mapping which contains the parsed card name to match to</param>
        /// <param name="converterGame">The Converter Game to be used when searching for another card</param>
        public InlineDialogPage_ChooseAnotherCardVM(ConverterMapping converterMapping, ConverterGame converterGame)
        {
            if (converterGame == null)
            {
                throw new ArgumentNullException("converterGame");
            }

            this._ConverterGame   = converterGame;
            this.ConverterMapping = converterMapping;
        }
        /// <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 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 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>A ConverterDeck which has all ConverterMappings populated with potential OCTGN cards from the converterSets</returns>
        public ConverterDeck ConvertFile(string fullPathName, ConverterGame converterGame)
        {
            // Try to find a pre-defined GameConverter to handle ConvertFile
            Game.GameConverter gameConverter = this.FindMatchingGameConverter(converterGame);

            if (gameConverter != null)
            {
                return gameConverter.ConvertFile(fullPathName, converterGame);
            }

            throw new NotImplementedException("Converting a File for game " + converterGame.Game.Name + " has not been implemented yet.");
        }
        /// <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 has all ConverterMappings populated with potential OCTGN cards from the converterSets</returns>
        public ConverterDeck ConvertURL(string url, ConverterGame converterGame)
        {
            Logger.Info("Converting the url " + url + " to the game " + converterGame.Game.Name);

            // Try to find a pre-defined GameConverter to handle ConvertFile
            Game.GameConverter gameConverter = this.FindMatchingGameConverter(converterGame);

            if (gameConverter != null)
            {
                return(gameConverter.ConvertURL(url, converterGame));
            }

            throw new NotImplementedException("Converting a URL for game " + converterGame.Game.Name + " has not been implemented yet.");
        }
        /// <summary>
        /// Converts user input text into a ConverterDeck which has all ConverterMappings populated with potential cards from the ConverterGame
        /// </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="converterGame">The ConverterGame instance that will be used for searching for matches</param>
        /// <returns>A ConverterDeck which has all ConverterMappings populated with potential OCTGN cards from the converterSets</returns>
        public ConverterDeck ConvertText(Dictionary <string, string> sectionsText, ConverterGame converterGame)
        {
            Logger.Info("Converting text to the game " + converterGame.Game.Name);

            // Try to find a pre-defined GameConverter to handle ConvertText
            Game.GameConverter gameConverter = this.FindMatchingGameConverter(converterGame);

            if (gameConverter != null)
            {
                return(gameConverter.ConvertText(sectionsText, converterGame));
            }
            else
            {
                return(TextConverter.ConvertText(sectionsText, converterGame.Sets, converterGame.DeckSectionNames));
            }
        }
 /// <summary>
 /// Checks if the GameGuid matches the ConverterGame Guid.  If it doesn't, an InvalidOperationException is thrown.
 /// </summary>
 /// <param name="converterGame">The ConverterGame instance to check for matching Game Guid</param>
 private void ThrowIfConverterGameDoesntMatch(ConverterGame converterGame)
 {
     if (converterGame.Game.Id != this.GameGuid)
     {
         throw new InvalidOperationException("converterGame is not the correct Game");
     }
 }
        /// <summary>
        /// Converts user input text into a ConverterDeck which has all ConverterMappings populated with potential cards from the ConverterGame
        /// </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="converterGame">The ConverterGame instance that will be used for searching for matches</param>
        /// <returns>Returns a ConverterDeck which has all ConverterMappings populated with potential cards from the converterSets</returns>
        public ConverterDeck ConvertText(Dictionary<string, string> sectionsText, ConverterGame converterGame)
        {
            this.ThrowIfConverterGameDoesntMatch(converterGame);

            ConverterDeck converterDeck = this.ConvertText(sectionsText, converterGame.Sets, converterGame.DeckSectionNames);
            
            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;
        }
 public Game.GameConverter FindMatchingGameConverter(ConverterGame converterGame)
 {
     return(this.gameConverters.FirstOrDefault(gc => gc.GameGuid == converterGame.Game.Id));
 }
 public Game.GameConverter FindMatchingGameConverter(ConverterGame converterGame)
 {
     return this.gameConverters.FirstOrDefault(gc => gc.GameGuid == converterGame.Game.Id);
 }
        /// <summary>
        /// Converts user input text into a ConverterDeck which has all ConverterMappings populated with potential cards from the ConverterGame
        /// </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="converterGame">The ConverterGame instance that will be used for searching for matches</param>
        /// <returns>A ConverterDeck which has all ConverterMappings populated with potential OCTGN cards from the converterSets</returns>
        public ConverterDeck ConvertText(Dictionary<string, string> sectionsText, ConverterGame converterGame)
        {
            // Try to find a pre-defined GameConverter to handle ConvertText
            Game.GameConverter gameConverter = this.FindMatchingGameConverter(converterGame);

            if (gameConverter != null)
            {
                return gameConverter.ConvertText(sectionsText, converterGame);
            }
            else
            {
                return TextConverter.ConvertText(sectionsText, converterGame.Sets, converterGame.DeckSectionNames);
            }
        }