Exemple #1
0
        public static List <Card> LoadCollection(Account account)
        {
            List <Card> lstRet = new List <Card>();

            try
            {
                string strPath = DustUtilityPlugin.GetFullFileName(account, CollectionString);

                if (File.Exists(strPath))
                {
                    List <CachedCard> lstCachedCards = FileManager.Load <List <CachedCard> >(strPath);

                    for (int i = 0; i < lstCachedCards.Count; i++)
                    {
                        CachedCard cachedCard = lstCachedCards[i];

                        lstRet.Add(new Card(cachedCard.Id, cachedCard.Count, cachedCard.IsGolden));
                    }
                }
                else
                {
                }
            }
            catch (System.Exception ex)
            {
                Log.WriteLine($"Exception occured while loading collection: {ex}", LogType.Error);
            }

            return(lstRet);
        }
        public static List <Card> LoadCollection(Account account, string strType = CollectionString)
        {
            List <Card> lstRet = new List <Card>();

            string strPath = DustUtilityPlugin.GetFullFileName(account, strType);

            if (File.Exists(strPath))
            {
                List <CachedCard> lstCachedCards = new List <CachedCard>();

                using (StreamReader reader = new StreamReader(strPath))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(List <CachedCard>));

                    lstCachedCards = (List <CachedCard>)serializer.Deserialize(reader);
                }

                for (int i = 0; i < lstCachedCards.Count; i++)
                {
                    CachedCard cachedCard = lstCachedCards[i];

                    lstRet.Add(new Card(cachedCard.Id, cachedCard.Count, cachedCard.IsGolden));
                }
            }
            else
            {
            }

            return(lstRet);
        }
        public static bool SaveDecks(Account account)
        {
            bool blnRet = false;

            List <Deck> lstDecks = Reflection.GetDecks();

            if (lstDecks != null && (lstDecks.Count > 0 && lstDecks[0].Cards.Count > 0) && !s_blnSaveDecksInProgress)
            {
                s_blnSaveDecksInProgress = true;

                List <CachedDeck> lstCachedDecks = new List <CachedDeck>();

                for (int i = 0; i < lstDecks.Count; i++)
                {
                    Deck deck = lstDecks[i];

                    CachedDeck cachedDeck = new CachedDeck()
                    {
                        Id          = deck.Id,
                        Name        = deck.Name,
                        Hero        = deck.Hero,
                        IsWild      = deck.IsWild,
                        Type        = deck.Type,
                        SeasonId    = deck.SeasonId,
                        CardBackId  = deck.CardBackId,
                        HeroPremium = deck.HeroPremium,
                        Cards       = deck.Cards.ToCachedCards()
                    };

                    lstCachedDecks.Add(cachedDeck);
                }

                string strPath = DustUtilityPlugin.GetFullFileName(account, DecksString);

                if (File.Exists(strPath))
                {
                    File.Delete(strPath);
                }
                else
                {
                }

                using (StreamWriter writer = new StreamWriter(strPath))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(List <CachedDeck>));

                    serializer.Serialize(writer, lstCachedDecks);
                }

                blnRet = true;

                s_blnSaveDecksInProgress = false;
            }
            else
            {
            }

            return(blnRet);
        }
Exemple #4
0
        private static void SaveHistory(Account account, List <CachedCardEx> lstCardsHistory)
        {
            Log.WriteLine($"Saving history for \"{account.AccountString}\"", LogType.Debug);

            string strPath = DustUtilityPlugin.GetFullFileName(account, HistoryString);

            FileManager.Write(strPath, lstCardsHistory);
        }
Exemple #5
0
        private static List <CachedCardEx> LoadHistory(Account account)
        {
            Log.WriteLine($"Loading history for \"{account.AccountString}\"", LogType.Debug);

            string strPath = DustUtilityPlugin.GetFullFileName(account, HistoryString);

            return(FileManager.Load <List <CachedCardEx> >(strPath));
        }
        //public static bool SaveProcessSuccessful => s_blnSavedCollection && s_blnSavedDecks;
        #endregion

        #region SaveCollection
        public static bool SaveCollection(Account account, List <Card> lstCollection = null, string strType = CollectionString)
        {
            bool blnRet = false;

            if (lstCollection == null)
            {
                lstCollection = Reflection.GetCollection();
            }
            else
            {
            }

            if (lstCollection != null && lstCollection.Count > 0 && !s_blnSaveCollectionInProgress)
            {
                s_blnSaveCollectionInProgress = true;

                string strPath = DustUtilityPlugin.GetFullFileName(account, strType);

                List <CachedCard> lstCachedCards = lstCollection.ToCachedCards();

                if (File.Exists(strPath))
                {
                    File.Delete(strPath);
                }
                else
                {
                }

                using (StreamWriter writer = new StreamWriter(strPath))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(List <CachedCard>));

                    serializer.Serialize(writer, lstCachedCards);
                }

                blnRet = true;

                s_blnSaveCollectionInProgress = false;
            }
            else
            {
            }

            return(blnRet);
        }
