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(); }
public void TestWrathfulSmiteDuration() { Spell wrathfulSmite = AllSpells.Get(SpellNames.WrathfulSmite); Assert.IsNotNull(wrathfulSmite); Assert.AreEqual(TimeSpan.FromMinutes(1), wrathfulSmite.Duration.GetTimeSpan()); }
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 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(); }
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); }
public void TestSpellSlotLevelPower() { Spell silentImage = AllSpells.Get("Silent Image"); Assert.AreEqual(1, silentImage.Level); Assert.IsFalse(silentImage.MorePowerfulWhenCastAtHigherLevels); Spell sleep = AllSpells.Get("Sleep"); Assert.AreEqual(1, sleep.Level); Assert.IsTrue(sleep.MorePowerfulWhenCastAtHigherLevels); sleep.RecalculateDiceAndAmmo(2, 5, 0); Assert.AreEqual("7d8(hpCapacity)", sleep.DieStr); sleep.RecalculateDiceAndAmmo(3, 5, 0); Assert.AreEqual("9d8(hpCapacity)", sleep.DieStr); sleep.RecalculateDiceAndAmmo(4, 5, 0); Assert.AreEqual("11d8(hpCapacity)", sleep.DieStr); sleep.RecalculateDiceAndAmmo(5, 5, 0); Assert.AreEqual("13d8(hpCapacity)", sleep.DieStr); Spell astralProjection = AllSpells.Get("Astral Projection"); Assert.AreEqual(9, astralProjection.Level); Assert.IsFalse(astralProjection.MorePowerfulWhenCastAtHigherLevels); }
public void TestSpellSlotLevels() { Assert.AreEqual("2d8,1d6", AllSpells.Get("Chaos Bolt", 1).DieStr); Assert.AreEqual("2d8,2d6", AllSpells.Get("Chaos Bolt", 2).DieStr); Assert.AreEqual("2d8,3d6", AllSpells.Get("Chaos Bolt", 3).DieStr); Assert.AreEqual("2d8,4d6", AllSpells.Get("Chaos Bolt", 4).DieStr); Assert.AreEqual("2d8,5d6", AllSpells.Get("Chaos Bolt", 5).DieStr); Assert.AreEqual("2d8,6d6", AllSpells.Get("Chaos Bolt", 6).DieStr); Assert.AreEqual("2d8,7d6", AllSpells.Get("Chaos Bolt", 7).DieStr); }
public void TestAmmoAndSpellSlotLevelsWithClonedSpells() { Spell bonesOfTheEarth = AllSpells.Get("Bones of the Earth"); Character merkin = AllPlayers.Get("Merkin"); Assert.AreEqual(6, bonesOfTheEarth.Clone(merkin, 6).AmmoCount); Assert.AreEqual(8, bonesOfTheEarth.Clone(merkin, 7).AmmoCount); Assert.AreEqual(10, bonesOfTheEarth.Clone(merkin, 8).AmmoCount); Assert.AreEqual(12, bonesOfTheEarth.Clone(merkin, 9).AmmoCount); }
public void TestCureWounds() { Assert.AreEqual("1d8+3(healing)", AllSpells.Get("Cure Wounds", 1, 5, +3).DieStr); Assert.AreEqual("2d8+3(healing)", AllSpells.Get("Cure Wounds", 2, 5, +3).DieStr); Assert.AreEqual("3d8+3(healing)", AllSpells.Get("Cure Wounds", 3, 5, 3).DieStr); Assert.AreEqual("4d8+3(healing)", AllSpells.Get("Cure Wounds", 4, 5, 3).DieStr); Assert.AreEqual("5d8+3(healing)", AllSpells.Get("Cure Wounds", 5, 5, 3).DieStr); Assert.AreEqual("6d8+3(healing)", AllSpells.Get("Cure Wounds", 6, 5, 3).DieStr); Assert.AreEqual("7d8+3(healing)", AllSpells.Get("Cure Wounds", 7, 5, 3).DieStr); }
public void TestPlayerLevels() { Assert.AreEqual("1d8(cold)", AllSpells.Get("Ray of Frost", 1, 1).DieStr); Assert.AreEqual("1d8(cold)", AllSpells.Get("Ray of Frost", 1, 4).DieStr); Assert.AreEqual("2d8(cold)", AllSpells.Get("Ray of Frost", 1, 5).DieStr); Assert.AreEqual("2d8(cold)", AllSpells.Get("Ray of Frost", 1, 10).DieStr); Assert.AreEqual("3d8(cold)", AllSpells.Get("Ray of Frost", 1, 11).DieStr); Assert.AreEqual("3d8(cold)", AllSpells.Get("Ray of Frost", 1, 16).DieStr); Assert.AreEqual("4d8(cold)", AllSpells.Get("Ray of Frost", 1, 17).DieStr); Assert.AreEqual("4d8(cold)", AllSpells.Get("Ray of Frost", 1, 22).DieStr); }
public void TestRayOfFrost() { Spell rayOfFrost = AllSpells.Get("Ray of Frost"); Assert.IsNotNull(rayOfFrost); Assert.AreEqual(DndTimeSpan.OneAction, rayOfFrost.CastingTime); Assert.AreEqual(DndTimeSpan.Zero, rayOfFrost.Duration); Assert.IsTrue(rayOfFrost.HasRange(60, SpellRangeType.DistanceFeet)); Assert.IsFalse(rayOfFrost.RequiresConcentration); Assert.AreEqual(Cantrip, rayOfFrost.Level); Assert.AreEqual(SpellComponents.Somatic | SpellComponents.Verbal, rayOfFrost.Components); Assert.AreEqual("1d8(cold)", rayOfFrost.DieStr); }
public void TestChaosBolt() { Spell chaosBolt = AllSpells.Get("Chaos Bolt"); Assert.IsTrue(chaosBolt.MorePowerfulWhenCastAtHigherLevels); Assert.IsNotNull(chaosBolt); Assert.AreEqual(DndTimeSpan.OneAction, chaosBolt.CastingTime); Assert.AreEqual(DndTimeSpan.Zero, chaosBolt.Duration); Assert.IsTrue(chaosBolt.HasRange(120, SpellRangeType.DistanceFeet)); Assert.IsFalse(chaosBolt.RequiresConcentration); Assert.AreEqual(1, chaosBolt.Level); Assert.AreEqual(SpellComponents.Somatic | SpellComponents.Verbal, chaosBolt.Components); }
public void TestSpellSlotLevelsWithClonedSpells() { Spell fireball = AllSpells.Get("Fireball"); Character merkin = AllPlayers.Get("Merkin"); Assert.AreEqual("8d6(fire)", fireball.Clone(merkin, 3).DieStr); Assert.AreEqual("9d6(fire)", fireball.Clone(merkin, 4).DieStr); Assert.AreEqual("10d6(fire)", fireball.Clone(merkin, 5).DieStr); Assert.AreEqual("11d6(fire)", fireball.Clone(merkin, 6).DieStr); Assert.AreEqual("12d6(fire)", fireball.Clone(merkin, 7).DieStr); Assert.AreEqual("13d6(fire)", fireball.Clone(merkin, 8).DieStr); Assert.AreEqual("14d6(fire)", fireball.Clone(merkin, 9).DieStr); }
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 void TestSpellcastingAbilityModifier() { AllSpells.Get("Cure Wounds", 1); }