Exemplo n.º 1
0
        private bool TryParseWho(LogDatum logDatum, out ILine lineEntry)
        {
            var match = RxWho.Match(logDatum.LogMessage);

            if (!match.Success)
            {
                lineEntry = null;
                return(false);
            }

            var isAfk = match.Groups[1].Success ? true : false;
            var isLfg = match.Groups[12].Success ? true : false;

            // These first 3 groups are for the ANONYMOUS character
            var isAnon = match.Groups[2].Success ? true : false;

            if (isAnon)
            {
                var name  = match.Groups[3].Success ? match.Groups[3].Value : null;
                var guild = match.Groups[4].Success ? match.Groups[4].Value : null;
                lineEntry = new Who(logDatum, YouAre.WhoAreYou(name), 0, null, null, null, guild, isAnon, isAfk, isLfg);
            }

            // These groups are for non-anonymous characters
            else
            {
                var level  = match.Groups[5].Success ? int.Parse(match.Groups[5].Value) : 0;
                var title  = match.Groups[6].Success ? match.Groups[6].Value : null;
                var @class = match.Groups[7].Success ? match.Groups[7].Value : null;
                var name   = match.Groups[8].Success ? match.Groups[8].Value : null;
                var race   = match.Groups[9].Success ? match.Groups[9].Value : null;
                var guild  = match.Groups[10].Success ? match.Groups[10].Value : null;
                var zone   = match.Groups[11].Success ? match.Groups[11].Value : null;
                lineEntry = new Who(logDatum, YouAre.WhoAreYou(name), level, title, @class, race, guild, isAnon, isAfk, isLfg, new Zone(logDatum, zone));
            }

            // What about chars who are /role playing? Is that the same as anonymous?

            return(true);
        }
Exemplo n.º 2
0
        private bool TryParseYouMiss(LogDatum logDatum, out ILine lineEntry)
        {
            var match = RxYouMiss.Match(logDatum.LogMessage);

            if (!match.Success)
            {
                lineEntry = null;
                return(false);
            }

            var attacker   = YouAre.Name;
            var attackVerb = match.Groups[1].Value;
            var defender   = match.Groups[2].Value;
            var defense    = match.Groups[3].Value;
            var qualifier  = match.Groups[4].Success ? match.Groups[4].Value : null;

            defense = ModifyDefense(defender, defense);

            lineEntry = new Miss(logDatum, attacker, YouAre.WhoAreYou(defender), attackVerb, defense, qualifier);

            return(true);
        }
Exemplo n.º 3
0
        private bool TryParseHeal(LogDatum logDatum, out ILine lineEntry)
        {
            var match = RxHeal.Match(logDatum.LogMessage);

            if (!match.Success)
            {
                lineEntry = null;
                return(false);
            }

            var flavor  = match.Groups[1].Value;
            var healer  = match.Groups[2].Value;
            var patient = match.Groups[4].Value;

            // "has been" || "have been"
            // Mordsith has been healed over time by ....
            // You have been healed over time by ...
            if (match.Groups[3].Success)
            {
                patient = healer;
                healer  = null;
            }

            // Khronick healed you over time ...
            // Mordsith has been healed over time ...
            var isHot = match.Groups[5].Success || match.Groups[4].Value == "over time";

            var amount    = int.Parse(match.Groups[6].Value);
            var maxAmount = match.Groups[7].Success ? int.Parse(match.Groups[7].Value) : -1;
            var spellName = match.Groups[8].Value;
            var qualifier = match.Groups[9].Success ? match.Groups[9].Value : null;

            lineEntry = new Heal(logDatum, YouAre.WhoAreYou(healer), YouAre.WhoAreYou(patient), amount, maxAmount, spellName, isHot, qualifier);

            return(true);
        }
Exemplo n.º 4
0
        private bool TryParseSpell(LogDatum logDatum, out ILine lineEntry)
        {
            var match = RxSpell.Match(logDatum.LogMessage);

            if (!match.Success)
            {
                lineEntry = null;
                return(false);
            }

            var name      = match.Groups[1].Value;
            var spellName = match.Groups[2].Value;

            lineEntry = new Spell(logDatum, YouAre.WhoAreYou(name), spellName);

            return(true);
        }
