Exemple #1
0
        private void readMulligan()
        {
            string[] lines = new string[] { };
            cardlist.Clear();
            holdDB.Clear();
            concedelist.Clear();

            string       path           = Settings.Instance.path;
            string       cleanpath      = "Silverfish" + System.IO.Path.DirectorySeparatorChar;
            string       datapath       = path + "Data" + System.IO.Path.DirectorySeparatorChar;
            string       cleandatapath  = cleanpath + "Data" + System.IO.Path.DirectorySeparatorChar;
            string       classpath      = datapath + ownClass + System.IO.Path.DirectorySeparatorChar;
            string       cleanclasspath = cleandatapath + ownClass + System.IO.Path.DirectorySeparatorChar;
            string       deckpath       = classpath + deckName + System.IO.Path.DirectorySeparatorChar;
            string       cleandeckpath  = cleanclasspath + deckName + System.IO.Path.DirectorySeparatorChar;
            const string filestring     = "_mulligan.txt";


            if (deckName != "" && System.IO.File.Exists(deckpath + filestring))
            {
                path      = deckpath;
                cleanPath = cleandeckpath + filestring;
            }
            else if (deckName != "" && System.IO.File.Exists(classpath + filestring))
            {
                path      = classpath;
                cleanPath = cleanclasspath + filestring;
            }
            else if (deckName != "" && System.IO.File.Exists(datapath + filestring))
            {
                path      = datapath;
                cleanPath = cleandatapath + filestring;
            }
            else if (System.IO.File.Exists(path + filestring))
            {
                cleanPath = cleanpath + filestring;
            }
            else
            {
                Helpfunctions.Instance.ErrorLog("[Mulligan] cant find base _mulligan.txt, consider creating one");
                return;
            }
            Helpfunctions.Instance.ErrorLog("[Mulligan] read " + cleanPath);


            try
            {
                lines = System.IO.File.ReadAllLines(path + "_mulligan.txt");
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("[Mulligan] _mulligan.txt read error. Continuing without user-defined rules.");
                return;
            }

            foreach (string line in lines)
            {
                string ln = line.Trim();
                if (ln.StartsWith("//"))
                {
                    continue;
                }
                if (ln.Length == 0)
                {
                    continue;
                }

                string entry1 = ln.Split(';')[0];
                if (entry1 == "hold" || entry1 == "discard")
                {
                    addRule(ln);
                }
                else if (entry1 == "None" || CardDB.Instance.cardIdstringToEnum(entry1) != CardDB.cardIDEnum.None)
                {
                    addHBRule(ln);
                }
                else if (entry1 == "loser")
                {
                    loserLoserLoser = true;
                    continue;
                }
                else if (entry1 == "concede:")
                {
                    try
                    {
                        string      ownh = ln.Split(':')[1];
                        concedeItem ci   = new concedeItem();
                        ci.urhero = Hrtprozis.Instance.heroNametoEnum(ownh);
                        string enemlist = ln.Split(':')[2];
                        foreach (string s in enemlist.Split(','))
                        {
                            ci.enemhero.Add(Hrtprozis.Instance.heroNametoEnum(s));
                        }
                        concedelist.Add(ci);
                    }
                    catch
                    {
                        Helpfunctions.Instance.ErrorLog("[Mulligan] cant read: " + ln);
                    }
                    continue;
                }
                else
                {
                    Helpfunctions.Instance.ErrorLog("[Mulligan] cant read: " + ln);
                }
            }

            if (cardlist.Count > 0)
            {
                Helpfunctions.Instance.ErrorLog("[Mulligan] " + cardlist.Count + " rules found");
            }
            if (concedelist.Count > 0)
            {
                Helpfunctions.Instance.ErrorLog("[Mulligan] " + concedelist.Count + " concede rules found");
            }
        }
