Exemplo n.º 1
0
        public void FullPackTest()
        {
            for (int i = 0; i < 100; i++)
            {
                //Arrange
                int   size = r.Next(-1000000, 1000000);
                Pack  P    = new Pack(size);
                Enemy e    = new Enemy("Giant Goblin", 'G', 30);

                if (size <= 0)
                {
                    size = 1;
                }
                //Act
                for (int j = 0; j < size + 5; j++)
                {
                    P.Add(e);
                }
                //Assert
                Assert.IsNotNull(P);
                Assert.IsTrue(P.Enemies.Capacity >= P.Enemies.Count);
                Assert.IsTrue(P.Enemies.Contains(e));
                if (size > 0)
                {
                    Assert.IsTrue(P.Enemies.Count == size);
                }
            }
        }
Exemplo n.º 2
0
        public void OrderFullNodeTest()
        {
            List <Node> nodes = new List <Node>();
            Node        a     = new Node(random, 0, 1);
            Node        b     = new Node(random, 1, 1);

            a.AddGate(Exit.Right, b);
            b.AddGate(Exit.Left, a);

            nodes.Add(a);
            nodes.Add(b);

            Dungeon dungeon = new Dungeon(random, nodes, 1, 1);

            Pack p = new Pack(1);

            p.Add(new Enemy("", 'a', 10));
            b.AddPack(p);
            p.GiveOrder(new Order(a));

            dungeon.MacroUpdate();
            Assert.AreEqual(a.PackList.Count, 1);
            Assert.AreEqual(b.PackList.Count, 0);

            p = new Pack(1);
            p.Add(new Enemy("", 'a', 10));
            b.AddPack(p);
            p.GiveOrder(new Order(a));

            dungeon.MacroUpdate();
            Assert.AreEqual(a.PackList.Count, 1);
            Assert.AreEqual(b.PackList.Count, 1);
        }
Exemplo n.º 3
0
        public void PlayerCombatTest()
        {
            Pack  pa     = new Pack(1);
            Enemy badGuy = new Enemy("long name", 'l', (int)(Player.strength * 2.5));

            pa.Add(badGuy);
            p.Combat(badGuy);
            Assert.IsTrue(badGuy.Alive);
            Assert.AreEqual((int)Player.strength * 1.5, badGuy.CurrentHP);
            p.AddItem(new Loot(2, '2'));
            p.UseItem(new MagicScroll(new NotSoRandom(0f), null), null);
            p.Combat(badGuy);
            Assert.IsFalse(badGuy.Alive);
            Assert.AreEqual(p.GetScore, badGuy.GetScore());
        }
Exemplo n.º 4
0
        /*CONSTRUCTORS ----------------------------------------------------------------------------------------------------*/
        /*Constructor: Default
                       1) Creates a default, unshuffled MatchDeck object
                       2) Loops through suits array twice to create 24 cards, and places them
                          in the property Pack */
        public MatchDeck()
        {
            this.Pack = new List<Card>(); // initialising List to avoid problems
            this.DeckImg = "Images/mdb.png";

            for (int i = 0; i < suits.Length; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    Card c = new Card();
                    c.Suit = suits[i];
                    // NOTE: the Image property will be the same for 2 cards in the MatchDeck
                    c.Image = $"Images/MatchCards/{suits[i]}.png";
                    Pack.Add(c); // adding new card to deck
                }
            }// end nested for block
        }// end Default constructor
Exemplo n.º 5
0
        public void EnemyMovementTest()//test if monsters do not enter the spaces of other monsters in their pack
        {
            Node n = new Node(random, 0, 100);
            //arrange
            MonsterCreator M    = new MonsterCreator(random, 20);
            Pack           pack = new Pack(10);

            while (pack.Enemies.Count < pack.Enemies.Capacity)
            {
                Enemy x = M.CreateMonster(1);
                pack.Add(x);
            }

            Player p = new Player();
            Enemy  y = pack[0];

            p.Location       = new System.Drawing.Point(5, 5);
            pack[1].Location = new System.Drawing.Point(5, 4);
            pack[2].Location = new System.Drawing.Point(4, 5);
            pack[3].Location = new System.Drawing.Point(6, 5);
            pack[4].Location = new System.Drawing.Point(5, 6);
            pack[5].Location = new System.Drawing.Point(4, 4);
            pack[6].Location = new System.Drawing.Point(3, 3);

            n.AddPack(pack);
            n.Player = p;

            y.Location = new System.Drawing.Point(2, 2);
            //act
            for (int i = 0; i < 100; i++)
            {
                n.Move(y, p.Location);
                //assert
                foreach (Enemy en in pack)
                {
                    if (en != y)
                    {
                        Assert.AreNotEqual(y.Location, en.Location);
                    }
                }
            }
        }
