Example #1
0
            public void DifficultyRange(GoblinTypes type, int difficulty)
            {
                const int MaxDeviation_ATT = 2;
                const int MaxDeviation_DEF = 2;

                int    targetvalue_att = difficulty * 2;
                int    targetvalue_def = difficulty * 4;
                Entity ent             = GoblinFactory.createGoblin(type, difficulty);
                int    deviation_att   = Math.Abs(targetvalue_att - ent.Attack);
                int    deviation_def   = Math.Abs(targetvalue_def - ent.Defence);

                Assert.IsTrue(deviation_att <= MaxDeviation_ATT);
                Assert.IsTrue(deviation_def <= MaxDeviation_DEF);
            }
Example #2
0
            //[DataRow(GoblinTypes.archer, typeof(GoblinWarrior))]
            public void ClassValidity(GoblinTypes type, Type expected)
            {
                const int DIFF = 1;
                Entity    ent  = GoblinFactory.createGoblin(type, DIFF);

                try
                {
                    Convert.ChangeType(ent, expected);
                }
                catch
                {
                    Assert.Fail();
                }
            }
        public static Entity createGoblin(GoblinTypes type, int difficultyLevel)
        {
            Entity    enemy;
            const int ATT = 2;
            const int DEF = 4;

            switch (type)
            {
            default:
            case GoblinTypes.rogue: enemy = new Enemies.GoblinRogue("Goblin Rogue", 10, difficultyLevel * ATT, difficultyLevel * DEF); break;

            case GoblinTypes.warrior: enemy = new Enemies.GoblinWarrior("Goblin Warrior", 20, difficultyLevel * ATT, difficultyLevel * DEF); break;
            }
            return(enemy);
        }