Exemplo n.º 5
0
        private bool TryParseHit(LogDatum logDatum, out ILine lineEntry)
        {
            var match = RxHit.Match(logDatum.LogMessage);

            if (!match.Success)
            {
                lineEntry = null;
                return(false);
            }

            var attacker        = match.Groups[1].Value;
            var attackVerb      = match.Groups[2].Value;
            var defender        = match.Groups[3].Value;
            var damage          = int.Parse(match.Groups[4].Value);
            var damageType      = match.Groups[5].Success ? match.Groups[5].Value : null;
            var damageBy        = match.Groups[6].Success ? match.Groups[6].Value : null;
            var damageQualifier = match.Groups[7].Success ? match.Groups[7].Value : null;

            lineEntry = new Hit(logDatum, YouAre.WhoAreYou(attacker), YouAre.WhoAreYou(defender), attackVerb, damage, damageType, damageBy, damageQualifier);

            return(true);
        }
Exemplo n.º 6
0
        private bool TryParseChat(LogDatum logDatum, out ILine lineEntry)
        {
            var match = RxChat.Match(logDatum.LogMessage);

            if (!match.Success)
            {
                lineEntry = null;
                return(false);
            }

            var who     = match.Groups[1].Value;
            var verb    = match.Groups[2].Value;
            var channel = match.Groups[3].Value;
            var text    = match.Groups[4].Value;

            who     = YouAre.WhoAreYou(who);
            channel = ModifyChannel(string.IsNullOrEmpty(channel) ? verb : channel);
            var server = CheckNameForServer(ref who);

            lineEntry = new Chat(logDatum, who, channel, text, server);

            return(true);
        }
Exemplo n.º 7
0
        private bool TryParseOtherDeath(LogDatum logDatum, out ILine lineEntry)
        {
            lineEntry = null;
            string attacker;
            string defender;

            int i = logDatum.LogMessage.IndexOf(OtherDeath);

            if (i >= 0)
            {
                defender  = logDatum.LogMessage.Substring(0, i);
                attacker  = logDatum.LogMessage.Substring(i + OtherDeath.Length, logDatum.LogMessage.Length - i - OtherDeath.Length - 1);
                lineEntry = new Kill(logDatum, YouAre.WhoAreYou(attacker), YouAre.WhoAreYou(defender), "slain");
                return(true);
            }

            return(false);
        }
Exemplo n.º 8
0
        public void VerifyNoNameYourUppercase()
        {
            var yr = new YouResolver();

            Assert.AreEqual("You", yr.WhoAreYou("YOUR"));
        }
Exemplo n.º 9
0
        public void VerifyTrickyNoSubstitution3()
        {
            var yr = new YouResolver("Khadaji");

            Assert.AreEqual("Healyougood", yr.WhoAreYou("Healyougood"));
        }
Exemplo n.º 10
0
        public void VerifyTrickyNoSubstitution2()
        {
            var yr = new YouResolver("Khadaji");

            Assert.AreEqual("Yourdoc", yr.WhoAreYou("Yourdoc"));
        }
Exemplo n.º 11
0
        public void VerifyNoSubstitution()
        {
            var yr = new YouResolver("Khadaji");

            Assert.AreEqual("Movanna", yr.WhoAreYou("Movanna"));
        }
Exemplo n.º 12
0
        public void VerifyYourSubstitutionUppercase()
        {
            var yr = new YouResolver("Khadaji");

            Assert.AreEqual("Khadaji", yr.WhoAreYou("YOUR"));
        }
Exemplo n.º 13
0
        public void VerifyYouSubstitutionLowercase()
        {
            var yr = new YouResolver("Khadaji");

            Assert.AreEqual("Khadaji", yr.WhoAreYou("you"));
        }
Exemplo n.º 14
0
        public void HandleYourself()
        {
            var yr = new YouResolver("Khronick");

            Assert.AreEqual("Khronick", yr.WhoAreYou("yourself"));
        }
Exemplo n.º 15
0
        public void VerifyEmptylName()
        {
            var yr = new YouResolver("Khadaji");

            Assert.AreEqual(string.Empty, yr.WhoAreYou(""));
        }
Exemplo n.º 16
0
        public void VerifyNullName()
        {
            var yr = new YouResolver("Khadaji");

            Assert.IsNull(yr.WhoAreYou(null));
        }