public void EnemyUpdateTest() { Node n = new Bridge(new Random(), 9, 200, 9); n.Player = testSubject.GetPlayer; MonsterCreator creator = new MonsterCreator(random, 1); Pack p = creator.GeneratePack(1); n.AddPack(p); testSubject.InitRoom(n); testSubject.GetPlayer.Location = new Point(2, 2); p[0].Location = new Point(2, 4); testSubject.Update('e'); Assert.AreEqual(p[0].Location, new Point(2, 3)); testSubject.Update('e'); Assert.AreEqual(testSubject.GetPlayer.MaxHP - p[0].damage, testSubject.GetPlayer.CurrentHP); int max = p[0].MaxHP; testSubject.Update('s'); if (max <= Player.strength) { Assert.AreEqual(0, p.Size); } else { Assert.AreEqual(p[0].MaxHP - Player.strength, p[0].CurrentHP); } }
public void Init() { random = new Random(); MonsterCreator M = new MonsterCreator(random, 1); e = M.GeneratePack(2)[0]; }
public void DefendOrderTest() { List <Node> nodes = new List <Node>(); Node a = new Node(random, 0, 15); Bridge b = new Bridge(random, 1, 15, 1); Node c = new Node(random, 2, 15); Bridge d = new Bridge(random, 2, 15, 2); Node e = new Node(random, 2, 15); a.AddGate(Exit.Right, b); b.AddGate(Exit.Left, a); b.AddGate(Exit.Right, c); c.AddGate(Exit.Left, b); c.AddGate(Exit.Right, d); d.AddGate(Exit.Left, c); d.AddGate(Exit.Right, e); e.AddGate(Exit.Left, d); nodes.Add(a); nodes.Add(b); nodes.Add(c); nodes.Add(d); nodes.Add(e); MonsterCreator mc = new MonsterCreator(random, 1); Pack p = mc.GeneratePack(1); c.AddPack(p); Dungeon dungeon = new Dungeon(random, nodes, 1, 15); Assert.IsTrue(dungeon.DefendOrder()); dungeon.MacroUpdate(); Assert.IsNotNull(b.CurrentPack); b.locked = false; p.GiveOrder(new Order(d)); p = mc.GeneratePack(1); c.AddPack(p); p = mc.GeneratePack(1); a.AddPack(p); Assert.IsTrue(dungeon.DefendOrder()); for (int i = 0; i < 10; i++) { dungeon.MacroUpdate(); } Assert.IsTrue(d.PackList.Count == 2); }
public void GeneratePackTest() { //Arrange MonsterCreator M = new MonsterCreator(r, 10); //Act Pack P = M.GeneratePack(50); //Assert Assert.IsNotNull(P); Assert.IsTrue(P.Enemies.Count >= 1); Assert.IsTrue(P.Enemies.Count <= 10); Assert.IsTrue(P.Enemies.Count <= P.Enemies.Capacity); }
public void TestMovementObstructedByEnemy() { //arrange MonsterCreator M = new MonsterCreator(random, 10); Pack testPack = M.GeneratePack(1); Node n = new Node(random, 1, 15); n.AddPack(testPack); testPack[0].Location = new Point(5, 5); p.Location = new Point(5, 4); //act and assert p.Move(Direction.Down, testPack); Assert.IsTrue(p.Location.X == 5 && p.Location.Y == 4); }
public void UpdateTest() { Node node = new Node(new NotSoRandom(0.0), 0, 20); Pack a = new Pack(0); node.AddPack(a); node.MacroUpdate(); Assert.IsTrue(node.PackList.Count == 0); MonsterCreator mc = new MonsterCreator(random, 6); Pack b = mc.GeneratePack(1); node.AddPack(b); node.MacroUpdate(); Assert.IsTrue(node.PackList.Count == 1); }
public void EnemyAdditionTest() { MonsterCreator creator = new MonsterCreator(new NotSoRandom(25), 25); Pack p = creator.GeneratePack(9001); Node node = new Node(random, 1024, 128); node.AddPack(p); for (int n = 0; n < 100; n++) { testSubject.InitRoom(node); for (int i = 0; i < p.Size; i++) { for (int j = 0; j < i; j++) { Assert.AreNotEqual(p[i].Location, p[j].Location, "Two enemies at the same place. The horror!"); } } } }
public void NoBridgeDefendOrderTest() { List <Node> nodes = new List <Node>(); Node a = new Node(random, 1, 10); Node b = new Node(random, 2, 10); nodes.Add(a); nodes.Add(b); MonsterCreator mc = new MonsterCreator(random, 1); Pack p = mc.GeneratePack(1); a.AddPack(p); Dungeon d = new Dungeon(random, nodes, 1, 10); Assert.IsFalse(d.DefendOrder()); }
public void PlayerDamageTest() { //arrange MonsterCreator M = new MonsterCreator(random, 10); Player p = new Player(); p.Location = new System.Drawing.Point(5, 5); Node node = new Node(random, 0, 100); Pack pack = M.GeneratePack(1); Enemy x = pack[0]; node.AddPack(pack); node.Player = p; x.Location = new System.Drawing.Point(4, 5); //act Assert.IsTrue(node.Move(x, p.Location)); e.KillTheHeretic(p); //assert Assert.IsTrue(p.CurrentHP < p.MaxHP); }
public void ImpossibleOrderTest() { List <Node> nodes = new List <Node>(); Node a = new Node(random, 0, 15); Node b = new Node(random, 1, 15); Node c = new Node(random, 2, 15); Node d = new Node(random, 3, 15); Node e = new Node(random, 4, 15); a.AddGate(Exit.Right, b); b.AddGate(Exit.Left, a); b.AddGate(Exit.Right, c); c.AddGate(Exit.Left, b); c.AddGate(Exit.Right, d); d.AddGate(Exit.Left, c); d.AddGate(Exit.Right, e); e.AddGate(Exit.Left, d); nodes.Add(a); nodes.Add(b); nodes.Add(c); nodes.Add(d); nodes.Add(e); Dungeon dungeon = new Dungeon(random, nodes, 1, 15); MonsterCreator mc = new MonsterCreator(random, 10); Pack p = mc.GeneratePack(1); e.AddPack(p); p.GiveOrder(new Order(a)); dungeon.MacroUpdate(); Assert.IsTrue(d.PackList.Count == 1); Assert.IsTrue(e.PackList.Count == 0); Assert.IsNotNull(p.order); dungeon.Destroy(b); dungeon.MacroUpdate(); Assert.IsNull(p.order); }
public void FakeOrderTest() { List <Node> nodes = new List <Node>(); Node a = new Node(random, 1, 10); nodes.Add(a); MonsterCreator mc = new MonsterCreator(random, 1); Pack p = mc.GeneratePack(1); a.AddPack(p); Dungeon d = new Dungeon(random, nodes, 1, 10); d.GiveOrder(null, 1); Assert.IsNull(p.order); p.GiveOrder(null); Assert.IsNull(p.order); }
public void PotionDropTest() { Node n = new Node(random, 0, 100); MonsterCreator mc = new MonsterCreator(new NotSoRandom(100), 100); Pack p = mc.GeneratePack(9001); n.AddPack(p); List <Node> nodes = new List <Node>(); nodes.Add(n); Dungeon dungeon = new Dungeon(random, nodes, 1, 101); Player player = new Player(); ItemGenerator.Init(random, dungeon, player); for (int i = 0; i < 100; i++) { Loot l = ItemGenerator.GetItem(0); if (l != null) { Assert.AreEqual(l.ID, 0); } } n.RemovePack(p); p = new Pack(1); p.Add(new Enemy("A", 'a', player.CurrentHP + player.GetPotCount * Potion.healPower - 1)); n.AddPack(p); for (int i = 0; i < 100; i++) { Loot l = ItemGenerator.GetItem(0); Assert.IsNull(l); } }