Пример #1
0
        internal static void SetLogLineParser(LogLine line, FahLogType fahLogType)
        {
            if (line.LineType == LogLineType.Unknown)
            {
                return;
            }
            Func <LogLine, object> parser;

            if (!CommonParsers.TryGetValue(line.LineType, out parser))
            {
                switch (fahLogType)
                {
                case FahLogType.Legacy:
                    LegacyParsers.TryGetValue(line.LineType, out parser);
                    break;

                case FahLogType.FahClient:
                    FahClientParsers.TryGetValue(line.LineType, out parser);
                    break;
                }
            }
            if (parser != null)
            {
                line.SetParser(parser);
            }
        }
Пример #2
0
        /// <summary>
        /// Parses the details from the village match
        /// </summary>
        private void HandleMatch(Dictionary <int, Village> ownVillages, Match match, DateTime serverTime)
        {
            int villageId;

            if (CommonParsers.ParseInt(match.Groups["id"].Value, out villageId))
            {
                Village vil = null;
                if (ownVillages.ContainsKey(villageId))
                {
                    vil = ownVillages[villageId];
                }
                else
                {
                    // newly conquered village: change owner
                    foreach (Village village in World.Default.Villages.Values)
                    {
                        if (village.Id == villageId)
                        {
                            vil        = village;
                            vil.Player = World.Default.You;
                        }
                    }
                }

                if (vil != null)
                {
                    CurrentSituation situation = vil.Reports.CurrentSituation;

                    int tempInt;
                    if (CommonParsers.ParseInt(match.Groups["points"].Value, out tempInt))
                    {
                        vil.Points = tempInt;
                    }

                    string          pattern    = string.Format(@"(\<img src="".*\.png(\?1)?"" title=""({0}|{1}|{2})"" alt="""" /\>(\<span class=""warn""\>)?(?<res>(\d*<span class=""grey""\>\.\</span\>)?\d*)(\</span\>)?\s*)", TWWords.Wood, TWWords.Clay, TWWords.Iron);
                    var             res        = new Regex(pattern);
                    MatchCollection resMatches = res.Matches(match.Groups["res"].Value);
                    if (resMatches.Count == 3)
                    {
                        if (CommonParsers.ParseInt(resMatches[0].Groups["res"].Value, out tempInt))
                        {
                            situation.Resources.Wood = tempInt;
                        }
                        if (CommonParsers.ParseInt(resMatches[1].Groups["res"].Value, out tempInt))
                        {
                            situation.Resources.Clay = tempInt;
                        }
                        if (CommonParsers.ParseInt(resMatches[2].Groups["res"].Value, out tempInt))
                        {
                            situation.Resources.Iron = tempInt;
                        }

                        situation.ResourcesDate = serverTime;
                    }

                    vil.Reports.Save();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Parses the details from the village match
        /// </summary>
        private void HandleMatch(Dictionary <int, Village> ownVillages, Match match, DateTime serverTime)
        {
            int villageId;

            if (CommonParsers.ParseInt(match.Groups["id"].Value, out villageId))
            {
                Village          vil       = ownVillages[villageId];
                CurrentSituation situation = vil.Reports.CurrentSituation;

                int tempInt;
                if (CommonParsers.ParseInt(match.Groups["points"].Value, out tempInt))
                {
                    vil.Points = tempInt;
                }

                // groups: warehouse, population / farm

                //System.Diagnostics.Debug.Print(vil.ToString());
                string          pattern    = string.Format(@"\<img src="".*\.png(\?1)?"" title=""({0}|{1}|{2})"" alt="""" /\>(?<res>(\d*<span class=""grey""\>\.\</span\>)?\d*)\s*", TWWords.Wood, TWWords.Clay, TWWords.Iron);
                var             res        = new Regex(pattern);
                MatchCollection resMatches = res.Matches(match.Groups["res"].Value);
                if (resMatches.Count == 3)
                {
                    if (CommonParsers.ParseInt(resMatches[0].Groups["res"].Value, out tempInt))
                    {
                        situation.Resources.Wood = tempInt;
                    }
                    if (CommonParsers.ParseInt(resMatches[1].Groups["res"].Value, out tempInt))
                    {
                        situation.Resources.Clay = tempInt;
                    }
                    if (CommonParsers.ParseInt(resMatches[2].Groups["res"].Value, out tempInt))
                    {
                        situation.Resources.Iron = tempInt;
                    }

                    situation.ResourcesDate = serverTime;
                }



                vil.Reports.Save();
            }
        }