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 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. }
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()); }
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); }
public void TestProperties() { Character fred = AllPlayers.Get("Fred"); DndGame game = DndGame.Instance; game.GetReadyToPlay(); game.AddPlayer(fred); game.Start(); Expressions.Do("Set(_rage,true)", fred); Assert.IsTrue(Expressions.GetBool("_rage", fred)); Assert.IsTrue(Expressions.GetBool("InRage", fred)); Expressions.Do("Set(_rage,false)", fred); Assert.IsFalse(Expressions.GetBool("_rage", fred)); Assert.IsFalse(Expressions.GetBool("InRage", fred)); }
public void TestBarbarianMeleeConditions() { 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()); Expressions.Do("Set(_rage,true)", fred); fred.GetAttackingAbilityModifier(WeaponProperties.Melee, AttackType.Melee); Assert.IsTrue(barbarianMelee.ShouldActivateNow()); }
private static Character StartNewGame(string playerClass, int level, string weapon = null) { AllPlayers.Invalidate(); AllFeatures.Invalidate(); DndGame game = DndGame.Instance; game.GetReadyToPlay(); Character player = PlayerHelper.GetPlayerAtLevel(playerClass, level); game.AddPlayer(player); if (weapon != null) { player.AddWeapon(weapon); } game.Start(); return(player); }
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)); }
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 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)); }