Exemple #1
0
        public void TestLoad()
        {
            AllPlayers.Invalidate();
            Feature barbarianMelee = AllFeatures.Get("BarbarianMelee");

            Assert.IsNotNull(barbarianMelee);
            Character fred = AllPlayers.GetFromId(PlayerID.Fred);
            DndGame   game = DndGame.Instance;

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

            fred.StartTurnResetState();

            Assert.IsFalse(Expressions.GetBool("BarbarianMelee(strength)", fred));
            //Expressions.LogHistory = true;
            Expressions.Do("Set(_rage,true)", fred);
            Assert.IsFalse(Expressions.GetBool("BarbarianMelee(strength)", fred));
            fred.GetAttackingAbilityModifier(WeaponProperties.Melee, AttackType.Melee);
            Assert.IsTrue(Expressions.GetBool("BarbarianMelee(strength)", fred));
        }
Exemple #2
0
        public void TestAlwaysOnFeatureActivation()
        {
            AllPlayers.Invalidate();
            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            Character lady = game.AddPlayer(AllPlayers.GetFromId(PlayerID.Lady));

            Assert.IsNotNull(lady);
            Assert.IsFalse(lady.IsResistantTo(DamageType.Lightning, AttackKind.Any));
            Assert.IsFalse(lady.IsResistantTo(DamageType.Thunder, AttackKind.Any));
            Assert.IsFalse(lady.IsResistantTo(DamageType.Lightning, AttackKind.Magical));
            Assert.IsFalse(lady.IsResistantTo(DamageType.Thunder, AttackKind.Magical));
            Assert.IsFalse(lady.IsResistantTo(DamageType.Lightning, AttackKind.NonMagical));
            Assert.IsFalse(lady.IsResistantTo(DamageType.Thunder, AttackKind.NonMagical));
            game.Start();
            Assert.IsTrue(lady.IsResistantTo(DamageType.Lightning, AttackKind.Any));
            Assert.IsTrue(lady.IsResistantTo(DamageType.Thunder, AttackKind.Any));
            Assert.IsTrue(lady.IsResistantTo(DamageType.Lightning, AttackKind.Magical));
            Assert.IsTrue(lady.IsResistantTo(DamageType.Thunder, AttackKind.Magical));
            Assert.IsTrue(lady.IsResistantTo(DamageType.Lightning, AttackKind.NonMagical));
            Assert.IsTrue(lady.IsResistantTo(DamageType.Thunder, AttackKind.NonMagical));
        }
 public static void Initialize(DndGame game)
 {
     Game = game;
     RollSavingThrowsForAllTargetsFunction.SavingThrowForTargetsRequested += SavingThrowForTargetsRequested;
 }
Exemple #4
0
 public WeatherManager(DndGame game)
 {
     Game = game;
 }
        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));
            }
        }
        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));
        }
 public WeatherManager(OBSWebsocket obsWebsocket, DndGame game)
 {
     Game = game;
     this.obsWebsocket = obsWebsocket;
 }