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 TestAttackSpellEventsTimeout()
        {
            AllPlayers.Invalidate();
            Character merkin           = AllPlayers.GetFromId(PlayerID.Merkin);
            Monster   joeTheVineBlight = MonsterBuilder.BuildVineBlight("Joe");

            Spell zzzRangeSpell = AllSpells.Get("ZZZ Test Range Spell", merkin, 3);

            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            game.AddPlayer(merkin);
            game.AddCreature(joeTheVineBlight);
            game.EnteringCombat();
            merkin.CastTest(zzzRangeSpell, joeTheVineBlight);
            List <CastedSpell> activeSpells = merkin.GetActiveSpells();

            Assert.IsNotNull(activeSpells);
            Assert.AreEqual(0, activeSpells.Count);
            Assert.AreEqual("onCasting", Expressions.GetStr("Get(_spellState)", merkin));
            const int hiddenThreshold = 12;

            merkin.ReadyRollDice(DiceRollType.Attack, "1d20(:score),2d8(:damage),1d6(:damage)", hiddenThreshold);
            Assert.AreEqual("onCast", Expressions.GetStr("Get(_spellState)", merkin));
            const int damage = 7;

            merkin.DieRollStoppedForTestCases(hiddenThreshold, damage);

            game.AdvanceClock(DndTimeSpan.FromMinutes(1));
            Assert.AreEqual("onDispel", Expressions.GetStr("Get(_spellState)", merkin));
            activeSpells = merkin.GetActiveSpells();
            Assert.IsNotNull(activeSpells);
            Assert.AreEqual(0, activeSpells.Count);
            game.ExitingCombat();
        }
Esempio n. 3
0
        public void TestAttackSpellEventsOnPlayerAttacks()
        {
            AllPlayers.Invalidate();
            Character merkin        = AllPlayers.GetFromId(PlayerID.Merkin);
            Monster   joeVineBlight = MonsterBuilder.BuildVineBlight("Joe");

            Spell zzzSaveSpell = AllSpells.Get("ZZZ Test Save Spell", merkin, 3);

            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            game.AddPlayer(merkin);
            game.AddCreature(joeVineBlight);
            game.EnteringCombat();
            merkin.CastTest(zzzSaveSpell, joeVineBlight);

            const int hiddenThreshold = 12;
            const int damage          = 7;

            Assert.AreEqual("onCasting", Expressions.GetStr("Get(_spellState)", merkin));
            merkin.ReadyRollDice(DiceRollType.DamageOnly, "1d6(fire)");
            Assert.AreEqual("onCast", Expressions.GetStr("Get(_spellState)", merkin));

            merkin.PrepareAttack(joeVineBlight, Attack.Melee("Unarmed Strike", 5, 5));
            Assert.AreEqual("onPlayerAttacks", Expressions.GetStr("Get(_spellState)", merkin));

            merkin.ReadyRollDice(DiceRollType.Attack, "1d20(:score),2d8(:damage),1d6(:damage)", hiddenThreshold);
            merkin.DieRollStoppedForTestCases(hiddenThreshold, damage);
            Assert.AreEqual("onPlayerHitsTarget", Expressions.GetStr("Get(_spellState)", merkin));

            List <CastedSpell> activeSpells = merkin.GetActiveSpells();

            Assert.IsNotNull(activeSpells);
            game.ExitingCombat();
        }