Exemplo n.º 6
0
        public void UnlockNodeTest()
        {
            List <Node> nodes  = new List <Node>();
            Bridge      b      = new Bridge(random, 0, 10, 1);
            Dungeon     d      = new Dungeon(random, nodes, 1, 10);
            Player      player = new Player(101);

            ItemGenerator.Init(random, d, new Player());
            Pack p = new Pack(1);

            p.Add(new Enemy("A", 'a', 1));
            b.AddPack(p);
            b.MicroUpdates();
            Assert.IsTrue(b.locked);
            player.OP = true;
            player.Combat(p.Enemies[0]);
            b.MicroUpdates();
            Assert.IsFalse(b.locked);
            b.locked = true;
            b.MicroUpdates();
            Assert.IsFalse(b.locked);
        }
Exemplo n.º 7
0
        public void FleeingEnemyTest()
        {
            List <Node> nodes = new List <Node>();
            Node        a     = new Node(random, 0, 10);
            Node        b     = new Node(random, 1, 10);

            b.AddGate(Exit.Left, a);
            b.leftLocation = Node.minDoorSize;
            Dungeon d      = new Dungeon(random, nodes, 1, 10);
            Player  player = new Player();

            b.Player        = player;
            player.Location = new Point(5, b.leftLocation);
            Pack p = new Pack(1);

            p.Add(new Enemy("A", 'a', 10, 5, 5));
            b.AddPack(p);
            p.Enemies[0].Location = new Point(6, b.leftLocation);
            p.Enemies[0].Hit(9);
            b.MicroUpdates();
            Assert.AreEqual(p.Enemies[0].Location, new Point(6, b.leftLocation));
            Assert.AreEqual(player.CurrentHP, player.MaxHP);
        }
Exemplo n.º 8
0
        /*CONSTRUCTORS ----------------------------------------------------------------------------------------------------*/
        /*Constructor: Default
                       1) Creates a default, unshuffled PlayingDeck object
                       2) Loops through suits and ranks arrays to create 52 cards, and places them
                          in the property Pack */
        public PlayingDeck()
        {
            this.Pack = new List<Card>(); // initialising List to avoid problems
            this.DeckImg = @"ProjectGameInterface/Images/pdb.png";
            for (int i = 0; i < suits.Length; i++)
            {
                for (int j = 0; j < ranks.Length; j++)
                {
                    Card c = new Card();
                    c.Suit = suits[i];
                    c.Rank = ranks[j];
                    c.Image = $"Images/PlayingCards/{ranks[j]}{suits[i].Substring(0,1)}.png";

                    // assigning the default point value for each card
                    if (j <= 8)
                        c.Point = j + 1; // the point value for ace is set to 1 at this time
                    else
                        c.Point = 10;  // cards 10 to King will be worth 10 points

                    Pack.Add(c); // adding new card to deck
                }
            }// end nested for block
        }// end Default constructor
Exemplo n.º 9
0
        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);
            }
        }
Exemplo n.º 10
0
        /*CONSTRUCTORS ----------------------------------------------------------------------------------------------------*/
        /*Constructor: Default
                       1) Creates a default, unshuffled TarotDeck object
                       2) Loops through majorArcana, minorSuits and minorRanks arrays to create 78 cards, and places them
                          in the property Pack */
        public TarotDeck()
        {
            this.Pack = new List<Card>(); // initialising Pack first to avoid problems
            this.DeckImg = "Images/tdb.png";

            // looping through all major cards and adding them to the Pack list
            for (int i = 0; i < majorArcana.Length; i++)
            {
                Card c = new Card();
                c.Suit = "major";
                c.Rank = majorArcana[i];
                c.Image = "Images/TarotCards/placeholder.png";

                // Note: from Ace to King in minor is 1 - 14, should start with Fool at 15
                c.Point = i + 15;
                c.Position = true; // this just means the card was pulled upright
                Pack.Add(c); // adding new card to deck
            }

            // looping through all minor cards and adding them to the Pack list
            for (int i = 0; i < minorSuits.Length; i++)
            {
                for (int j = 0; j < minorRanks.Length; j++)
                {
                    Card c = new Card();
                    c.Suit = minorSuits[i];
                    c.Rank = minorRanks[j];
                    c.Image = "Images/TarotCards/placeholder.png";

                    // assigning the default point value for each card
                    c.Point = j + 1; // start with Ace and make it worth 1
                    c.Position = true;
                    Pack.Add(c); // adding new card to deck
                }
            }// end nested for block
        }// end Default constructor
