示例#1
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();
        }
示例#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();
        }
示例#3
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);
        }
示例#4
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();
        }
示例#5
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));
            }
        }