Exemple #2
0
        private void readCombos()
        {
            string[] lines = new string[0] { };
            this.holdlist.Clear();
            this.deletelist.Clear();
            try
            {
                string path = Settings.Instance.path;
                lines = System.IO.File.ReadAllLines(path + "_mulligan.txt");
            }
            catch
            {
                Helpfunctions.Instance.logg("cant find _mulligan.txt");
                Helpfunctions.Instance.ErrorLog("cant find _mulligan.txt (if you dont created your own mulliganfile, ignore this message)");
                return;
            }
            Helpfunctions.Instance.logg("read _mulligan.txt...");
            Helpfunctions.Instance.ErrorLog("read _mulligan.txt...");
            foreach (string line in lines)
            {
                string shortline = line.Replace(" ", "");
                if (shortline.StartsWith("//")) continue;
                if (line.StartsWith("loser"))
                {
                    this.loserLoserLoser = true;
                    continue;
                }

                if (line.StartsWith("concede:"))
                {
                    try
                    {
                        string ownh = line.Split(':')[1];
                        concedeItem ci = new concedeItem();
                        ci.urhero = Hrtprozis.Instance.heroNametoEnum(ownh);
                        string enemlist = line.Split(':')[2];
                        foreach (string s in enemlist.Split(','))
                        {
                            ci.enemhero.Add(Hrtprozis.Instance.heroNametoEnum(s));
                        }
                        concedelist.Add(ci);
                    }
                    catch
                    {
                        Helpfunctions.Instance.logg("mullimaker cant read: " + line);
                        Helpfunctions.Instance.ErrorLog("mullimaker cant read: " + line);
                    }
                    continue;
                }

                if (line.StartsWith("hold;"))
                {
                    try
                    {
                        string ownclass = line.Split(';')[1];
                        string enemyclass = line.Split(';')[2];
                        string cardlist = line.Split(';')[3];

                        int coinrule = 0;
                        if (line.Split(';').Length >= 5)
                        {
                            string coin = line.Split(';')[4];
                            if (coin == "nocoin") coinrule = 1;
                            if (coin == "coin") coinrule = 2;
                        }

                        foreach (string crd in cardlist.Split(','))
                        {
                            if (crd.Contains(":"))
                            {
                                if ((crd.Split(':')).Length == 3)
                                {
                                    this.holdlist.Add(new mulliitem(line, crd.Split(':')[0], ownclass, enemyclass, Convert.ToInt32(crd.Split(':')[1]), crd.Split(':')[2].Split('/'),coinrule,-1));
                                }
                                else
                                {
                                    this.holdlist.Add(new mulliitem(line, crd.Split(':')[0], ownclass, enemyclass, Convert.ToInt32(crd.Split(':')[1]),null, coinrule,-1));
                                }

                            }
                            else
                            {
                                this.holdlist.Add(new mulliitem(line, crd, ownclass, enemyclass, 2,null,coinrule,-1));
                            }
                        }

                        

                        if (line.Split(';').Length >= 6)
                        {
                            string mr = (line.Split(';')[5]).Replace(" ", "");
                            if (mr == "") continue;
                            int manarule = Convert.ToInt32(mr);
                            if (manarule <= 0) continue;
                            Console.WriteLine("manarule "+mr); 
                            this.holdlist.Add(new mulliitem(line, "#MANARULE", ownclass, enemyclass, 2, null, coinrule, manarule));
                        }

                    }
                    catch
                    {
                        Helpfunctions.Instance.logg("mullimaker cant read: " + line);
                        Helpfunctions.Instance.ErrorLog("mullimaker cant read: " + line);
                    }
                }
                else
                {
                    if (line.StartsWith("discard;"))
                    {
                        try
                        {
                            string ownclass = line.Split(';')[1];
                            string enemyclass = line.Split(';')[2];
                            string cardlist = line.Split(';')[3];
                            int coinrule = 0;
                            if (line.Split(';').Length >= 5)
                            {
                                string coin = line.Split(';')[4];
                                if (coin == "nocoin") coinrule = 1;
                                if (coin == "coin") coinrule = 2;
                            }

                            foreach (string crd in cardlist.Split(','))
                            {
                                if (crd == null || crd == "") continue;
                                this.deletelist.Add(new mulliitem(line, crd, ownclass, enemyclass, 2,null, coinrule, -1));
                            }

                            if (line.Split(';').Length >= 6)
                            {
                                string mr = (line.Split(';')[5]).Replace(" ","");
                                if (mr == "") continue;
                                int manarule = Convert.ToInt32(mr);
                                if (manarule <= 0) continue;
                                this.deletelist.Add(new mulliitem(line, "#MANARULE", ownclass, enemyclass, 2, null, coinrule, manarule));
                            }

                        }
                        catch
                        {
                            Helpfunctions.Instance.logg("mullimaker cant read: " + line);
                            Helpfunctions.Instance.ErrorLog("mullimaker cant read: " + line);
                        }
                    }
                    else
                    {

                    }
                }

            }

        }
