Exemple #1
0
    def test_handling_weapon_level(self):
        """
        Testing handling of weapons
        """
        self.player.hit_points = 100
        self.player.add_item_to_backpack(
            database.get_item_from_db("Test spear"))
        self.player.use_item("Test spear")

        enemies = [Human(["Name", 20, 0, 2, 1, 50, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 0, 2, 1, 50, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 0, 2, 1, 50, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 0, 2, 1, 50, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 0, 2, 1, 50, 50, None, None, None, None,
                          None, None, None, None, None]),
                  ]

        for enemy in enemies:
            fight(self.player, enemy)
            self.assertEqual(enemy.hit_points, 0)
            self.assertEqual(enemy.given_damage, 0)

        self.assertEqual(self.player.spear_level, 2)
        self.assertEqual(int(self.player.damage
                             - self.player.weapon_type_damage(
                                 self.player.right_hand)), 6)
Exemple #2
0
    def test_creating_armor_set(self):
        """
        Testing creation of armor set
        """
        self.player.head = database.get_item_from_db("Heavy helmet")
        self.player.chest = database.get_item_from_db("Test chest")
        self.player.arms = database.get_item_from_db("Test arms")
        self.player.legs = database.get_item_from_db("Test legs")

        self.assertIsNotNone(self.player.head)
        self.assertIsNotNone(self.player.chest)
        self.assertIsNotNone(self.player.arms)
        self.assertIsNotNone(self.player.legs)

        armor_set = self.player.create_armor_set()

        self.assertEqual(len(armor_set), 4)
        self.assertEqual(sum(armor_set), 42)
Exemple #3
0
    def test_configuring_em(self):
        """
        Testing configuration of not player' equipment model
        """
        right_hand = database.get_item_from_db("Test spear")
        left_hand = database.get_item_from_db("Test buckler")
        helmet = database.get_item_from_db("Heavy helmet")
        chest = database.get_item_from_db("Test chest")
        arms = database.get_item_from_db("Test arms")
        legs = database.get_item_from_db("Test legs")

        human = Human(["Name", 20, 5, 2, 1, 50, 50, right_hand, left_hand,
                       helmet, chest, arms, legs, None, None, None])

        self.assertGreater(human.damage, 5)
        self.assertGreater(human.armor, 1)
        self.assertIsNotNone(human.left_hand)
        self.assertIsNotNone(human.right_hand)
        self.assertIsNotNone(human.head)
Exemple #4
0
 def test_using_item(self):
     self.player.add_item_to_backpack(
         database.get_item_from_db("Test spear"))
Exemple #5
0
    def test_handling_armor_level(self):
        """
        Testing handling of armor level
        """
        self.player.add_item_to_backpack(
            database.get_item_from_db("Heavy helmet"))
        self.player.add_item_to_backpack(
            database.get_item_from_db("Test chest"))
        self.player.add_item_to_backpack(
            database.get_item_from_db("Test arms"))
        self.player.add_item_to_backpack(
            database.get_item_from_db("Test legs"))

        self.player.use_item("Heavy helmet")
        self.player.use_item("Test chest")
        self.player.use_item("Test arms")
        self.player.use_item("Test legs")

        self.assertIsNotNone(self.player.head)
        self.assertIsNotNone(self.player.chest)
        self.assertIsNotNone(self.player.arms)
        self.assertIsNotNone(self.player.legs)

        self.assertEqual(self.player.armor
                         - sum(self.player.create_armor_set()), 2)

        enemies = [Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                   Human(["Name", 20, 30, 2, 1, 3, 50, None, None, None, None,
                          None, None, None, None, None]),
                  ]

        for enemy in enemies:
            fight(self.player, enemy)
            self.assertEqual(enemy.hit_points, 0)
            self.player.hit_points = self.player.max_hit_points
        self.assertEqual(self.player.heavy_armor_level, 2)