Esempio n. 4
0
        public void TestAutoAdvanceRound()
        {
            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            Character merkin           = AllPlayers.GetFromId(PlayerID.Merkin);
            Monster   joeTheVineBlight = MonsterBuilder.BuildVineBlight("Joe");

            game.AddPlayer(merkin);
            game.AddMonster(joeTheVineBlight);
            game.EnteringCombat();
            DateTime enterCombatTime = game.Time;

            Assert.AreEqual(1, game.RoundNumber);
            Spell zzzSaveSpell = AllSpells.Get("ZZZ Test Save Spell", merkin, 3);

            merkin.CastTest(zzzSaveSpell, joeTheVineBlight);
            joeTheVineBlight.PrepareAttack(merkin, joeTheVineBlight.GetAttack(AttackNames.Constrict));
            merkin.CastTest(zzzSaveSpell, joeTheVineBlight);
            Assert.AreEqual(2, game.RoundNumber);

            DateTime exitCombatTime  = game.Time;
            TimeSpan totalCombatTime = exitCombatTime - enterCombatTime;

            Assert.AreEqual((game.RoundNumber - 1) * 6 /*seconds*/, totalCombatTime.TotalSeconds);
            game.ExitingCombat();
            Assert.AreEqual(1, game.RoundNumber);
        }
Esempio n. 5
0
        public void TestSaveSpellEvents()
        {
            AllPlayers.Invalidate();
            History.TimeClock = new DndTimeClock();

            Character merkin           = AllPlayers.GetFromId(PlayerID.Merkin);
            Monster   joeTheVineBlight = MonsterBuilder.BuildVineBlight("Joe");

            Spell zzzSaveSpell = AllSpells.Get("ZZZ Test Save Spell", merkin, 3);

            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            game.AddPlayer(merkin);
            game.AddCreature(joeTheVineBlight);
            merkin.CastTest(zzzSaveSpell, joeTheVineBlight);
            merkin.ReadyRollDice(DiceRollType.DamageOnly, "3d6(fire)", 12);
            List <CastedSpell> activeSpells = merkin.GetActiveSpells();

            Assert.IsNotNull(activeSpells);
            Assert.AreEqual(1, activeSpells.Count);
            Assert.AreEqual("onCast", Expressions.GetStr("Get(_spellState)", merkin));
            game.AdvanceClock(DndTimeSpan.FromMinutes(1));
            Assert.AreEqual("onDispel", Expressions.GetStr("Get(_spellState)", merkin));
            activeSpells = merkin.GetActiveSpells();
            Assert.IsNotNull(activeSpells);
            Assert.AreEqual(0, activeSpells.Count);
        }
        public void TestDamageImmunity()
        {
            Monster   vrock  = MonsterBuilder.BuildVrock();
            Character wizard = CharacterBuilder.BuildTestWizard();
            Attack    beak   = vrock.attacks.Find(x => x.Name == "Beak");

            Assert.IsTrue(wizard.CanBeAffectedBy(beak));
            wizard.AddDamageImmunity(DamageType.Piercing, AttackKind.Any);
            Assert.IsFalse(wizard.CanBeAffectedBy(beak));
        }
        public void TestStunnedImmunity()
        {
            Monster   vrock           = MonsterBuilder.BuildVrock();
            Character wizard          = CharacterBuilder.BuildTestWizard();
            Attack    stunningScreech = vrock.attacks.Find(x => x.Name == AttackNames.StunningScreech);

            Assert.IsTrue(wizard.CanBeAffectedBy(stunningScreech));
            wizard.conditionImmunities = Conditions.Stunned;
            Assert.IsFalse(wizard.CanBeAffectedBy(stunningScreech));
        }
        public void TestDeafnessImmunity()
        {
            Monster   vrock           = MonsterBuilder.BuildVrock();
            Character wizard          = CharacterBuilder.BuildTestWizard();
            Attack    stunningScreech = vrock.attacks.Find(x => x.Name == AttackNames.StunningScreech);

            Assert.IsTrue(wizard.CanBeAffectedBy(stunningScreech));
            wizard.ManuallyAddedConditions |= Conditions.Deafened;
            Assert.IsFalse(wizard.CanBeAffectedBy(stunningScreech));
        }