Exemple #7
0
        public static List <Deck> LoadDecks(Account account)
        {
            List <Deck> lstRet = new List <Deck>();

            try
            {
                string strPath = DustUtilityPlugin.GetFullFileName(account, DecksString);

                if (File.Exists(strPath))
                {
                    List <CachedDeck> lstCachedDecks = FileManager.Load <List <CachedDeck> >(strPath);

                    for (int i = 0; i < lstCachedDecks.Count; i++)
                    {
                        CachedDeck cachedDeck = lstCachedDecks[i];

                        Deck deck = new Deck()
                        {
                            Id          = cachedDeck.Id,
                            Name        = cachedDeck.Name,
                            Hero        = cachedDeck.Hero,
                            IsWild      = cachedDeck.IsWild,
                            Type        = cachedDeck.Type,
                            SeasonId    = cachedDeck.SeasonId,
                            CardBackId  = cachedDeck.CardBackId,
                            HeroPremium = cachedDeck.HeroPremium,
                            Cards       = cachedDeck.Cards.ToCards()
                        };

                        lstRet.Add(deck);
                    }
                }
                else
                {
                }
            }
            catch (System.Exception ex)
            {
                Log.WriteLine($"Exception occured while loading decks: {ex}", LogType.Error);
            }

            return(lstRet);
        }
        public static List <Deck> LoadDecks(Account account)
        {
            List <Deck> lstRet = new List <Deck>();

            string strPath = DustUtilityPlugin.GetFullFileName(account, DecksString);

            if (File.Exists(strPath))
            {
                List <CachedDeck> lstCachedDecks = new List <CachedDeck>();

                using (StreamReader reader = new StreamReader(strPath))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(List <CachedDeck>));

                    lstCachedDecks = (List <CachedDeck>)serializer.Deserialize(reader);
                }

                for (int i = 0; i < lstCachedDecks.Count; i++)
                {
                    CachedDeck cachedDeck = lstCachedDecks[i];

                    Deck deck = new Deck()
                    {
                        Id          = cachedDeck.Id,
                        Name        = cachedDeck.Name,
                        Hero        = cachedDeck.Hero,
                        IsWild      = cachedDeck.IsWild,
                        Type        = cachedDeck.Type,
                        SeasonId    = cachedDeck.SeasonId,
                        CardBackId  = cachedDeck.CardBackId,
                        HeroPremium = cachedDeck.HeroPremium,
                        Cards       = cachedDeck.Cards.ToCards()
                    };

                    lstRet.Add(deck);
                }
            }
            else
            {
            }

            return(lstRet);
        }
Exemple #9
0
        private static bool SaveDecks(Account account)
        {
            bool blnRet = false;

            List <Deck> lstAllDecks = Reflection.GetDecks();

            if (lstAllDecks != null && (lstAllDecks.Count > 0 && lstAllDecks[0].Cards.Count > 0) && !s_blnSaveDecksInProgress)
            {
                s_blnSaveDecksInProgress = true;

                string strPath = DustUtilityPlugin.GetFullFileName(account, DecksString);

                List <Deck> lstDecks = new List <Deck>(lstAllDecks.Count);

                for (int i = 0; i < lstAllDecks.Count; i++)
                {
                    if (lstAllDecks[i].Type == 1)
                    {
                        lstDecks.Add(lstAllDecks[i]);
                    }
                    else
                    {
                    }
                }

                FileManager.Write(strPath, lstDecks.ToCachedDecks());

                blnRet = true;

                s_blnSaveDecksInProgress = false;
            }
            else
            {
            }

            return(blnRet);
        }
Exemple #10
0
        //public static bool SaveProcessSuccessful => s_blnSavedCollection && s_blnSavedDecks;
        #endregion

        #region SaveCollection
        private static bool SaveCollection(Account account)
        {
            bool blnRet = false;

            List <Card> lstCollection = Reflection.GetCollection();

            if (lstCollection != null && lstCollection.Count > 0 && !s_blnSaveCollectionInProgress)
            {
                s_blnSaveCollectionInProgress = true;

                string strPath = DustUtilityPlugin.GetFullFileName(account, CollectionString);

                FileManager.Write(strPath, lstCollection.ToCachedCards());

                blnRet = true;

                s_blnSaveCollectionInProgress = false;
            }
            else
            {
            }

            return(blnRet);
        }