Esempio n. 1
0
        public void TestConditionalGrapple()
        {
            Monster   vineBlight = MonsterBuilder.BuildVineBlight();
            Character barbarian1 = CharacterBuilder.BuildTestBarbarian();
            Character barbarian2 = CharacterBuilder.BuildTestBarbarian();
            Character elf        = CharacterBuilder.BuildTestElf();
            Character druid      = CharacterBuilder.BuildTestDruid();

            elf.creatureSize        = CreatureSize.Small;
            barbarian1.creatureSize = CreatureSize.Huge;
            Assert.IsFalse(barbarian1.HasCondition(Conditions.Grappled));
            Assert.IsFalse(elf.HasCondition(Conditions.Grappled));
            Assert.IsFalse(druid.HasCondition(Conditions.Grappled));
            int attackRoll = vineBlight.GetAttackRoll(12, AttackNames.Constrict);

            Assert.AreEqual(16, attackRoll);
            barbarian1.baseArmorClass = 13;
            barbarian2.baseArmorClass = 17;
            DamageResult elfDamage        = vineBlight.GetDamageFromAttack(elf, AttackNames.Constrict, 10, attackRoll);
            DamageResult barbarian1Damage = vineBlight.GetDamageFromAttack(barbarian1, AttackNames.Constrict, 10, attackRoll);
            DamageResult barbarian2Damage = vineBlight.GetDamageFromAttack(barbarian2, AttackNames.Constrict, 10, attackRoll);

            Assert.IsNull(barbarian2Damage);              // Barbarian 2's AC is 17, which should result in a miss - no damage.
            DamageResult druidDamage = vineBlight.GetDamageFromAttack(druid, AttackNames.Constrict, 12, attackRoll);

            Assert.IsFalse(barbarian1Damage.HasCondition(Conditions.Grappled));         // barbarian 1 is huge => no damage.
            Assert.IsTrue(elfDamage.HasCondition(Conditions.Grappled));
            Assert.IsFalse(druidDamage.HasCondition(Conditions.Grappled));              // druid saving throw avoids the grapple.
            Assert.AreEqual(-9, elfDamage.hitPointChange);
            Assert.AreEqual(-9, barbarian1Damage.hitPointChange);
            Assert.AreEqual(-9, druidDamage.hitPointChange);
            Assert.AreEqual(DamageType.Bludgeoning | DamageType.Condition, elfDamage.damageTypes);
            Assert.AreEqual(DamageType.Bludgeoning, barbarian1Damage.damageTypes);
            Assert.AreEqual(DamageType.Bludgeoning, druidDamage.damageTypes);
        }
Esempio n. 2
0
        public void TestBasicDamage()
        {
            Character player     = CharacterBuilder.BuildTestDruid();
            Weapon    shortSword = Weapon.buildShortSword();

            player.hitPoints = 100;
            shortSword.Attack(AttackNames.Stab, player);
            Assert.AreEqual(96.5, player.hitPoints);
            Assert.AreEqual(3.5, player.LastDamagePointsTaken);
            Assert.AreEqual(DamageType.Piercing, player.LastDamageTaken);
        }
Esempio n. 3
0
        public void TestNoResistance()
        {
            Character    player            = CharacterBuilder.BuildTestDruid();
            Weapon       shortSword        = Weapon.buildShortSword();
            const double startingHitPoints = 100;

            player.hitPoints = startingHitPoints;
            player.AddDamageResistance(DamageType.Lightning, AttackKind.Magical | AttackKind.NonMagical);
            shortSword.Attack(AttackNames.Stab, player);
            const double expectedDamage = 3.5;

            Assert.AreEqual(startingHitPoints - expectedDamage, player.hitPoints);
            Assert.AreEqual(expectedDamage, player.LastDamagePointsTaken);
        }
Esempio n. 4
0
        public void TestImmunities()
        {
            Character    player            = CharacterBuilder.BuildTestDruid();
            Weapon       shortSword        = Weapon.buildShortSword();
            const double startingHitPoints = 100;

            player.hitPoints = startingHitPoints;
            player.AddDamageImmunity(DamageType.Piercing, AttackKind.Any);
            shortSword.Attack(AttackNames.Stab, player);
            shortSword.Attack(AttackNames.Stab, player);
            shortSword.Attack(AttackNames.Stab, player);
            shortSword.Attack(AttackNames.Stab, player);
            Assert.AreEqual(startingHitPoints, player.hitPoints);
            Assert.AreEqual(0, player.LastDamagePointsTaken);
            Assert.AreEqual(DamageType.None, player.LastDamageTaken);
        }
Esempio n. 5
0
        public void TestNonMagicalShortswordImmunity()
        {
            Weapon shortsword = Weapon.buildShortSword();
            // vs.
            Character    player            = CharacterBuilder.BuildTestDruid();
            const double startingHitPoints = 100;

            player.hitPoints = startingHitPoints;
            player.AddDamageImmunity(DamageType.Piercing, AttackKind.NonMagical);
            shortsword.Attack(AttackNames.Stab, player);
            const double expectedDamage = 0;

            Assert.AreEqual(startingHitPoints - expectedDamage, player.hitPoints);
            Assert.AreEqual(expectedDamage, player.LastDamagePointsTaken);
            Assert.AreEqual(DamageType.None, player.LastDamageTaken);
        }