Esempio n. 9
0
        public void TestVrock()
        {
            Monster vrock = MonsterBuilder.BuildVrock();

            Assert.IsTrue(vrock.IsResistantTo(DamageType.Cold, AttackKind.NonMagical));
            Assert.IsTrue(vrock.IsResistantTo(DamageType.Fire, AttackKind.NonMagical));
            Assert.IsTrue(vrock.IsResistantTo(DamageType.Lightning, AttackKind.NonMagical));
            Assert.IsTrue(vrock.IsResistantTo(DamageType.Bludgeoning, AttackKind.NonMagical));
            Assert.IsTrue(vrock.IsResistantTo(DamageType.Piercing, AttackKind.NonMagical));
            Assert.IsTrue(vrock.IsResistantTo(DamageType.Slashing, AttackKind.NonMagical));
            Assert.IsTrue(vrock.IsImmuneTo(DamageType.Poison, AttackKind.Any));
            Assert.IsTrue(vrock.IsImmuneTo(Conditions.Poisoned));
        }
Esempio n. 10
0
        public void TestTurnEvents()
        {
            AllPlayers.Invalidate();
            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            Character            ava        = game.AddPlayer(AllPlayers.GetFromId(PlayerID.LilCutie));
            Creature             joe        = game.AddCreature(MonsterBuilder.BuildVineBlight("Joe"));
            PlayerActionShortcut greatsword = ava.GetShortcut("Greatsword");

            game.EnteringCombat();
            Assert.IsNull(game.ActiveCreature);
            ava.TestStartTurn();
            Assert.AreEqual(ava, game.ActiveCreature);
            ava.PrepareAttack(joe, greatsword);
            game.SetHiddenThreshold(ava, 12, DiceRollType.Attack);
            //DiceRoll diceRoll = ava.GetRoll();

            game.ExitingCombat();
        }
