Ejemplo n.º 1
0
        public void TestBarbarianMeleeConditionsWithFinesseWeapons()
        {
            History.TimeClock = new DndTimeClock();
            Character fred = AllPlayers.GetFromId(PlayerID.Fred);
            DndGame   game = DndGame.Instance;

            game.GetReadyToPlay();
            game.AddPlayer(fred);
            game.Start();
            fred.StartTurnResetState();
            AssignedFeature barbarianMelee = fred.GetFeature("BarbarianMelee");

            Assert.IsFalse(barbarianMelee.ShouldActivateNow());

            fred.ActivateFeature("WildSurgeRage");
            Assert.IsFalse(barbarianMelee.ShouldActivateNow());              // Not yet. We need to be using the right weapon.

            PlayerActionShortcut dagger = fred.GetShortcut("Dagger");

            Assert.IsNotNull(dagger);
            fred.Use(dagger);
            Assert.IsTrue(barbarianMelee.ShouldActivateNow());

            fred.baseDexterity = 18;
            fred.baseStrength  = 10;
            dagger.UpdatePlayerAttackingAbility(fred);
            fred.Use(dagger);
            Assert.IsFalse(barbarianMelee.ShouldActivateNow());              // Should not be satisfied because dexterity is now the ability of choice to use with this finesse weapon.
        }
Ejemplo n.º 2
0
        public void TestSpellCastingTimeTransitionToShortcut()
        {
            List <PlayerActionShortcut> merkinShortcuts = AllActionShortcuts.Get(PlayerID.Merkin);
            PlayerActionShortcut        shieldShortcut  = merkinShortcuts.FirstOrDefault(x => x.Name == "Shield");

            Assert.AreEqual(TurnPart.Reaction, shieldShortcut.Part);
        }
Ejemplo n.º 3
0
        public void TestBarbarianMeleeRageExpiration()
        {
            AllPlayers.Invalidate();
            AllFeatures.Invalidate();
            History.TimeClock = new DndTimeClock();
            Character fred = AllPlayers.GetFromId(PlayerID.Fred);
            DndGame   game = DndGame.Instance;

            game.GetReadyToPlay();
            game.AddPlayer(fred);
            game.Start();

            fred.StartTurnResetState();
            AssignedFeature barbarianMelee = fred.GetFeature("BarbarianMelee");

            Assert.IsFalse(barbarianMelee.ShouldActivateNow());

            fred.ActivateFeature("WildSurgeRage");
            PlayerActionShortcut greataxe = fred.GetShortcut("Greataxe");

            fred.Use(greataxe);

            Assert.IsTrue(barbarianMelee.ShouldActivateNow());

            // Now test alarm system to turn off rage after one minute....
            History.TimeClock.Advance(DndTimeSpan.FromSeconds(59));
            Assert.IsTrue(barbarianMelee.ShouldActivateNow());
            History.TimeClock.Advance(DndTimeSpan.FromSeconds(1));
            Assert.IsFalse(barbarianMelee.ShouldActivateNow());
        }
Ejemplo n.º 4
0
        public void TestBarbarianMeleeConditionsWithVariousWeapons()
        {
            AllPlayers.Invalidate();
            History.TimeClock = new DndTimeClock();
            Character fred = AllPlayers.GetFromId(PlayerID.Fred);
            DndGame   game = DndGame.Instance;

            game.GetReadyToPlay();
            game.AddPlayer(fred);
            game.Start();
            fred.StartTurnResetState();
            AssignedFeature barbarianMelee = fred.GetFeature("BarbarianMelee");

            Assert.IsFalse(barbarianMelee.ShouldActivateNow());

            fred.ActivateFeature("WildSurgeRage");
            Assert.IsFalse(barbarianMelee.ShouldActivateNow());              // Not yet. We need to be using the right weapon.

            PlayerActionShortcut greataxe = fred.GetShortcut("Greataxe");

            Assert.IsNotNull(greataxe);
            fred.Use(greataxe);

            Assert.IsTrue(Expressions.GetBool("InRage", fred));
            Assert.IsTrue(Expressions.GetBool("AttackIsMelee", fred));
            Assert.IsTrue(Expressions.GetBool("AttackingWith(strength)", fred));
            Assert.IsTrue(barbarianMelee.ShouldActivateNow());

            PlayerActionShortcut longbow = fred.GetShortcut("Longbow");

            fred.Use(longbow);
            Assert.IsFalse(barbarianMelee.ShouldActivateNow());
        }
        public void TestAvaActionShortcuts()
        {
            List <PlayerActionShortcut> avaShortcuts = AllActionShortcuts.Get(PlayerID.LilCutie);
            PlayerActionShortcut        javelin      = avaShortcuts.FirstOrDefault(x => x.DisplayText == "Javelin");

            Assert.IsNotNull(javelin);
        }
Ejemplo n.º 6
0
 public void TestTurnPartConversion()
 {
     Assert.AreEqual(TurnPart.Action, PlayerActionShortcut.GetTurnPart("1A"));
     Assert.AreEqual(TurnPart.BonusAction, PlayerActionShortcut.GetTurnPart("1BA"));
     Assert.AreEqual(TurnPart.Reaction, PlayerActionShortcut.GetTurnPart("1R"));
     Assert.AreEqual(TurnPart.Special, PlayerActionShortcut.GetTurnPart("*"));
     Assert.AreEqual(TurnPart.Action, PlayerActionShortcut.GetTurnPart(""));
 }