Exemple #3
0
        private void readCombos()
        {
            string[] lines = new string[0] {
            };
            this.holdlist.Clear();
            this.deletelist.Clear();
            try
            {
                string path = Settings.Instance.path;
                lines = System.IO.File.ReadAllLines(path + "_mulligan.txt");
            }
            catch
            {
                Helpfunctions.Instance.logg("cant find _mulligan.txt");
                Helpfunctions.Instance.ErrorLog("cant find _mulligan.txt (if you dont created your own mulliganfile, ignore this message)");
                return;
            }
            Helpfunctions.Instance.logg("read _mulligan.txt...");
            Helpfunctions.Instance.ErrorLog("read _mulligan.txt...");
            foreach (string line in lines)
            {
                if (line.StartsWith("loser"))
                {
                    this.loserLoserLoser = true;
                    continue;
                }

                if (line.StartsWith("concede:"))
                {
                    try
                    {
                        string      ownh = line.Split(':')[1];
                        concedeItem ci   = new concedeItem();
                        ci.urhero = Hrtprozis.Instance.heroNametoEnum(ownh);
                        string enemlist = line.Split(':')[2];
                        foreach (string s in enemlist.Split(','))
                        {
                            ci.enemhero.Add(Hrtprozis.Instance.heroNametoEnum(s));
                        }
                        concedelist.Add(ci);
                    }
                    catch
                    {
                        Helpfunctions.Instance.logg("mullimaker cant read: " + line);
                        Helpfunctions.Instance.ErrorLog("mullimaker cant read: " + line);
                    }
                    continue;
                }

                if (line.StartsWith("hold;"))
                {
                    try
                    {
                        string ownclass   = line.Split(';')[1];
                        string enemyclass = line.Split(';')[2];
                        string cardlist   = line.Split(';')[3];
                        foreach (string crd in cardlist.Split(','))
                        {
                            if (crd.Contains(":"))
                            {
                                if ((crd.Split(':')).Length == 3)
                                {
                                    this.holdlist.Add(new mulliitem(line, crd.Split(':')[0], ownclass, enemyclass, Convert.ToInt32(crd.Split(':')[1]), crd.Split(':')[2].Split('/')));
                                }
                                else
                                {
                                    this.holdlist.Add(new mulliitem(line, crd.Split(':')[0], ownclass, enemyclass, Convert.ToInt32(crd.Split(':')[1])));
                                }
                            }
                            else
                            {
                                this.holdlist.Add(new mulliitem(line, crd, ownclass, enemyclass, 2));
                            }
                        }

                        if (line.Split(';').Length == 5)
                        {
                            int manarule = Convert.ToInt32(line.Split(';')[4]);
                            this.holdlist.Add(new mulliitem(line, "#MANARULE", ownclass, enemyclass, 2, null, manarule));
                        }
                    }
                    catch
                    {
                        Helpfunctions.Instance.logg("mullimaker cant read: " + line);
                        Helpfunctions.Instance.ErrorLog("mullimaker cant read: " + line);
                    }
                }
                else
                {
                    if (line.StartsWith("discard;"))
                    {
                        try
                        {
                            string ownclass   = line.Split(';')[1];
                            string enemyclass = line.Split(';')[2];
                            string cardlist   = line.Split(';')[3];
                            foreach (string crd in cardlist.Split(','))
                            {
                                if (crd == null || crd == "")
                                {
                                    continue;
                                }
                                this.deletelist.Add(new mulliitem(line, crd, ownclass, enemyclass, 2));
                            }

                            if (line.Split(';').Length == 5)
                            {
                                int manarule = Convert.ToInt32(line.Split(';')[4]);
                                this.deletelist.Add(new mulliitem(line, "#MANARULE", ownclass, enemyclass, 2, null, manarule));
                            }
                        }
                        catch
                        {
                            Helpfunctions.Instance.logg("mullimaker cant read: " + line);
                            Helpfunctions.Instance.ErrorLog("mullimaker cant read: " + line);
                        }
                    }
                    else
                    {
                    }
                }
            }
        }
