public void AddPCGetPC()
        {
            var k  = new Character("Khadaji");
            var cr = new CharacterResolver();

            cr.SetPlayer(k);
            Assert.AreEqual(CharacterResolver.Type.Player, cr.WhichType(k));
            Assert.AreEqual(CharacterResolver.Type.Player, cr.WhichType("Khadaji"));
        }
        public void AddVarietyOfNamesGetThemBackCorrectly()
        {
            var cr = new CharacterResolver();

            cr.SetPlayer("Khadaji");
            cr.SetMercenary("Movanna");
            cr.SetPet("Khadaji`s pet");
            cr.SetPet("Jabantik");
            cr.SetNonPlayer("Gomphus");

            Assert.AreEqual(CharacterResolver.Type.Player, cr.WhichType("Khadaji"));
            Assert.AreEqual(CharacterResolver.Type.Mercenary, cr.WhichType("Movanna"));
            Assert.AreEqual(CharacterResolver.Type.Pet, cr.WhichType("Khadaji`s pet"));
            Assert.AreEqual(CharacterResolver.Type.Pet, cr.WhichType("Jabantik"));
            Assert.AreEqual(CharacterResolver.Type.NonPlayerCharacter, cr.WhichType("Gomphus"));
        }
Beispiel #3
0
        private bool IsCharacterPlayerOrMerc(Character c)
        {
            var charType = CharResolver.WhichType(c);

            switch (charType)
            {
            case CharacterResolver.Type.NonPlayerCharacter:
                return(false);

            case CharacterResolver.Type.Player:
            case CharacterResolver.Type.Mercenary:

            // It's more that this char is not an NPC
            default:
                return(true);
            }
        }
        public void PlayerStickyResistsOverrideToMercenary()
        {
            var cr = new CharacterResolver();

            cr.SetPlayer("Bob", true);
            cr.SetMercenary("Bob");

            Assert.AreEqual(CharacterResolver.Type.Player, cr.WhichType("Bob"));
        }
        public void MercenaryOverridesPlayer()
        {
            var cr = new CharacterResolver();

            cr.SetPlayer("Bob");
            cr.SetMercenary("Bob");

            Assert.AreEqual(CharacterResolver.Type.Mercenary, cr.WhichType("Bob"));
        }
        public void PetOverridesPlayer()
        {
            var cr = new CharacterResolver();

            cr.SetPlayer("Bob");
            cr.SetPet("Bob");

            Assert.AreEqual(CharacterResolver.Type.Pet, cr.WhichType("Bob"));
        }
        public void PlayerNotOverwrittenByMercenary()
        {
            var cr = new CharacterResolver();

            cr.SetPlayer("Bob");
            cr.SetMercenary("Bob", overwrite: false);

            Assert.AreEqual(CharacterResolver.Type.Player, cr.WhichType("Bob"));
        }
        public void PlayerNonStickyGetsChangedToMercenary()
        {
            var cr = new CharacterResolver();

            cr.SetPlayer("Bob");
            cr.SetMercenary("Bob");

            Assert.AreEqual(CharacterResolver.Type.Mercenary, cr.WhichType("Bob"));
        }
        public void AddNameToMultipleListsGetBackWhichShouldNotBeAllowed()
        {
            var cr = new CharacterResolver();

            cr.SetMercenary("Bob");
            cr.SetNonPlayer("Bob");
            // Should this fail? Exception or silent? I prefer no exception

            Assert.AreEqual(CharacterResolver.Type.Mercenary, cr.WhichType("Bob"));
        }
Beispiel #10
0
        // public void AddLine(Zone line) { }
        // public void AddLine(Chat line) { }

        private void DeterminePrimaryMob(Attack line)
        {
            // If mob already set, don't change it
            if (PrimaryMob != Character.Unknown)
            {
                return;
            }

            // If it's a mob, set it
            if (CharResolver.WhichType(line.Attacker) == CharacterResolver.Type.NonPlayerCharacter)
            {
                PrimaryMob = line.Attacker;
                return;
            }

            if (CharResolver.WhichType(line.Defender) == CharacterResolver.Type.NonPlayerCharacter)
            {
                PrimaryMob = line.Defender;
                return;
            }

            // If we've got multiple lines, we should be able to see who's the main target by the fact that everyone keeps beating them up
            if (!Fighters.Any())
            {
                return;
            }

            // Note: this finds the fighter who has the most combined attack lines
            // better would be to find the fight with the most distinct other fighters who have been attacking them
            var topFighter = Fighters.Aggregate((maxItem, nextItem) => maxItem.DefensiveStatistics.Lines.Count + maxItem.OffensiveStatistics.Lines.Count > nextItem.DefensiveStatistics.Lines.Count + nextItem.OffensiveStatistics.Lines.Count ? maxItem : nextItem);

            if (topFighter.DefensiveStatistics.Lines.Count + topFighter.OffensiveStatistics.Lines.Count >= 2)
            {
                PrimaryMob = topFighter.Character;
            }
        }
        public void UnknownCharacterAtStartWhenAllIsEmpty()
        {
            var cr = new CharacterResolver();

            Assert.AreEqual(CharacterResolver.Type.Unknown, cr.WhichType(new Character("Khadaji")));
        }