Ejemplo n.º 7
0
        public void TestAvaActionShortcuts()
        {
            List <PlayerActionShortcut> avaShortcuts = AllActionShortcuts.Get(PlayerID.Ava);
            PlayerActionShortcut        javelin      = avaShortcuts.FirstOrDefault(x => x.Name == "Javelin");

            Assert.IsNotNull(javelin);

            PlayerActionShortcut thunderousSmite = avaShortcuts.FirstOrDefault(x => x.Name == "Thunderous Smite");

            Assert.AreEqual(3, thunderousSmite.Windups.Count);
            Assert.IsNotNull(thunderousSmite);
        }
Ejemplo n.º 8
0
        public void TestBarbarianMeleeDeactivate()
        {
            AllPlayers.Invalidate();
            AllFeatures.Invalidate();
            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            Character fred = AllPlayers.GetFromId(PlayerID.Fred);

            game.AddPlayer(fred);
            game.Start();

            PlayerActionShortcut greataxe = fred.GetShortcut("Greataxe");

            fred.Use(greataxe);

            CharacterClass barbarianClass = fred.Classes.FirstOrDefault(x => x.Name == "Barbarian");

            Assert.IsNotNull(barbarianClass);
            barbarianClass.Level = 16;
            fred.ResetPlayerActionBasedState();

            Assert.AreEqual(0, fred.damageOffsetThisRoll);

            fred.ActivateFeature("WildSurgeRage");
            Assert.AreEqual(0, fred.damageOffsetThisRoll);
            fred.Use(greataxe);
            Assert.AreEqual(4, fred.damageOffsetThisRoll);

            AssignedFeature rageFeature = fred.GetFeature("WildSurgeRage");

            Assert.IsTrue(rageFeature.Feature.IsActive);

            Expressions.Do("Set(_rage,false)", fred);

            Assert.IsFalse(rageFeature.Feature.IsActive);
            Assert.IsFalse(fred.GetFeature("BarbarianMelee").Feature.IsActive);
            fred.Use(greataxe);
            Assert.IsFalse(fred.GetFeature("BarbarianMelee").Feature.IsActive);

            Assert.AreEqual(0, fred.damageOffsetThisRoll);


            fred.ActivateFeature("WildSurgeRage");
            Assert.IsTrue(fred.GetFeature("BarbarianMelee").Feature.IsActive);
            Assert.AreEqual(4, fred.damageOffsetThisRoll);

            fred.DeactivateFeature("WildSurgeRage");
            Assert.IsFalse(fred.GetFeature("BarbarianMelee").Feature.IsActive);
            Assert.AreEqual(0, fred.damageOffsetThisRoll);
        }
Ejemplo n.º 9
0
        public void TestToHitBonusAndDamageDie()
        {
            List <PlayerActionShortcut> battleaxes  = AllActionShortcuts.Get(PlayerID.Ava, "Battleaxe");
            PlayerActionShortcut        battleaxe2H = battleaxes.FirstOrDefault(x => x.Name.IndexOf("(2H)") > 0);
            PlayerActionShortcut        battleaxe1H = battleaxes.FirstOrDefault(x => x.Name.IndexOf("(1H)") > 0);

            Assert.IsNotNull(battleaxe1H);
            Assert.IsNotNull(battleaxe2H);
            Assert.AreEqual("1d8+3(slashing)", battleaxe1H.Dice);
            Assert.AreEqual("1d10+3(slashing)", battleaxe2H.Dice);
            Assert.AreEqual(6, battleaxe1H.ToHitModifier);
            Assert.AreEqual(6, battleaxe2H.ToHitModifier);

            PlayerActionShortcut greatsword = AllActionShortcuts.Get(PlayerID.Ava, "Greatsword")[0];

            Assert.AreEqual(1, greatsword.PlusModifier);
            Assert.IsNotNull(greatsword);
            Assert.AreEqual("2d6+4(slashing)", greatsword.Dice);
            Assert.AreEqual(7, greatsword.ToHitModifier);
        }
Ejemplo 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();
        }
Ejemplo 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));
            }
        }
Ejemplo n.º 12
0
 public static void Misses(this Creature creature, Creature target, PlayerActionShortcut weapon)
 {
     creature.PrepareAttack(target, weapon);
     creature.MissesTarget();
 }
Ejemplo n.º 13
0
        public static DiceRoll GetSpellFrom(string spellName, Character player, int spellSlotLevel = -1)
        {
            PlayerActionShortcut shortcut = PlayerActionShortcut.FromSpell(spellName, player, spellSlotLevel);

            return(DiceRoll.GetFrom(shortcut));
        }
Ejemplo n.º 14
0
 public static void Hits(this Creature creature, Creature target, PlayerActionShortcut weapon)
 {
     creature.WillAttack(target, weapon);
     creature.HitsTarget();
 }