예제 #1
0
        public void ReadCombos(string behavName, bool nameIsPath = false)
        {
            string pathToCombo = behavName;

            if (!nameIsPath)
            {
                if (!SilverFishBot.Instance.BehaviorPath.ContainsKey(behavName))
                {
                    help.ErrorLog(behavName + ": no special combos.");
                    return;
                }
                pathToCombo = Path.Combine(SilverFishBot.Instance.BehaviorPath[behavName], "_combo.txt");
            }

            if (!File.Exists(pathToCombo))
            {
                help.InfoLog(behavName + ": no special combos.");
                return;
            }

            help.InfoLog($"[Combo] Load combos for {behavName}");
            string[] lines = new string[0] {
            };
            combos.Clear();
            playByValue.Clear();
            try
            {
                lines = File.ReadAllLines(pathToCombo);
            }
            catch (Exception ex)
            {
                LogHelper.WriteCombatLog("cant find _combo.txt");
                help.ErrorLog(ex);
                help.ErrorLog("cant find _combo.txt (if you don't created your own combos, ignore this message)");
                return;
            }
            help.InfoLog("read _combo.txt...");
            foreach (string line in lines)
            {
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }
                if (line.StartsWith("//"))
                {
                    continue;
                }
                if (line.Contains("weapon:"))
                {
                    try
                    {
                        this.attackFaceHP = Convert.ToInt32(line.Replace("weapon:", ""));
                    }
                    catch (Exception ex)
                    {
                        LogHelper.WriteCombatLog("combomaker cant read: " + line);
                        help.ErrorLog(ex);
                        help.ErrorLog("combomaker cant read: " + line);
                    }
                }
                else
                {
                    if (line.Contains("cardvalue:"))
                    {
                        try
                        {
                            string            cardvalue = line.Replace("cardvalue:", "");
                            CardDB.cardIDEnum ce        = cdb.cardIdstringToEnum(cardvalue.Split(',')[0]);
                            int val = Convert.ToInt32(cardvalue.Split(',')[1]);
                            if (this.playByValue.ContainsKey(ce))
                            {
                                continue;
                            }
                            this.playByValue.Add(ce, val);
                            //help.ErrorLog("adding: " + line);
                        }
                        catch (Exception ex)
                        {
                            LogHelper.WriteCombatLog("combomaker cant read: " + line);
                            help.ErrorLog(ex);
                            help.ErrorLog("combomaker cant read: " + line);
                        }
                    }
                    else
                    {
                        try
                        {
                            combo c = new combo(line);
                            this.combos.Add(c);
                        }
                        catch (Exception ex)
                        {
                            LogHelper.WriteCombatLog("combomaker cant read: " + line);
                            help.ErrorLog(ex);
                            help.ErrorLog("combomaker cant read: " + line);
                        }
                    }
                }
            }
            help.InfoLog("[Combo] " + combos.Count + " combos loaded successfully, " + playByValue.Count + " values loaded successfully");
        }