示例#1
0
        /// <summary>
        /// Creates a new ConverterCard with the given parameters and adds it to it's ConverterCards List
        /// </summary>
        /// <param name="cardID">Octgn Guid of the Card</param>
        /// <param name="name">Octgn Name of the Card</param>
        /// <param name="multiverseID">WoTC Multiverse ID</param>
        internal void AddNewConverterCard(Guid cardID, string name, int multiverseID)
        {
            ConverterCard newConverterCard = new ConverterCard(cardID, name, this.OctgnSet.Name, multiverseID);

            this._ConverterCards.Add(newConverterCard);

            if
            (
                this._MaxMultiverseIDCard == null ||
                newConverterCard.MultiverseID > this._MaxMultiverseIDCard.MultiverseID
            )
            {
                this._MaxMultiverseIDCard = newConverterCard;
            }
        }
示例#2
0
        /// <summary>
        /// Adds the potentialCard to the PotentialOCTGNCards Collection in MultiverseID order.
        /// </summary>
        /// <param name="potentialCard">The ConverterCard to add to the PotentialOCTGNCards Collection</param>
        /// <returns>True if added, false if not</returns>
        public bool AddPotentialOCTGNCard(ConverterCard potentialCard)
        {
            if (potentialCard == null)
            {
                throw new ArgumentNullException();
            }

            if (this._PotentialOCTGNCards.Contains(potentialCard))
            {
                return(false);
            }

            if (this._PotentialOCTGNCards.Count == 0)
            {
                // Add it since it is the only item
                this._PotentialOCTGNCards.Add(potentialCard);
            }
            else if (this._PotentialOCTGNCards.Last().MultiverseID > potentialCard.MultiverseID)
            {
                // Add it at the end
                this._PotentialOCTGNCards.Add(potentialCard);
            }
            else
            {
                int index = 0;
                for (int i = 0; i < this._PotentialOCTGNCards.Count; i++)
                {
                    if (this._PotentialOCTGNCards[i].MultiverseID > potentialCard.MultiverseID)
                    {
                        break;
                    }
                    else
                    {
                        index = i;
                    }
                }

                this._PotentialOCTGNCards.Insert(index, potentialCard);
            }

            return(true);
        }