Esempio n. 6
0
        public void TestPositionCreatures()
        {
            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            Character alice   = game.AddPlayer(CharacterBuilder.BuildTestBarbarian("a"));
            Character betty   = game.AddPlayer(CharacterBuilder.BuildTestDruid("b"));
            Character charlie = game.AddPlayer(CharacterBuilder.BuildTestElf("c"));
            Character david   = game.AddPlayer(CharacterBuilder.BuildTestWizard("d"));
            DndMap    map     = game.AddMap(new DndMap("Caves of the Wandering Winds"));
            DndRoom   dndRoom = map.AddRoom(new DndRoom("Wizard's Workshop"));

            Assert.AreEqual(new Vector(0, 0), alice.Location);
            Assert.AreEqual(Vector.zero, betty.Location);
            dndRoom.PositionCreatures(@"
┌───────────────┐
│               │
│               │
│    a          │
│            c  │
│               └───────────────┐
│       b                       │
│                                       │
│                               │
│                               │
│               ┌───────────────┘
│           d   │
│               │
│    e          │
│               │
│               │
└───────────────┘");
            game.ActivateMap(map);
            game.ActivateRoom(dndRoom);
            Assert.AreEqual(new Vector(DndMap.SquareSide * 5, DndMap.SquareSide * 3), alice.Location);
            Assert.AreEqual(new Vector(DndMap.SquareSide * 8, DndMap.SquareSide * 6), betty.Location);
            Assert.AreEqual(new Vector(DndMap.SquareSide * 13, DndMap.SquareSide * 4), charlie.Location);
            Assert.AreEqual(new Vector(DndMap.SquareSide * 12, DndMap.SquareSide * 11), david.Location);

            //dndGame.EnterCombat(true);
            //ergo.QueueAction(new ActionAttack(alice, AttackNames.Constrict));
        }
Esempio n. 7
0
        public void TestPositionCreatures()
        {
            DndGame   dndGame = new DndGame();
            Character alice   = dndGame.AddPlayer(CharacterBuilder.BuildTestBarbarian("a"));
            Character betty   = dndGame.AddPlayer(CharacterBuilder.BuildTestDruid("b"));
            Character charlie = dndGame.AddPlayer(CharacterBuilder.BuildTestElf("c"));
            Character david   = dndGame.AddPlayer(CharacterBuilder.BuildTestWizard("d"));
            DndMap    map     = dndGame.AddMap(new DndMap("Caves of the Wandering Winds"));
            DndRoom   dndRoom = map.AddRoom(new DndRoom("Wizard's Workshop"));

            Assert.AreEqual(new Vector(0, 0), alice.WorldPosition);
            Assert.AreEqual(Vector.zero, betty.WorldPosition);
            dndRoom.PositionCreatures(@"
┌───────────────┐
│               │
│               │
│    a          │
│            c  │
│               └───────────────┐
│       b                       │
│                                       │
│                               │
│                               │
│               ┌───────────────┘
│           d   │
│               │
│    e          │
│               │
│               │
└───────────────┘");
            dndGame.ActivateMap(map);
            dndGame.ActivateRoom(dndRoom);
            Assert.AreEqual(new Vector(5, 3), alice.WorldPosition);
            Assert.AreEqual(new Vector(8, 6), betty.WorldPosition);
            Assert.AreEqual(new Vector(13, 4), charlie.WorldPosition);
            Assert.AreEqual(new Vector(12, 11), david.WorldPosition);

            //dndGame.EnterCombat(true);
            //ergo.QueueAction(new ActionAttack(alice, AttackNames.Constrict));
        }
Esempio n. 8
0
        public void TestMultiShortswordsAnyImmunity()
        {
            Weapon magicalShortsword = Weapon.buildMagicalShortSword();
            Weapon shortsword        = Weapon.buildShortSword();
            // vs.
            Character    player            = CharacterBuilder.BuildTestDruid();
            const double startingHitPoints = 100;

            player.hitPoints = startingHitPoints;
            player.AddDamageImmunity(DamageType.Piercing, AttackKind.Any);
            Assert.IsTrue(player.IsImmuneTo(DamageType.Piercing, AttackKind.Magical));
            Assert.IsTrue(player.IsImmuneTo(DamageType.Piercing, AttackKind.NonMagical));
            Assert.IsTrue(player.IsImmuneTo(DamageType.Piercing, AttackKind.Any));
            Assert.IsFalse(player.IsImmuneTo(DamageType.Poison, AttackKind.Any));
            Assert.IsFalse(player.IsImmuneTo(DamageType.Psychic, AttackKind.Magical));
            Assert.IsFalse(player.IsImmuneTo(DamageType.Radiant, AttackKind.NonMagical));
            shortsword.Attack(AttackNames.Stab, player);
            magicalShortsword.Attack(AttackNames.Stab, player);
            const double expectedDamage = 0;

            Assert.AreEqual(startingHitPoints - expectedDamage, player.hitPoints);
            Assert.AreEqual(expectedDamage, player.LastDamagePointsTaken);
            Assert.AreEqual(DamageType.None, player.LastDamageTaken);
        }