Пример #1
0
        internal bool AddDeck(Deck deck)
        {
            if (Decks.Any(d => d.ID == deck.ID))
            {
                Decks.Remove(Decks.First(d => d.ID == deck.ID));
            }

            Decks.Add(deck);

            using (StreamWriter deckFile = new StreamWriter(_deckFilePath,false))
            {
                deckFile.WriteLine("#Deck");
                deckFile.WriteLine("#ID\tPlayerID\tClassID\tName\tURL\tVersion");
                foreach (Deck thisDeck in Decks.OrderBy(d => d.ID))
                {
                    deckFile.WriteLine(thisDeck.ToString());
                }

                deckFile.Flush();
            }

            return true;
        }
Пример #2
0
        private void LoadDecks()
        {
            if (!File.Exists(_deckFilePath))
            {
                throw new ArgumentException("Cannot load Deck File.");
            }

            using (StreamReader deckFile = new StreamReader(_deckFilePath))
            {
                string deckLine;
                while ((deckLine = deckFile.ReadLine()) != null)
                {
                    if (deckLine.StartsWith("#"))
                    {
                        continue;
                    }

                    string[] deckData = deckLine.Split('\t');
                    if (deckData.Length >= 6)
                    {
                        Deck thisDeck = new Deck();
                        thisDeck.ID = int.Parse(deckData[0]);
                        thisDeck.Player = Players.First(p => p.ID == int.Parse(deckData[1]));
                        thisDeck.Class = HeroClasses.First(c => c.ID == int.Parse(deckData[2]));
                        thisDeck.Name = deckData[3];
                        thisDeck.DeckURL = deckData[4];
                        thisDeck.Version = deckData[5];

                        if (!Decks.Contains(thisDeck))
                        {
                            Decks.Add(thisDeck);
                        }
                    }
                }
            }
        }
Пример #3
0
 internal bool UpdateDeck(Deck deck)
 {
     return AddDeck(deck);
 }
Пример #4
0
        internal bool DeleteDeck(Deck deck)
        {
            if (Decks.Any(d => d.ID == deck.ID))
            {
                Decks.Remove(Decks.First(d => d.ID == deck.ID));
                return DeleteDeck(deck);
            }

            return true;
        }
Пример #5
0
 public bool UpdateDeck(Deck deck)
 {
     return _fileData.UpdateDeck(deck);
 }
Пример #6
0
 public bool DeleteDeck(Deck deck)
 {
     return _fileData.DeleteDeck(deck);
 }
Пример #7
0
 public bool AddDeck(Deck deck)
 {
     return _fileData.AddDeck(deck);
 }