コード例 #1
0
        public void TestReserialize()
        {
            var deck         = DeckSerializer.Deserialize(DeckString);
            var reserialized = DeckSerializer.Serialize(deck, false);

            Assert.AreEqual(DeckString, reserialized);
        }
コード例 #2
0
        public static void SavePlayerCreatedDecksToFile()
        {
            List <string> deckStrings = CurrentDecks.Select(x => DeckSerializer.Serialize(x, true)).ToList();
            string        path        = Path.Combine(Config.SavedDataFolder(), Config.SavedDecksFile());

            File.WriteAllLines(path, deckStrings);

            Log.Info("Successfully saved player created decks to file.");
        }
コード例 #3
0
        public void DeserializeWithComments()
        {
            var deck = DeckSerializer.Deserialize(FullDeckString);

            Assert.AreEqual("Warrior123", deck.Name);
            Assert.AreEqual(30, deck.GetCards().Values.Sum());
            var serialized = DeckSerializer.Serialize(deck, false);

            Assert.AreEqual(DeckString, serialized);
        }
コード例 #4
0
        public void TestSerializerCommentsDefaults()
        {
            var deck = DeckSerializer.Deserialize(DeckString);

            var commented = DeckSerializer.Serialize(deck, true);
            var lines     = commented.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            Assert.AreEqual("### Warrior Deck", lines[0]);
            Assert.AreEqual("# Class: Warrior", lines[1]);
            Assert.AreEqual("# Format: Standard", lines[2]);
        }
コード例 #5
0
        public void TestSerializerComments()
        {
            var deck = DeckSerializer.Deserialize(DeckString);

            deck.Name       = "Warrior123";
            deck.ZodiacYear = ZodiacYear.MAMMOTH;

            var commented = DeckSerializer.Serialize(deck, true);
            var lines     = commented.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            Assert.AreEqual("### Warrior123", lines[0]);
            Assert.AreEqual("# Class: Warrior", lines[1]);
            Assert.AreEqual("# Format: Standard", lines[2]);
            Assert.AreEqual("# Year of the Mammoth", lines[3]);
        }
コード例 #6
0
ファイル: Deck.cs プロジェクト: becelot/dh-hdt-client
        /// <summary>
        /// Generates a deckcode for the deck that was last played during the game
        /// </summary>
        /// <returns></returns>
        public string GenerateDeckCode()
        {
            // Extract deckcode
            string deckcode;

            try
            {
                deckcode = DeckSerializer.Serialize(this, false);
            }
            catch (Exception exc)
            {
                Log.Error(exc);
                throw new Exception("Exception while serializing played deck");
            }

            // And return it
            Hearthstone_Deck_Tracker.Utility.Logging.Log.Info(deckcode);
            return(deckcode);
        }