Exemple #4
0
        private void readCombos()
        {
            string[] lines = new string[0] { };
            this.holdlist.Clear();
            this.deletelist.Clear();
            try
            {
                string path = sf.Settings.path;
                lines = System.IO.File.ReadAllLines(path + "_mulligan.txt");
            }
            catch
            {
                sf.Helpfunctions.logg("cant find _mulligan.txt");
                sf.Helpfunctions.ErrorLog("cant find _mulligan.txt (if you dont created your own mulliganfile, ignore this message)");
                return;
            }
            sf.Helpfunctions.logg("read _mulligan.txt...");
            sf.Helpfunctions.ErrorLog("read _mulligan.txt...");
            foreach (string line in lines)
            {
                if (line.StartsWith("loser"))
                {
                    this.loserLoserLoser = true;
                    continue;
                }

                if (line.StartsWith("concede:"))
                {
                    try
                    {
                        string ownh = line.Split(':')[1];
                        concedeItem ci = new concedeItem();
                        ci.urhero = sf.Hrtprozis.heroNametoEnum(ownh);
                        string enemlist = line.Split(':')[2];
                        foreach (string s in enemlist.Split(','))
                        {
                            ci.enemhero.Add(sf.Hrtprozis.heroNametoEnum(s));
                        }
                        concedelist.Add(ci);
                    }
                    catch
                    {
                        sf.Helpfunctions.logg("mullimaker cant read: " + line);
                        sf.Helpfunctions.ErrorLog("mullimaker cant read: " + line);
                    }
                    continue;
                }

                if (line.StartsWith("hold;"))
                {
                    try
                    {
                        string ownclass = line.Split(';')[1];
                        string enemyclass = line.Split(';')[2];
                        string cardlist = line.Split(';')[3];
                        foreach (string crd in cardlist.Split(','))
                        {
                            if (crd.Contains(":"))
                            {
                                if ((crd.Split(':')).Length == 3)
                                {
                                    this.holdlist.Add(new mulliitem(line, crd.Split(':')[0], ownclass, enemyclass, Convert.ToInt32(crd.Split(':')[1]), crd.Split(':')[2].Split('/')));
                                }
                                else
                                {
                                    this.holdlist.Add(new mulliitem(line, crd.Split(':')[0], ownclass, enemyclass, Convert.ToInt32(crd.Split(':')[1])));
                                }

                            }
                            else
                            {
                                this.holdlist.Add(new mulliitem(line, crd, ownclass, enemyclass, 2));
                            }
                        }

                        if (line.Split(';').Length == 5)
                        {
                            int manarule = Convert.ToInt32(line.Split(';')[4]);
                            this.holdlist.Add(new mulliitem(line, "#MANARULE", ownclass, enemyclass, 2, null, manarule));
                        }

                    }
                    catch
                    {
                        sf.Helpfunctions.logg("mullimaker cant read: " + line);
                        sf.Helpfunctions.ErrorLog("mullimaker cant read: " + line);
                    }
                }
                else
                {
                    if (line.StartsWith("discard;"))
                    {
                        try
                        {
                            string ownclass = line.Split(';')[1];
                            string enemyclass = line.Split(';')[2];
                            string cardlist = line.Split(';')[3];
                            foreach (string crd in cardlist.Split(','))
                            {
                                if (crd == null || crd == "") continue;
                                this.deletelist.Add(new mulliitem(line, crd, ownclass, enemyclass, 2));
                            }

                            if (line.Split(';').Length == 5)
                            {
                                int manarule = Convert.ToInt32(line.Split(';')[4]);
                                this.deletelist.Add(new mulliitem(line, "#MANARULE", ownclass, enemyclass, 2, null, manarule));
                            }

                        }
                        catch
                        {
                            sf.Helpfunctions.logg("mullimaker cant read: " + line);
                            sf.Helpfunctions.ErrorLog("mullimaker cant read: " + line);
                        }
                    }
                    else
                    {

                    }
                }

            }

        }