示例#3
0
        /// <summary>
        /// Sets the SelectedOCTGNCard to the ConverterCard with the highest Multiverse ID
        /// </summary>
        public void AutoSelectPotentialOCTGNCard()
        {
            if (this.PotentialOCTGNCards.Count == 0)
            {
                this.SelectedOCTGNCard = null;
            }
            else
            {
                ConverterCard maxMultiverseIDCard = this.PotentialOCTGNCards.First();
                foreach (ConverterCard cc in this.PotentialOCTGNCards)
                {
                    if (cc.MultiverseID > maxMultiverseIDCard.MultiverseID)
                    {
                        maxMultiverseIDCard = cc;
                    }
                }

                this.SelectedOCTGNCard = maxMultiverseIDCard;
            }
        }
        /// <summary>
        /// Creates a new ConverterCard with the given parameters and adds it to it's ConverterCards List
        /// </summary>
        /// <param name="cardID">Octgn Guid of the Card</param>
        /// <param name="name">Octgn Name of the Card</param>
        /// <param name="multiverseID">WoTC Multiverse ID</param>
        internal void AddNewConverterCard(Guid cardID, string name, int multiverseID)
        {
            ConverterCard newConverterCard = new ConverterCard(cardID, name, this.OctgnSet.Name, multiverseID);
            this._ConverterCards.Add(newConverterCard);

            if 
            (
                this._MaxMultiverseIDCard == null ||
                newConverterCard.MultiverseID > this._MaxMultiverseIDCard.MultiverseID
            )
            {
                this._MaxMultiverseIDCard = newConverterCard;
            }
        }
 private static void VerifyConverterCardsAreIdentical(ConverterCard converterCard, ConverterCard otherConverterCard)
 {
     Assert.AreEqual(converterCard.CardID, otherConverterCard.CardID);
     Assert.AreEqual(converterCard.MultiverseID, otherConverterCard.MultiverseID);
     Assert.AreEqual(converterCard.Name, otherConverterCard.Name);
     Assert.AreEqual(converterCard.Set, otherConverterCard.Set);
 }
 /// <summary>
 /// Removes the potentialCard from the PotentialOCTGNCards Collection
 /// </summary>
 /// <param name="potentialCard">The ConverterCard to remove from the PotentialOCTGNCards Collection</param>
 /// <returns>True if removed, false if not</returns>
 public bool RemovePotentialOCTGNCard(ConverterCard potentialCard)
 {
     return this._PotentialOCTGNCards.Remove(potentialCard);
 }
        /// <summary>
        /// Sets the SelectedOCTGNCard to the ConverterCard with the highest Multiverse ID
        /// </summary>
        public void AutoSelectPotentialOCTGNCard()
        {
            if (this.PotentialOCTGNCards.Count == 0)
            {
                this.SelectedOCTGNCard = null;
            }
            else
            {
                ConverterCard maxMultiverseIDCard = this.PotentialOCTGNCards.First();
                foreach (ConverterCard cc in this.PotentialOCTGNCards)
                {
                    if (cc.MultiverseID > maxMultiverseIDCard.MultiverseID)
                    {
                        maxMultiverseIDCard = cc;
                    }
                }

                this.SelectedOCTGNCard = maxMultiverseIDCard;
            }
        }
        /// <summary>
        /// Adds the potentialCard to the PotentialOCTGNCards Collection in MultiverseID order.
        /// </summary>
        /// <param name="potentialCard">The ConverterCard to add to the PotentialOCTGNCards Collection</param>
        /// <returns>True if added, false if not</returns>
        public bool AddPotentialOCTGNCard(ConverterCard potentialCard)
        {
            if (potentialCard == null)
            {
                throw new ArgumentNullException();
            }

            if (this._PotentialOCTGNCards.Contains(potentialCard))
            { 
                return false; 
            }

            if (this._PotentialOCTGNCards.Count == 0)
            {
                // Add it since it is the only item
                this._PotentialOCTGNCards.Add(potentialCard);
            }
            else if (this._PotentialOCTGNCards.Last().MultiverseID > potentialCard.MultiverseID)
            {
                // Add it at the end
                this._PotentialOCTGNCards.Add(potentialCard);
            }
            else
            {
                int index = 0;
                for (int i = 0; i < this._PotentialOCTGNCards.Count; i++)
                {
                    if (this._PotentialOCTGNCards[i].MultiverseID > potentialCard.MultiverseID)
                    { 
                        break; 
                    }
                    else
                    { 
                        index = i; 
                    }
                }

                this._PotentialOCTGNCards.Insert(index, potentialCard);
            }

            return true;
        }
示例#9
0
 /// <summary>
 /// Removes the potentialCard from the PotentialOCTGNCards Collection
 /// </summary>
 /// <param name="potentialCard">The ConverterCard to remove from the PotentialOCTGNCards Collection</param>
 /// <returns>True if removed, false if not</returns>
 public bool RemovePotentialOCTGNCard(ConverterCard potentialCard)
 {
     return(this._PotentialOCTGNCards.Remove(potentialCard));
 }
