Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        private InterpreterAction getInterpreterAction(string str)
        {
            if (str == null)
            {
                return(InterpreterAction.NULL);
            }

            InterpreterAction action = InterpreterAction.NULL;

            if (!interpreterActionCache.TryGetValue(str, out action))
            {
                if (!Enum.TryParse <InterpreterAction>(str.Replace("[", "").Replace("]", ""), out action))
                {
                    interpreterActionCache.Add(str, action);
                    return(InterpreterAction.NULL);
                }
                interpreterActionCache.Add(str, action);
            }

            return(action);
            //foreach (InterpreterAction action in Enum.GetValues(typeof(InterpreterAction)))
            //    if (str.IndexOf(action.ToString()) != -1)
            //        return action;
            //return InterpreterAction.NULL;
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pickUp"></param>
        /// <param name="validRule"></param>
        /// <param name="action"></param>
        private void logOut(ItemEvaluationType evaluationType, string validRule, InterpreterAction action)
        {
            // return if we have a evaluationtype sell or salvage
            if (evaluationType == ItemEvaluationType.Salvage || evaluationType == ItemEvaluationType.Sell)
            {
                return;
            }

            string logString = getFullItem() + validRule;

            TrinityItemQuality quality = getTrinityItemQualityFromString(itemDic["[QUALITY]"]);

            switch (action)
            {
            case InterpreterAction.PICKUP:
                if (quality >= logPickQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;

            case InterpreterAction.IGNORE:
                if (quality >= logPickQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;

            case InterpreterAction.KEEP:
                if (quality >= logKeepQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;

            case InterpreterAction.TRASH:
                if (quality >= logKeepQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;

            case InterpreterAction.SCORE:
                if (quality >= logKeepQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;

            case InterpreterAction.NULL:
                if (quality >= logPickQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;
            }
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="str"></param>
        /// <param name="logType"></param>
        public void logOut(string str, InterpreterAction action, LogType logType)
        {
            // no debugging when flag set false
            if (logType == LogType.DEBUG && !Trinity.Settings.Loot.ItemRules.Debug)
            {
                return;
            }

            if (!Trinity.Settings.Advanced.ItemRulesLogs)
            {
                return;
            }

            if (!Directory.Exists(Path.GetDirectoryName(FileManager.LoggingPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(FileManager.LoggingPath));
            }

            string filePath = string.Empty;

            switch (action)
            {
            case InterpreterAction.PICKUP:
            case InterpreterAction.IGNORE:
                filePath = Path.Combine(FileManager.LoggingPath, PickLogFile);
                log      = new StreamWriter(filePath, true);
                break;

            case InterpreterAction.IDENTIFY:
            case InterpreterAction.UNIDENT:
                filePath = Path.Combine(FileManager.LoggingPath, RestLogFile);
                log      = new StreamWriter(filePath, true);
                break;

            case InterpreterAction.KEEP:
            case InterpreterAction.TRASH:
            case InterpreterAction.SCORE:
                filePath = Path.Combine(FileManager.LoggingPath, KeepLogFile);
                log      = new StreamWriter(filePath, true);
                break;

            case InterpreterAction.SALVAGE:
            case InterpreterAction.SELL:
                filePath = Path.Combine(FileManager.LoggingPath, RestLogFile);
                log      = new StreamWriter(filePath, true);
                break;

            case InterpreterAction.NULL:
                filePath = Path.Combine(FileManager.LoggingPath, BugsLogFile);
                log      = new StreamWriter(filePath, true);
                break;
            }

            log.WriteLine(DateTime.UtcNow.ToString("yyyyMMddHHmmssffff") + ".Hero" + SEP + logType + SEP + action + SEP + str);
            log.Close();
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public InterpreterAction checkUnidStashItem(ACDItem item)
        {
            fillDic(item);

            InterpreterAction action = InterpreterAction.NULL;

            string validRule = "";

            ArrayList rules;

            rules = unidKeepRuleSet;

            foreach (string str in rules)
            {
                ParseErrors parseErrors = null;

                // default configuration for positive rules is pickup and keep
                InterpreterAction tempAction = InterpreterAction.KEEP;


                string[] strings = str.Split(new string[] { assign }, StringSplitOptions.None);
                if (strings.Count() > 1)
                {
                    tempAction = getInterpreterAction(strings[1]);
                }

                try
                {
                    if (evaluate(strings[0], out parseErrors))
                    {
                        validRule = str;
                        action    = tempAction;
                        if (parseErrors.Count > 0)
                        {
                            logOut("Have errors with out a catch!"
                                   + SEP + "last use rule: " + str
                                   + SEP + getParseErrors(parseErrors)
                                   + SEP + getFullItem(), tempAction, LogType.DEBUG);
                        }
                        break;
                    }
                } catch (Exception e)
                {
                    logOut(e.Message
                           + SEP + "last use rule: " + str
                           + SEP + getParseErrors(parseErrors)
                           + SEP + getFullItem(), tempAction, LogType.ERROR);
                }
            }

            //logOut(ItemEvaluationType.Salvage, validRule, action);

            return(action);
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="str"></param>
        /// <param name="logType"></param>
        public void logOut(string str, InterpreterAction action, LogType logType)
        {
            // no debugging when flag set false
            if (logType == LogType.DEBUG && !Bot.Settings.ItemRules.ItemRuleDebug)
            {
                return;
            }

            //if (!GilesTrinity.Settings.Advanced.ItemRulesLogs)
            //return;

            log = new StreamWriter(Path.Combine(logPath, logFile), true);
            log.WriteLine(DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".Hero" + SEP + logType + SEP + action + SEP + str);
            log.Close();
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="str"></param>
        /// <param name="logType"></param>
        public void logOut(string str, InterpreterAction action, LogType logType)
        {
            // no debugging when flag set false
            if (logType == LogType.DEBUG && !FunkyTownRunPlugin.PluginSettings.ItemRuleDebug)
            {
                return;
            }

            string filePath = string.Empty;

            switch (action)
            {
            case InterpreterAction.PICKUP:
            case InterpreterAction.IGNORE:
                filePath = Path.Combine(FolderPaths.LoggingFolderPath, PickLogFile);
                log      = new StreamWriter(filePath, true);
                break;

            case InterpreterAction.IDENTIFY:
            case InterpreterAction.UNIDENT:
                filePath = Path.Combine(FolderPaths.LoggingFolderPath, RestLogFile);
                log      = new StreamWriter(filePath, true);
                break;

            case InterpreterAction.KEEP:
            case InterpreterAction.TRASH:
            case InterpreterAction.SCORE:
                filePath = Path.Combine(FolderPaths.LoggingFolderPath, KeepLogFile);
                log      = new StreamWriter(filePath, true);
                break;

            case InterpreterAction.SALVAGE:
            case InterpreterAction.SELL:
                filePath = Path.Combine(FolderPaths.LoggingFolderPath, RestLogFile);
                log      = new StreamWriter(filePath, true);
                break;

            case InterpreterAction.NULL:
                filePath = Path.Combine(FolderPaths.LoggingFolderPath, BugsLogFile);
                log      = new StreamWriter(filePath, true);
                break;
            }

            log.WriteLine(DateTime.UtcNow.ToString("yyyyMMddHHmmssffff") + ".Hero" + SEP + logType + SEP + action + SEP + str);
            log.Close();
        }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pickUp"></param>
        /// <param name="validRule"></param>
        /// <param name="action"></param>
        private void logOut(ItemEvaluationType evaluationType, string validRule, InterpreterAction action)
        {
            string logString = getFullItem() + validRule;

            TrinityItemQuality quality = TrinityItemQuality.Unknown;

            if (itemDic.ContainsKey("[QUALITY]"))
            {
                quality = getTrinityItemQualityFromString(itemDic["[QUALITY]"]);
            }

            switch (action)
            {
            case InterpreterAction.PICKUP:
                if (quality >= logPickQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;

            case InterpreterAction.IGNORE:
                if (quality >= logPickQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;

            case InterpreterAction.IDENTIFY:
                //if (quality >= logPickQuality)
                //    logOut(logString, action, LogType.LOG);
                break;

            case InterpreterAction.UNIDENT:
                if (quality >= logPickQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;

            case InterpreterAction.KEEP:
                if (quality >= logKeepQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;

            case InterpreterAction.TRASH:
                if (quality >= logKeepQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;

            case InterpreterAction.SCORE:
                if (quality >= logKeepQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;

            case InterpreterAction.SALVAGE:
                //if (quality >= logKeepQuality)
                //    logOut(logString, action, LogType.LOG);
                break;

            case InterpreterAction.SELL:
                //if (quality >= logKeepQuality)
                //    logOut(logString, action, LogType.LOG);
                break;

            case InterpreterAction.NULL:
                if (quality >= logPickQuality)
                {
                    logOut(logString, action, LogType.LOG);
                }
                break;
            }
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public InterpreterAction checkItem(ItemEvaluationType evaluationType)
        {
            InterpreterAction action        = InterpreterAction.NULL;
            InterpreterAction defaultAction = InterpreterAction.NULL;

            string validRule = "";

            ArrayList rules = null;

            switch (evaluationType)
            {
            case ItemEvaluationType.PickUp:
                defaultAction = InterpreterAction.PICKUP;
                rules         = pickUpRuleSet;
                break;

            case ItemEvaluationType.Sell:
                defaultAction = InterpreterAction.IDENTIFY;
                rules         = identifyRuleSet;
                break;

            case ItemEvaluationType.Keep:
                defaultAction = InterpreterAction.KEEP;
                rules         = keepRuleSet;
                break;

            case ItemEvaluationType.Salvage:
                defaultAction = InterpreterAction.SALVAGE;
                rules         = salvageSellRuleSet;
                break;

            default:
                defaultAction = InterpreterAction.NULL;
                rules         = null;
                break;
            }

            foreach (string str in rules)
            {
                ParseErrors parseErrors = null;

                InterpreterAction tempAction = defaultAction;

                string[] strings = str.Split(new string[] { assign }, StringSplitOptions.None);
                if (strings.Count() > 1)
                {
                    tempAction = getInterpreterAction(strings[1]);
                }
                try
                {
                    if (evaluate(strings[0], out parseErrors))
                    {
                        validRule = str;
                        action    = tempAction;
                        if (parseErrors.Count > 0)
                        {
                            logOut("Have errors with out a catch!"
                                   + SEP + "last use rule: " + str
                                   + SEP + getParseErrors(parseErrors)
                                   + SEP + getFullItem(), InterpreterAction.NULL, LogType.ERROR);
                        }
                        break;
                    }
                }
                catch (Exception e)
                {
                    logOut(e.Message
                           + SEP + "last use rule: " + str
                           + SEP + getParseErrors(parseErrors)
                           + SEP + getFullItem()
                           + SEP + e.ToString()
                           , InterpreterAction.NULL, LogType.ERROR);
                }
            }

            logOut(evaluationType, validRule, action);

            return(action);
        }
Beispiel #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="str"></param>
        /// <param name="logType"></param>
        public void logOut(string str, InterpreterAction action, LogType logType)
        {
            // no debugging when flag set false
            if (logType == LogType.DEBUG && !Trinity.Settings.Loot.ItemRules.Debug)
                return;

            if (!Trinity.Settings.Advanced.ItemRulesLogs)
                return;

            if (!Directory.Exists(Path.GetDirectoryName(FileManager.LoggingPath)))
                Directory.CreateDirectory(Path.GetDirectoryName(FileManager.LoggingPath));

            string filePath = string.Empty;
            switch (action)
            {
                case InterpreterAction.PICKUP:
                case InterpreterAction.IGNORE:
                    filePath = Path.Combine(FileManager.LoggingPath, PickLogFile);
                    log = new StreamWriter(filePath, true);
                    break;
                case InterpreterAction.IDENTIFY:
                case InterpreterAction.UNIDENT:
                    filePath = Path.Combine(FileManager.LoggingPath, RestLogFile);
                    log = new StreamWriter(filePath, true);
                    break;
                case InterpreterAction.KEEP:
                case InterpreterAction.TRASH:
                case InterpreterAction.SCORE:
                    filePath = Path.Combine(FileManager.LoggingPath, KeepLogFile);
                    log = new StreamWriter(filePath, true);
                    break;
                case InterpreterAction.SALVAGE:
                case InterpreterAction.SELL:
                    filePath = Path.Combine(FileManager.LoggingPath, RestLogFile);
                    log = new StreamWriter(filePath, true);
                    break;
                case InterpreterAction.NULL:
                    filePath = Path.Combine(FileManager.LoggingPath, BugsLogFile);
                    log = new StreamWriter(filePath, true);
                    break;
            }

            log.WriteLine(DateTime.UtcNow.ToString("yyyyMMddHHmmssffff") + ".Hero" + SEP + logType + SEP + action + SEP + str);
            log.Close();
        }
Beispiel #10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pickUp"></param>
        /// <param name="validRule"></param>
        /// <param name="action"></param>
        private void logOut(ItemEvaluationType evaluationType, string validRule, InterpreterAction action)
        {

            string logString = getFullItem() + validRule;

            TrinityItemQuality quality = TrinityItemQuality.Unknown;

            if (itemDic.ContainsKey("[QUALITY]"))
                quality = getTrinityItemQualityFromString(itemDic["[QUALITY]"]);

            switch (action)
            {
                case InterpreterAction.PICKUP:
                    if (quality >= logPickQuality)
                        logOut(logString, action, LogType.LOG);
                    break;
                case InterpreterAction.IGNORE:
                    if (quality >= logPickQuality)
                        logOut(logString, action, LogType.LOG);
                    break;
                case InterpreterAction.IDENTIFY:
                    //if (quality >= logPickQuality)
                    //    logOut(logString, action, LogType.LOG);
                    break;
                case InterpreterAction.UNIDENT:
                    if (quality >= logPickQuality)
                        logOut(logString, action, LogType.LOG);
                    break;
                case InterpreterAction.KEEP:
                    if (quality >= logKeepQuality)
                        logOut(logString, action, LogType.LOG);
                    break;
                case InterpreterAction.TRASH:
                    if (quality >= logKeepQuality)
                        logOut(logString, action, LogType.LOG);
                    break;
                case InterpreterAction.SCORE:
                    if (quality >= logKeepQuality)
                        logOut(logString, action, LogType.LOG);
                    break;
                case InterpreterAction.SALVAGE:
                    //if (quality >= logKeepQuality)
                    //    logOut(logString, action, LogType.LOG);
                    break;
                case InterpreterAction.SELL:
                    //if (quality >= logKeepQuality)
                    //    logOut(logString, action, LogType.LOG);
                    break;
                case InterpreterAction.NULL:
                    if (quality >= logPickQuality)
                        logOut(logString, action, LogType.LOG);
                    break;
            }
        }
Beispiel #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public InterpreterAction checkItem(ItemEvaluationType evaluationType)
        {
            InterpreterAction action = InterpreterAction.NULL;

            string validRule = "";

            ArrayList rules;

            if (evaluationType == ItemEvaluationType.PickUp)
            {
                rules = pickUpRuleSet;
            }
            else
            {
                rules = ruleSet;
            }

            foreach (string str in rules)
            {
                ParseErrors parseErrors = null;

                // default configuration for positive rules is pickup and keep
                InterpreterAction tempAction;
                if (evaluationType == ItemEvaluationType.PickUp)
                {
                    tempAction = InterpreterAction.PICKUP;
                }
                else
                {
                    tempAction = InterpreterAction.KEEP;
                }

                string[] strings = str.Split(new string[] { assign }, StringSplitOptions.None);
                if (strings.Count() > 1)
                {
                    tempAction = getInterpreterAction(strings[1]);
                }

                try
                {
                    if (evaluate(strings[0], out parseErrors))
                    {
                        validRule = str;
                        action    = tempAction;
                        if (parseErrors.Count > 0)
                        {
                            logOut("Have errors with out a catch!"
                                   + SEP + "last use rule: " + str
                                   + SEP + getParseErrors(parseErrors)
                                   + SEP + getFullItem(), InterpreterAction.NULL, LogType.ERROR);
                        }
                        break;
                    }
                } catch (Exception e)
                {
                    logOut(e.Message
                           + SEP + "last use rule: " + str
                           + SEP + getParseErrors(parseErrors)
                           + SEP + getFullItem(), InterpreterAction.NULL, LogType.ERROR);
                }
            }

            logOut(evaluationType, validRule, action);

            return(action);
        }
Beispiel #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pickUp"></param>
        /// <param name="validRule"></param>
        /// <param name="action"></param>
        private void logOut(ItemEvaluationType evaluationType, string validRule, InterpreterAction action)
        {
            // return if we have a evaluationtype sell or salvage
                if (evaluationType==ItemEvaluationType.Salvage||evaluationType==ItemEvaluationType.Sell)
                     return;

                string logString=getFullItem()+validRule;

                TrinityItemQuality quality=getTrinityItemQualityFromString(itemDic["[QUALITY]"]);

                switch (action)
                {
                     case InterpreterAction.PICKUP:
                          if (quality>=logPickQuality)
                                logOut(logString, action, LogType.LOG);
                          break;
                     case InterpreterAction.IGNORE:
                          if (quality>=logPickQuality)
                                logOut(logString, action, LogType.LOG);
                          break;
                     case InterpreterAction.KEEP:
                          if (quality>=logKeepQuality)
                                logOut(logString, action, LogType.LOG);
                          break;
                     case InterpreterAction.TRASH:
                          if (quality>=logKeepQuality)
                                logOut(logString, action, LogType.LOG);
                          break;
                     case InterpreterAction.SCORE:
                          if (quality>=logKeepQuality)
                                logOut(logString, action, LogType.LOG);
                          break;
                     case InterpreterAction.SALVAGE:
                          if (quality>=logKeepQuality)
                                logOut(logString, action, LogType.LOG);
                          break;
                     case InterpreterAction.NULL:
                          if (quality>=logPickQuality)
                                logOut(logString, action, LogType.LOG);
                          break;
                }
        }
Beispiel #13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="str"></param>
        /// <param name="logType"></param>
        public void logOut(string str, InterpreterAction action, LogType logType)
        {
            // no debugging when flag set false
                if (logType==LogType.DEBUG&&!Bot.Settings.ItemRules.ItemRuleDebug)
                     return;

                //if (!GilesTrinity.Settings.Advanced.ItemRulesLogs)
                //return;

                log=new StreamWriter(Path.Combine(logPath, logFile), true);
                log.WriteLine(DateTime.Now.ToString("yyyyMMddHHmmssffff")+".Hero"+SEP+logType+SEP+action+SEP+str);
                log.Close();
        }
Beispiel #14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="str"></param>
        /// <param name="logType"></param>
        public void logOut(string str, InterpreterAction action, LogType logType)
        {
            // no debugging when flag set false
              if (logType == LogType.DEBUG && !FunkyTownRunPlugin.PluginSettings.ItemRuleDebug)
                  return;

              string filePath = string.Empty;
              switch (action)
              {
                  case InterpreterAction.PICKUP:
                  case InterpreterAction.IGNORE:
                      filePath = Path.Combine(FolderPaths.LoggingFolderPath, PickLogFile);
                      log = new StreamWriter(filePath, true);
                      break;
                  case InterpreterAction.IDENTIFY:
                  case InterpreterAction.UNIDENT:
                      filePath = Path.Combine(FolderPaths.LoggingFolderPath, RestLogFile);
                      log = new StreamWriter(filePath, true);
                      break;
                  case InterpreterAction.KEEP:
                  case InterpreterAction.TRASH:
                  case InterpreterAction.SCORE:
                      filePath = Path.Combine(FolderPaths.LoggingFolderPath, KeepLogFile);
                      log = new StreamWriter(filePath, true);
                      break;
                  case InterpreterAction.SALVAGE:
                  case InterpreterAction.SELL:
                      filePath = Path.Combine(FolderPaths.LoggingFolderPath, RestLogFile);
                      log = new StreamWriter(filePath, true);
                      break;
                  case InterpreterAction.NULL:
                      filePath = Path.Combine(FolderPaths.LoggingFolderPath, BugsLogFile);
                      log = new StreamWriter(filePath, true);
                      break;
              }

              log.WriteLine(DateTime.UtcNow.ToString("yyyyMMddHHmmssffff") + ".Hero" + SEP + logType + SEP + action + SEP + str);
              log.Close();
        }