Exemplo n.º 11
0
        public void CombatItemEffectTest()
        {
            Pack enemies = new Pack(4);
            int  initHp  = 10 * Player.strength;

            for (int i = 0; i < 4; i++)
            {
                enemies.Add(new Enemy("Test", 't', initHp));
            }
            p.Combat(enemies[0]);
            p.inventory = new byte[] { 2, 2, 2 };

            Assert.AreEqual(initHp - Player.strength, enemies[0].CurrentHP, "base");
            for (int i = 1; i < 3; i++)
            {
                Assert.AreEqual(100, enemies[i].CurrentHP, "base");
            }

            DungeonCreator dc      = new DungeonCreator(random);
            Dungeon        dungeon = dc.CreateDungeon(1, 0, 10);
            TimeCrystal    crystal = new TimeCrystal();

            crystal.Duration = 1;

            dungeon.nodes[1].Player = p;

            dungeon.nodes[0].AddPack(enemies);

            p.UseItem(crystal, dungeon);

            int orderCount = 0;

            foreach (Node n in dungeon.nodes)
            {
                foreach (Pack thisVerySpecialSuperPack in n.PackList)
                {
                    if (thisVerySpecialSuperPack.order == Order.HuntOrder)
                    {
                        orderCount++;
                    }
                }
            }

            Assert.AreEqual(orderCount, 1);

            p.Combat(enemies[1]);
            Assert.AreEqual(initHp - 2 * Player.strength, enemies[0].CurrentHP, "Crystal");
            for (int i = 1; i < 3; i++)
            {
                Assert.AreEqual(initHp - Player.strength, enemies[i].CurrentHP, "Crystal");
            }

            MagicScroll scroll = new MagicScroll(new NotSoRandom(0.0), null);

            scroll.Duration = 2;
            p.UseItem(scroll, null);

            p.Combat(enemies[2]);
            Assert.AreEqual(initHp - 4 * Player.strength, enemies[0].CurrentHP, "Scroll and Crystal");
            for (int i = 1; i < 3; i++)
            {
                Assert.AreEqual(initHp - 3 * Player.strength, enemies[i].CurrentHP, "Scroll and Crystal");
            }

            p.UpdateItems();
            p.Combat(enemies[3]);
            Assert.AreEqual(initHp - 6 * Player.strength, enemies[0].CurrentHP, "Scroll and Crystal last time");
            for (int i = 1; i < 3; i++)
            {
                Assert.AreEqual(initHp - 5 * Player.strength, enemies[i].CurrentHP, "Scroll and Crystal last time");
            }

            p.UpdateItems();
            p.Combat(enemies[0]);
            Assert.AreEqual(initHp - 8 * Player.strength, enemies[0].CurrentHP, "Scroll and no more Crystal");
            for (int i = 1; i < 3; i++)
            {
                Assert.AreEqual(initHp - 5 * Player.strength, enemies[i].CurrentHP, "Scroll and no more Crystal");
            }

            MagicScroll scroll2 = new MagicScroll(new NotSoRandom(0.0), null);

            scroll2.Duration = 0;
            p.UseItem(scroll2, null);

            p.Combat(enemies[1]);
            Assert.AreEqual(initHp - 8 * Player.strength, enemies[0].CurrentHP, "Back to Normal");
            Assert.AreEqual(initHp - 9 * Player.strength, enemies[1].CurrentHP, "Back to Normal");
            for (int i = 2; i < 3; i++)
            {
                Assert.AreEqual(initHp - 5 * Player.strength, enemies[i].CurrentHP, "Back to Normal");
            }

            p.UpdateItems();
            p.Combat(enemies[0]);
            Assert.AreEqual(initHp - 9 * Player.strength, enemies[0].CurrentHP, "Back to Normal");
            Assert.AreEqual(initHp - 9 * Player.strength, enemies[1].CurrentHP, "Back to Normal");
            for (int i = 2; i < 3; i++)
            {
                Assert.AreEqual(initHp - 5 * Player.strength, enemies[i].CurrentHP, "Back to Normal");
            }
        }