示例#10
0
        /// <summary>
        /// Searches through all converterSets for Cards which potentially match this CardName/CardSet.
        /// Each potential card is added as a potential Card.
        /// </summary>
        /// <param name="converterCardDictionary">
        /// A Dictionary of ConverterCards which are potential matches, where the Key is the normalized first name
        /// of the card and the value is a collection of all corresponding ConverterCards-ConverterSet tuples.  Only sets which are
        /// included in searches should be in this.</param>
        public void PopulateWithPotentialCards(Dictionary <string, List <Tuple <ConverterCard, ConverterSet> > > converterCardDictionary)//(Dictionary<Guid, ConverterSet> converterSets)
        {
            // Some cards have 2+ names, so create an array of all the names in order
            List <string> converterMappingNames =
                (from string mappingName in this.CardName.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries)
                 select ConverterMapping.NormalizeName(mappingName)).ToList();

            if (converterCardDictionary.ContainsKey(converterMappingNames.First()))
            {
                foreach (Tuple <ConverterCard, ConverterSet> converterCardAndSet in converterCardDictionary[converterMappingNames.First()])
                {
                    ConverterCard converterCard = converterCardAndSet.Item1;

                    List <string> converterCardNames =
                        (from string cardName in converterCard.Name.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries)
                         select ConverterMapping.NormalizeName(cardName)).ToList();
                    int numIndexToCompare = Math.Min(converterMappingNames.Count, converterCardNames.Count);

                    // Compare all names.  If one card has less names than the other, then just compare indexes where
                    // both names are present because sometimes another format only includes the first name
                    bool isNameMatch = true;
                    for (int i = 0; i < numIndexToCompare; i++)
                    {
                        if (!converterCardNames[i].Equals(converterMappingNames[i]))
                        {
                            isNameMatch = false;
                            break;
                        }
                    }

                    bool isSetMatch = true;
                    if (isNameMatch && !string.IsNullOrWhiteSpace(this.CardSet))
                    {
                        ConverterSet converterSet = converterCardAndSet.Item2;

                        // LoTR - Pay attention to Set
                        if (converterSet.OctgnSet.GameId == ConvertEngine.Game.LoTR.GameGuidStatic)
                        {
                            string converterCardSet    = converterCard.Set;
                            string converterMappingSet = this.CardSet;

                            // Some sources omit 'The Hobbit - ' in the set name, so remove it from the comparison
                            if (converterCardSet.StartsWith("The Hobbit", StringComparison.InvariantCultureIgnoreCase))
                            {
                                converterCardSet = converterCardSet.Substring(13);
                            }
                            if (converterMappingSet.StartsWith("The Hobbit", StringComparison.InvariantCultureIgnoreCase))
                            {
                                converterMappingSet = converterMappingSet.Substring(13);
                            }

                            // Some sources omit 'The ' in the set name, so remove it from the comparison
                            if (converterCardSet.StartsWith("The ", StringComparison.InvariantCultureIgnoreCase))
                            {
                                converterCardSet = converterCardSet.Substring(4);
                            }
                            if (converterMappingSet.StartsWith("The ", StringComparison.InvariantCultureIgnoreCase))
                            {
                                converterMappingSet = converterMappingSet.Substring(4);
                            }

                            // Remove all Diacritics from names for comparison
                            converterCardSet    = ConverterMapping.NormalizeName(converterCardSet);
                            converterMappingSet = ConverterMapping.NormalizeName(converterMappingSet);

                            if (!converterCardSet.Equals(converterMappingSet))
                            {
                                isSetMatch = false;
                            }
                        }
                    }

                    if (isNameMatch && isSetMatch)
                    {
                        this.AddPotentialOCTGNCard(converterCard);
                    }
                }
            }
        }
 /// <summary>
 /// Sets the MouseOver ConverterCard on the ViewModel based on mouse events
 /// </summary>
 /// <param name="converterCard">The ConverterCard the mouse is hovering over.  If null, then mouse is not hovering over any.</param>
 private void MouseOverConverterCard(ConverterCard converterCard)
 {
     ViewModel.WizardPage_CompareCards wizardPageCompareCards = this.DataContext as ViewModel.WizardPage_CompareCards;
     if (wizardPageCompareCards != null)
     {
         wizardPageCompareCards.MouseOverConverterCard = converterCard;
     }
 }