public void DebugAttackArmorTest() { var DM = DungeonMaster.GetDebugDM(data); var attack = DebugData.GetDebugAttackAction(); var robby = DM.Characters[0]; var zach = DM.Characters[1]; zach.Conditions.Add(new Condition("Dodging", 3)); var outcome = new Outcome(); DM.Activate(robby); attack.ResolveAction(DM, robby, null, zach, "", outcome); //not adjacent so nothing happens Assert.IsTrue(zach.Vitality.Value == zach.Vitality.Max); zach.Pos = robby.Pos + Map.DirectionToPosition[Map.Direction.E]; Deck.SetFate(new List <string>() { "Glancing Blow" }); attack.ResolveAction(DM, robby, null, zach, "", outcome); Assert.IsTrue(zach.Vitality.Value < zach.Vitality.Max); Assert.AreEqual(zach.Vitality.Max - robby.Strength.Value - robby.WeaponDamage + zach.ArmorProtection, zach.Vitality.Value); }
public void TestDrainVitality() { var DM = DungeonMaster.GetDebugDM(data); var drain = data.Actions.FirstOrDefault(a => a.Name == "Drain Vitality"); var robby = DM.Characters[0]; robby.Mana.Value = 0; var zach = DM.Characters[1]; zach.Mana.Value = 0; var deck = drain.GetDeckFor(DM, robby, null, zach); var hitIndex = deck.Cards.IndexOf(deck.Cards.Find(c => c.TypeOfCard == Card.CardType.Hit)); Deck.FatedDraws.Add("Drain"); var outcome = new Outcome(); drain.ResolveAction(DM, robby, null, zach, "", outcome); Assert.AreEqual("Drain Vitality", outcome.ActionTaken); Assert.IsTrue(outcome.CardsDrawn.Count == 1); Assert.IsTrue(outcome.CardsDrawn.Any(c => c.Name == "Drain")); Assert.IsTrue(robby.Mana.Value > 0); Assert.IsTrue(zach.Vitality.Value < zach.Vitality.Max); Assert.IsTrue(robby.Vitality.Value == robby.Vitality.Max); Assert.IsTrue(zach.Mana.Value == 0); }
public void DebugAttackDeckTest() { var DM = DungeonMaster.GetDebugDM(data); var attack = DebugData.GetDebugAttackAction(); var robby = DM.Characters[0]; var zach = DM.Characters[1]; var deck = attack.GetDeckFor(DM, robby, null, zach); Assert.AreEqual(robby.Profeciency.Value + robby.WeaponAdvantage - zach.ArmorCoverage, deck.Cards.Count(c => c.TypeOfCard == Card.CardType.Hit)); Assert.AreEqual(zach.ArmorCoverage, deck.Cards.Count(c => c.TypeOfCard == Card.CardType.Armor)); Assert.AreEqual(2, deck.Cards.Count(c => c.TypeOfCard == Card.CardType.Miss)); int dodgeCards = 3; zach.Conditions.Add(new Condition("Dodging", dodgeCards)); deck = attack.GetDeckFor(DM, robby, null, zach); Assert.AreEqual(robby.Profeciency.Value + robby.WeaponAdvantage - zach.ArmorCoverage, deck.Cards.Count(c => c.TypeOfCard == Card.CardType.Hit)); Assert.AreEqual(zach.ArmorCoverage, deck.Cards.Count(c => c.TypeOfCard == Card.CardType.Armor)); Assert.AreEqual(2 + dodgeCards, deck.Cards.Count(c => c.TypeOfCard == Card.CardType.Miss)); }
public void DMSynrchronizationTest() { var DM1 = DungeonMaster.GetDebugDM(data); var DM2 = DM1.Clone() as DungeonMaster; DM2.data = DM1.data; Assert.AreEqual(DM1.map.GetGamestateHash(), DM2.map.GetGamestateHash()); Assert.AreEqual(DM1.Sides[0].ID.GetHashCode(), DM2.Sides[0].ID.GetHashCode()); Assert.AreEqual(DM1.Sides[0].Name.GetHashCode(), DM2.Sides[0].Name.GetHashCode()); Assert.AreEqual(DM1.GetGamestateHash(), DM2.GetGamestateHash()); var robby = DM1.Characters.FirstOrDefault(c => c.Name == "Robby"); var activateOutcome = DM1.Activate(robby); DM2.ApplyOutcome(activateOutcome); Assert.AreEqual(DM1.GetGamestateHash(), DM2.GetGamestateHash()); var moveOutcome = DM1.MoveCharacter(robby, Map.Direction.S); DM2.ApplyOutcome(moveOutcome); Assert.AreEqual(DM1.GetGamestateHash(), DM2.GetGamestateHash()); var attackOutcome = DM1.UseAbility("Attack", new List <string>() { "Zach" }); DM2.ApplyOutcome(attackOutcome); Assert.AreEqual(DM1.GetGamestateHash(), DM2.GetGamestateHash()); }
public void TurnPassingTest() { var DM = DungeonMaster.GetDebugDM(data); var robby = DM.Characters[0]; var zach = DM.Characters[1]; Assert.IsTrue(DM.currentSide.ID == robby.SideID); DM.Activate(robby); DM.MoveCharacter(robby, Map.Direction.S); robby.HasActed = true; DM.EndTurn(robby.SideID); Assert.IsTrue(DM.currentSide.ID == zach.SideID); Assert.AreEqual(0, DM.TurnCount); Assert.IsFalse(zach.HasBeenActivated); Assert.IsFalse(zach.HasActed); Assert.IsTrue(robby.HasActed); DM.EndTurn(zach.SideID); Assert.IsTrue(zach.HasBeenActivated); Assert.IsTrue(robby.HasActed); Assert.IsFalse(robby.HasBeenActivated); Assert.IsTrue(robby.Move.Value < robby.Move.Max); Assert.AreEqual(robby.SideID, DM.currentSide.ID); Assert.AreEqual(1, DM.TurnCount); DM.Activate(robby); Assert.IsTrue(robby.HasBeenActivated); Assert.AreEqual(robby.Move.Max, robby.Move.Value); }
public void MoveRobbyAround() { var DM = DungeonMaster.GetDebugDM(data); var robby = DM.Characters[0]; var zach = DM.Characters[1]; var startingPos = robby.Pos; var outcome = DM.MoveCharacter(robby, Map.Direction.S); Assert.IsNotNull(outcome); Assert.AreEqual(startingPos, robby.Pos); //shouldn't have moved since he isn't activated yet bool eventRaised = false; DM.OnCharacterMoved += delegate(object sender, CharacterMovedEventArgs e) { Assert.AreEqual("Robby", e.Name); eventRaised = true; }; outcome = DM.Activate(robby); outcome = DM.MoveCharacter(robby, Map.Direction.S); Assert.IsTrue(eventRaised); Assert.AreNotEqual(startingPos, robby.Pos); startingPos = zach.Pos; DM.MoveCharacter(zach, Map.Direction.S); Assert.AreEqual(startingPos, zach.Pos); //shouldn't move since its not his side's turn }
public void DMVisualizationTest() { var DM = DungeonMaster.GetDebugDM(data); string vis = DM.VisualizeWorld(); Assert.IsNotNull(vis); }
public void DeserializeAttackTest() { var DM = DungeonMaster.GetDebugDM(data); var robby = DM.Characters[0]; Assert.IsTrue(robby.Actions.Any(a => a.Name == "Attack")); //TODO: assert stuff about attack actions }
public void DebugAttackDodgeTest() { var DM = DungeonMaster.GetDebugDM(data); var attack = DebugData.GetDebugAttackAction(); var robby = DM.Characters[0]; var zach = DM.Characters[1]; int dodgeCards = 3; zach.Conditions.Add(new Condition("Dodging", dodgeCards)); DM.Activate(robby); zach.Pos = robby.Pos + Map.DirectionToPosition[Map.Direction.E]; Deck.SetFate(new List <string>() { "Dodge" }); var outcome = new Outcome(); attack.ResolveAction(DM, robby, null, zach, "", outcome); Assert.IsTrue(zach.Vitality.Value == zach.Vitality.Max); Assert.AreEqual(dodgeCards - 1, zach.Conditions.First(c => c.Name == "Dodging").Value); }