コード例 #1
0
ファイル: SkillInfo.cs プロジェクト: tiba666/WurmAssistant3
 public SkillInfo(string name, float value, DateTime stamp, float?gain)
 {
     NameNormalized = WurmSkills.NormalizeSkillName(name);
     Value          = value;
     Stamp          = stamp;
     Gain           = gain;
 }
コード例 #2
0
        public override float?TryGetSkillLevel(string skillName)
        {
            float value;

            if (skillLevels.TryGetValue(WurmSkills.NormalizeSkillName(skillName), out value))
            {
                return(value);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        Dictionary <string, float> ParseDump()
        {
            var fileLines = File.ReadAllLines(dumpInfo.FileInfo.FullName);
            Dictionary <string, float> skills = new Dictionary <string, float>();
            var parser = new SkillEntryParser(logger);

            foreach (var line in fileLines)
            {
                if (line.StartsWith("Skills") ||
                    line.StartsWith("Characteristics") ||
                    line.StartsWith("Religion") ||
                    line.StartsWith("-----"))
                {
                    continue;
                }
                var match     = Regex.Match(line, @"(.+): (.+) .+ .+", RegexOptions.Compiled | RegexOptions.CultureInvariant);
                var skillName = match.Groups[1].Value.Trim();
                if (string.IsNullOrEmpty(skillName))
                {
                    logger.Log(LogLevel.Error,
                               string.Format("Unparseable skill name in dump file {0}, raw line: {1}",
                                             dumpInfo.FileInfo.FullName,
                                             line),
                               this,
                               null);
                    continue;
                }
                var level = parser.TryParseFloatInvariant(match.Groups[2].Value);
                if (level == null)
                {
                    logger.Log(LogLevel.Error,
                               string.Format("Unparseable skill value in dump file {0}, raw line: {1}",
                                             dumpInfo.FileInfo.FullName,
                                             line),
                               this,
                               null);
                    continue;
                }
                skills[WurmSkills.NormalizeSkillName(skillName)] = level.Value;
            }
            return(skills);
        }
コード例 #4
0
ファイル: SkillsMap.cs プロジェクト: tiba666/WurmAssistant3
        public SkillInfo TryGetSkill([NotNull] string skillName, ServerGroup serverGroup)
        {
            if (skillName == null)
            {
                throw new ArgumentNullException(nameof(skillName));
            }
            skillName = WurmSkills.NormalizeSkillName(skillName);

            var key = new CompositeSkillKey(skillName, serverGroup);

            lock (locker)
            {
                SkillInfo info;
                if (skillsMap.TryGetValue(key, out info))
                {
                    return(info);
                }
                else
                {
                    return(null);
                }
            }
        }