Example #1
0
    def test_wrong_tower_name(self):
        """test case when a tower has no valid name (0,1,2,...)"""

        resources.tower['test_tower'] = {}
        for lvl in range(1, 4):
            att_dict = eval(
                str({
                    'tower': 12,
                    'lvl': lvl,
                    'image': 'tower01.png',
                    'damage': 7,
                    'range': 200,
                    'firerate': 2,
                    'projectileSpeed': 1000,
                    'cost': 50,
                    'projectileImage': 'projectile01.png',
                    'effect': 'normal',
                    'effectDuration': 5,
                    'effectFactor': 0
                }))
            try:
                att_dict["image"] = resources.load_image("tower01.png")
            except FileNotFoundError:
                print("Error: Image not found: {}".format("tower01.png"))
            try:
                att_dict["projectileImage"] = resources.load_image(
                    "projectile01.png")
            except FileNotFoundError:
                print("Error: Image not found: {}".format("projectile01.png"))
            resources.tower['test_tower'][lvl] = att_dict
        director.init(**settings['window'])
        pyfense.HelpLayer.on_enter(pyfense.HelpLayer())
Example #2
0
    def test_new_tower(self):
        """test case when new tower is added without modifying anything in
        pyfense
        """

        testtower_name = len(resources.tower) + 1
        resources.tower[testtower_name] = {}
        for lvl in range(1, 4):
            att_dict = eval(
                str({
                    'tower': testtower_name,
                    'lvl': lvl,
                    'image': 'tower01.png',
                    'damage': 7,
                    'range': 200,
                    'firerate': 2,
                    'projectileSpeed': 1000,
                    'cost': 50,
                    'projectileImage': 'projectile01.png',
                    'effect': 'normal',
                    'effectDuration': 5,
                    'effectFactor': 0
                }))
            try:
                att_dict["image"] = resources.load_image("tower01.png")
            except FileNotFoundError:
                print("Error: Image not found: {}".format("tower01.png"))
            try:
                att_dict["projectileImage"] = resources.load_image(
                    "projectile01.png")
            except FileNotFoundError:
                print("Error: Image not found: {}".format("projectile01.png"))
            resources.tower[testtower_name][lvl] = att_dict
        director.init(**settings['window'])
        pyfense.HelpLayer.on_enter(pyfense.HelpLayer())
Example #3
0
    def test_new_tower(self):
        """test case when new tower is added without modifying anything in
        pause
        """

        testtower_name = len(resources.tower) + 1
        resources.tower[testtower_name] = {}
        for lvl in range(1, 4):
            att_dict = eval(
                str({'tower': testtower_name, 'lvl': lvl,
                     'image': 'tower01.png',
                     'damage': 7, 'range': 200, 'firerate': 2,
                     'projectileSpeed': 1000, 'cost': 50,
                     'projectileImage': 'projectile01.png',
                     'effect': 'normal', 'effectDuration': 5,
                     'effectFactor': 0}))
            try:
                att_dict["image"] = resources.load_image("tower01.png")
            except FileNotFoundError:
                print("Error: Image not found: {}".format("tower01.png"))
            try:
                att_dict["projectileImage"] = resources.load_image(
                    "projectile01.png")
            except FileNotFoundError:
                print("Error: Image not found: {}".format("projectile01.png"))
            resources.tower[testtower_name][lvl] = att_dict
        director.init(**settings['window'])
        pause.PauseLayer.__init__(pause.PauseLayer())
Example #4
0
 def initiate_projectile(self):
     self.testGame = game.PyFenseGame(1)
     self.testPath = self.testGame.movePath
     self.image = resources.load_image('projectile01.png')
     self.testTower = tower.PyFenseTower(0, (50, 70))
     self.testEnemy = enemy.PyFenseEnemy(
         (50, 40), 0, 1, 1, self.testPath, 2)
     self.testProjectile = projectile.PyFenseProjectile(
         self.testTower, self.testEnemy, self.image, 0, 0,
         1000, 50, 'normal', 5, 1)
Example #5
0
 def initiate_projectile(self):
     self.testGame = game.PyFenseGame(1)
     self.testPath = self.testGame.movePath
     self.image = resources.load_image('projectile01.png')
     self.testTower = tower.PyFenseTower(0, (50, 70))
     self.testEnemy = enemy.PyFenseEnemy((50, 40), 0, 1, 1, self.testPath,
                                         2)
     self.testProjectile = projectile.PyFenseProjectile(
         self.testTower, self.testEnemy, self.image, 0, 0, 1000, 50,
         'normal', 5, 1)
Example #6
0
    def test_wrong_tower_name(self):
        """test case when a tower has no valid name (0,1,2,...)"""

        resources.tower['test_tower'] = {}
        for lvl in range(1, 4):
            att_dict = eval(
                str({'tower': 12, 'lvl': lvl, 'image': 'tower01.png',
                     'damage': 7, 'range': 200, 'firerate': 2,
                     'projectileSpeed': 1000, 'cost': 50,
                     'projectileImage': 'projectile01.png',
                     'effect': 'normal', 'effectDuration': 5,
                     'effectFactor': 0}))
            try:
                att_dict["image"] = resources.load_image("tower01.png")
            except FileNotFoundError:
                print("Error: Image not found: {}".format("tower01.png"))
            try:
                att_dict["projectileImage"] = resources.load_image(
                    "projectile01.png")
            except FileNotFoundError:
                print("Error: Image not found: {}".format("projectile01.png"))
            resources.tower['test_tower'][lvl] = att_dict
        director.init(**settings['window'])
        pause.PauseLayer.__init__(pause.PauseLayer())