Esempio n. 1
0
            public void ClassValidity(SpiderTypes type, Type expected)
            {
                const int DIFF = 1;
                Entity    ent  = SpiderFactory.createSpider(type, DIFF);

                try
                {
                    Convert.ChangeType(ent, expected);
                }
                catch
                {
                    Assert.Fail();
                }
            }
Esempio n. 2
0
            public void DifficultyRange(SpiderTypes 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             = SpiderFactory.createSpider(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);
            }
Esempio n. 3
0
        public static Entity createSpider(SpiderTypes type, int difficultyLevel)
        {
            Entity    enemy;
            const int ATT = 2;
            const int DEF = 4;

            switch (type)
            {
            default:
            case SpiderTypes.normal: enemy = new Enemies.Spider("normal spider", 10, difficultyLevel * ATT, difficultyLevel * DEF); break;

            case SpiderTypes.giant: enemy = new Enemies.GiantSpider("giant spider", 20, difficultyLevel * ATT, difficultyLevel * DEF); break;

            case SpiderTypes.poison: enemy = new Enemies.PoisonSpider("poison spider", 10, difficultyLevel * ATT, difficultyLevel * DEF); break;
            }
            return(enemy);
        }