Esempio n. 11
0
        public void TestWrathfulSmite()
        {
            AllPlayers.Invalidate();
            AllSpells.Invalidate();
            AllActionShortcuts.Invalidate();
            Character            ava        = AllPlayers.GetFromId(PlayerID.LilCutie);
            PlayerActionShortcut greatsword = ava.GetShortcut("Greatsword");

            Assert.IsNotNull(greatsword);
            Monster joeVineBlight = MonsterBuilder.BuildVineBlight("Joe");

            List <PlayerActionShortcut> wrathfulSmites = AllActionShortcuts.Get(ava.playerID, SpellNames.WrathfulSmite);

            Assert.AreEqual(1, wrathfulSmites.Count);
            PlayerActionShortcut wrathfulSmite = wrathfulSmites[0];

            Assert.IsNotNull(wrathfulSmite);

            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            game.AddPlayer(ava);
            game.AddCreature(joeVineBlight);
            DateTime gameStartTime = game.Time;

            game.EnteringCombat();

            ava.Hits(joeVineBlight, greatsword);            // Action. Ava is first to fight.
            ava.CastTest(wrathfulSmite.Spell);              // Bonus Action - Wrathful Smite lasts for one minute.
            Assert.IsTrue(ava.SpellIsActive(SpellNames.WrathfulSmite));

            joeVineBlight.Misses(ava, AttackNames.Constrict);

            AvaMeleeMissesJoe();                // Round 2
            Assert.AreEqual(6, game.SecondsSince(gameStartTime));

            joeVineBlight.Misses(ava, AttackNames.Constrict);
            Assert.AreEqual(6, game.SecondsSince(gameStartTime));

            AvaMeleeMissesJoe();                // Round 3
            Assert.AreEqual(12, game.SecondsSince(gameStartTime));

            joeVineBlight.Misses(ava, AttackNames.Constrict);
            Assert.AreEqual(12, game.SecondsSince(gameStartTime));

            AvaMeleeMissesJoe();
            Assert.AreEqual(18, game.SecondsSince(gameStartTime));

            joeVineBlight.Misses(ava, AttackNames.Constrict);
            Assert.AreEqual(18, game.SecondsSince(gameStartTime));

            //`+++NOW THE HIT....
            ava.Hits(joeVineBlight, greatsword);
            Assert.AreEqual(24, game.SecondsSince(gameStartTime));

            Assert.IsTrue(ava.SpellIsActive(SpellNames.WrathfulSmite));              // Wrathful Smite spell is not yet dispelled, however its impact on attack rolls is done.

            Assert.AreEqual($"Target must make a Wisdom saving throw or be frightened of {ava.name} until the spell ends. As an action, the creature can make a Wisdom check against {ava.name}'s spell save DC ({ava.GetSpellSaveDC()}) to steel its resolve and end this {wrathfulSmite.Spell.Name} spell.", game.lastMessageSentToDungeonMaster);

            joeVineBlight.Misses(ava, AttackNames.Constrict);
            Assert.AreEqual(24, game.SecondsSince(gameStartTime));

            ava.Misses(joeVineBlight, greatsword);              // Advancing Round (Ava's turn again).
            Assert.AreEqual("", ava.additionalDiceThisRoll);    // No more die roll effects.
            Assert.AreEqual("", ava.trailingEffectsThisRoll);
            Assert.AreEqual("", ava.dieRollEffectsThisRoll);
            Assert.AreEqual("", ava.dieRollMessageThisRoll);

            Assert.AreEqual(30, game.SecondsSince(gameStartTime));
            game.AdvanceClock(DndTimeSpan.FromSeconds(30));

            Assert.IsFalse(ava.SpellIsActive(SpellNames.WrathfulSmite));              // Wrathful Smite spell should finally be dispelled.

            void AvaMeleeMissesJoe()
            {
                Assert.AreEqual("", ava.additionalDiceThisRoll);
                Assert.AreEqual("", ava.trailingEffectsThisRoll);
                Assert.AreEqual("", ava.dieRollEffectsThisRoll);
                Assert.AreEqual("", ava.dieRollMessageThisRoll);
                ava.Misses(joeVineBlight, greatsword);                  // Advancing Round (Ava's turn again).
                Assert.AreEqual("1d6(psychic)", ava.additionalDiceThisRoll);
                Assert.AreEqual("Ravens;Spirals", ava.trailingEffectsThisRoll);
                Assert.AreEqual("PaladinSmite", ava.dieRollEffectsThisRoll);
                Assert.AreEqual("Wrathful Smite", ava.dieRollMessageThisRoll);
                Assert.IsTrue(ava.SpellIsActive(SpellNames.WrathfulSmite));
            }
        }
Esempio n. 12
0
        public void TestSpellRangeTest()
        {
            Spell chaosBolt = AllSpells.Get(SpellNames.ChaosBolt);

            AllPlayers.Invalidate();
            AllFeatures.Invalidate();
            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            Character sorcerer = PlayerHelper.GetPlayerAtLevel("Sorcerer", 6);

            sorcerer.name = "Mark";
            game.AddPlayer(sorcerer);
            Monster joe = MonsterBuilder.BuildVineBlight("Joe");

            game.AddCreature((Creature)joe);
            game.Start();

            PositionCreatures(@"
┌───────────────┐
│               │
│               │
│           M   │
│               │
│               └───────────────┐
│                               │
│                                       │
│                               │
│                               │
│               ┌───────────────┘
│           J   │
│               │
│               │
│               │
│               │
└───────────────┘", game.AllCreatures);
            Assert.AreEqual(40, sorcerer.CanCast(chaosBolt).DistanceTo(joe));
            Assert.IsTrue(sorcerer.CanCast(chaosBolt).At(joe));


            PositionCreatures(@"
┌───────────────┐
│               │
│               │
│           M   │
│               │
│               └───────────────┐
│                               │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                               │
│                               │
│               ┌───────────────┘
│           J   │
│               │
│               │
│               │
│               │
└───────────────┘", game.AllCreatures);

            Assert.AreEqual(125, sorcerer.CanCast(chaosBolt).DistanceTo(joe));
            Assert.IsFalse(sorcerer.CanCast(chaosBolt).At(joe));
        }