示例#1
0
        public static Deck Load(string name)
        {
            StreamReader reader = null;

            try
            {
#if !LIBWINDBOT
                reader = new StreamReader(new FileStream("Decks/" + name + ".ydk", FileMode.Open, FileAccess.Read));
#else
                reader = new StreamReader(new FileStream(Path.Combine(WindBot.AssetPath, "Decks/", name + ".ydk"), FileMode.Open, FileAccess.Read));
#endif

                Deck deck = new Deck();
                bool main = true;
                bool side = false;

                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    if (line == null)
                    {
                        continue;
                    }

                    line = line.Trim();
                    if (line.Equals("#extra"))
                    {
                        main = false;
                    }
                    else if (line.StartsWith("#"))
                    {
                        continue;
                    }
                    if (line.Equals("!side"))
                    {
                        side = true;
                        continue;
                    }

                    int id;
                    if (!int.TryParse(line, out id))
                    {
                        continue;
                    }

                    deck.AddNewCard(id, main, side);
                }

                reader.Close();

                return(deck);
            }
            catch (Exception)
            {
                reader?.Close();
                return(null);
            }
        }
示例#2
0
文件: Deck.cs 项目: Zayelion/windbot
        public static Deck Load(string name)
        {
            StreamReader reader = null;
            try
            {
                reader = new StreamReader(new FileStream("Decks/" + name + ".ydk", FileMode.Open, FileAccess.Read));

                Deck deck = new Deck();
                bool side = false;

                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    if (line == null)
                        continue;

                    line = line.Trim();
                    if (line.StartsWith("#"))
                        continue;
                    if (line.Equals("!side"))
                    {
                        side = true;
                        continue;
                    }

                    int id;
                    if (!int.TryParse(line, out id))
                        continue;

                    deck.AddNewCard(id, side);
                }

                reader.Close();

                if (deck.Cards.Count > 60)
                    return null;
                if (deck.ExtraCards.Count > 15)
                    return null;
                if (deck.SideCards.Count > 15)
                    return null;

                return deck;
            }
            catch (Exception)
            {
                if (reader != null)
                    reader.Close();
                return null;
            }
        }
示例#3
0
文件: Deck.cs 项目: IMJoyJ/windbot
        public static Deck Load(string name)
        {
            StreamReader reader = null;

            try
            {
                reader = new StreamReader(new FileStream("Decks/" + name + ".ydk", FileMode.Open, FileAccess.Read));

                Deck deck = new Deck();
                bool side = false;

                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    if (line == null)
                    {
                        continue;
                    }

                    line = line.Trim();
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }

                    if (line.Equals("!side"))
                    {
                        side = true;
                        continue;
                    }

                    int id;
                    if (!int.TryParse(line, out id))
                    {
                        continue;
                    }

                    deck.AddNewCard(id, side);
                }

                reader.Close();

                if (deck.Cards.Count > 60)
                {
                    return(null);
                }

                if (deck.ExtraCards.Count > 15)
                {
                    return(null);
                }

                if (deck.SideCards.Count > 15)
                {
                    return(null);
                }

                return(deck);
            }
            catch (Exception)
            {
                reader?.Close();
                return(null);
            }
        }
示例#4
0
        ////kdiy/////////
        //public static Deck Load(string name)
        public static Deck Load(string name, string deckpath, int seed)
        ////kdiy/////////
        {
            StreamReader reader = null;
            Deck         deck   = new Deck();

            try
            {
                ////////kdiy///////
                if (name.Contains("AI_perfectdicky"))
                {
                    string path = Path.Combine(Program.AssetPath, @"..");
                    reader = new StreamReader(new FileStream(Path.Combine(path, "deck/", deckpath + ".ydk"), FileMode.Open, FileAccess.Read));
                }
                else
                {
                    ////////kdiy///////
                    reader = new StreamReader(new FileStream(Path.IsPathRooted(name) ? name : Path.Combine(Program.AssetPath, "Decks/", name + ".ydk"), FileMode.Open, FileAccess.Read));
                }

                bool main = true;
                bool side = false;

                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    if (line == null)
                    {
                        continue;
                    }

                    line = line.Trim();
                    if (line.Equals("#extra"))
                    {
                        main = false;
                    }
                    else if (line.StartsWith("#"))
                    {
                        continue;
                    }
                    if (line.Equals("!side"))
                    {
                        side = true;
                        continue;
                    }

                    int id;
                    if (!int.TryParse(line, out id))
                    {
                        continue;
                    }

                    deck.AddNewCard(id, main, side);
                }

                ////kdiy/////////
                if (name.Contains("AI_Numeron") || name.Contains("AI_Hope"))
                {
                    deck.Cards.Add(85);
                    deck.Cards.Add(86);
                }
                deck.ExtraCards.Add(111);
                if (seed == 3)
                {
                    deck.ExtraCards.Add(211);
                }
                else if (seed == 2)
                {
                    deck.ExtraCards.Add(208);
                }
                else if (seed == 1)
                {
                    deck.ExtraCards.Add(112);
                }
                ////kdiy/////////
                reader.Close();
            }
            catch (Exception)
            {
                Logger.WriteLine("Failed to load deck: " + name + ".");
                reader?.Close();
            }
            return(deck);
        }