Beispiel #1
0
        /// <summary>
        /// Creates and returns an OCTGN format Deck who's contents are the cards which were converted in the Wizard.
        /// </summary>
        /// <returns>an OCTGN format Deck who's contents are the cards which were converted in the Wizard.</returns>
        public Octgn.DataNew.Entities.Deck CreateDeck()
        {
            Octgn.DataNew.Entities.Deck deck = this.ConverterGame.Game.CreateDeck();

            Dictionary <string, Octgn.DataNew.Entities.ISection> deckSections = new Dictionary <string, Octgn.DataNew.Entities.ISection>();

            foreach (Octgn.DataNew.Entities.ISection section in deck.Sections)
            {
                deckSections.Add(section.Name, section);
            }

            foreach (ConverterSection converterSection in this.ConverterDeck.ConverterSections)
            {
                foreach (ConverterMapping converterMapping in converterSection.SectionMappings)
                {
                    if (converterMapping.SelectedOCTGNCard != null)
                    {
                        Octgn.DataNew.Entities.Card      octgnCard      = this.ConverterGame.Game.AllCards().First(c => c.Id == converterMapping.SelectedOCTGNCard.CardID);
                        Octgn.DataNew.Entities.MultiCard octgnMultiCard = octgnCard.ToMultiCard(converterMapping.Quantity);
                        deckSections[converterSection.SectionName].Cards.AddCard(octgnMultiCard);
                    }
                }
            }

            // Auto-inserting notes into the deck has been removed because it
            // is annoying when it pops up every time you load a deck.
            ////var assembly = System.Reflection.Assembly.GetExecutingAssembly();
            ////var version = assembly.GetName().Version;
            ////StringBuilder deckNotes = new StringBuilder();
            ////deckNotes.AppendLine("Imported with Splat's OCTGN Deck Converter v" + version.Major + "." + version.Minor + "." + version.Build);
            ////deckNotes.AppendLine(@"http://octgn.gamersjudgement.com/wordpress/mtg/deck-editor-plugins/");
            ////deckNotes.AppendLine();
            ////deckNotes.Append("Source: ");
            ////deckNotes.AppendLine(this.DeckSourceType.Value.ToString());

            ////switch(this.DeckSourceType.Value)
            ////{
            ////    case DeckSourceTypes.File:
            ////        deckNotes.Append("File: ");
            ////        deckNotes.AppendLine(this.DeckFullPathName);
            ////        break;

            ////    case DeckSourceTypes.Webpage:
            ////        deckNotes.Append("URL: ");
            ////        deckNotes.AppendLine(this.DeckURL);
            ////        break;
            ////}

            ////deckNotes.Append("Name: ");
            ////deckNotes.AppendLine(this.ConverterDeck.DeckName);
            ////deck.Notes = deckNotes.ToString();

            deck.Notes = string.Empty;
            return(deck);
        }
Beispiel #2
0
 internal Card(Player owner, int id, ulong key, CardDef def, DataNew.Entities.Card model, bool mySecret)
     : base(owner)
 {
     _id = id;
     Type = new CardIdentity(id) {Alias = false, Key = key, Model = model, MySecret = mySecret};
     // var _definition = def;
     All.Add(id, this);
     _alternateOf = null;
     numberOfSwitchWithAlternatesNotPerformed = 0;
     _isAlternateImage = false;
 }
        /// <summary>
        /// Returns an Image of the Octgn Card with corresponding Guid.  If there is an error (including if the Card Guid is not found)
        /// then the default back of the card is returned.
        /// </summary>
        /// <param name="cardID">The Guid of the Card to get a Bitmap picture of</param>
        /// <param name="game">The OCTGN game to find the Card from</param>
        /// <returns>The BitmapImage of the Octgn Card with corresponding Guid</returns>
        public static BitmapImage GetCardBitmapImage(Guid cardID, Octgn.DataNew.Entities.Game game)
        {
            var bim = new BitmapImage();

            bim.BeginInit();
            bim.CacheOption = BitmapCacheOption.OnLoad;

            try
            {
                Octgn.DataNew.Entities.Card octgnCard = game.AllCards().First(c => c.Id == cardID);
                bim.UriSource = new Uri(octgnCard.GetPicture());
                bim.EndInit();
            }
            catch (Exception)
            {
                bim             = new BitmapImage();
                bim.CacheOption = BitmapCacheOption.OnLoad;
                bim.BeginInit();
                bim.UriSource = new Uri(game.CardSize.Front);
                bim.EndInit();
            }

            return(bim);
        }
Beispiel #4
0
 /// <summary>
 /// Switches the underlying card model with some predefined Alternate
 /// Returns true if the model was switched (or the switch was recorded to be performed when applicable)
 /// Returns false if it did nothing.
 /// </summary>
 /// <returns></returns>
 internal bool SwitchWithAlternate()
 {
     //This function will change the underlying Model of a Card to some predefined alternate version.
     #if (DEBUG)
     Debug.WriteLine("Attempting to SwitchWithAlternate on " + Name);
     #endif
     if (_faceUp)
     {
         if (Type.Model.HasProperty("Alternate"))
         {//if there is an alternate, we want to switch to it
             if (_alternateOf == null)
             {//Switching to first alternate
                 _alternateOf = Type.Model;
     #if (DEBUG)
                 Debug.WriteLine("Switching for the first time!");
     #endif
             }
             else
             {//Not the first, not the last
     #if (DEBUG)
                 Debug.WriteLine("Not the first, not the last.");
     #endif
             }
             SetModel(Database.GetCardById(Type.Model.Alternate));
             return true;
         }
         //if there is no alternate, we might have reached the end of the chain
         else if (_alternateOf != null)
         {//Then we've come from somewhere, and we want to go back.
             SetModel(_alternateOf);
             _alternateOf = null;
     #if (DEBUG)
             Debug.WriteLine("Reached the end of the chain - Going back to the original");
     #endif
             return true;
         }
         //if we don't have a specified alternate, and we haven't come from an alternate, do nothing.
     #if (DEBUG)
         Debug.WriteLine("No Alternate, No Original - Doin' Nothin.");
     #endif
         return false;
     }
     else //if not face up
     {
         numberOfSwitchWithAlternatesNotPerformed++;//the number of switches
     #if (DEBUG)
         Debug.WriteLine("Not FaceUp. Catching the missed switch. New Number: " + numberOfSwitchWithAlternatesNotPerformed);
     #endif
         return true;
     }
 }