コード例 #1
0
    def test_object_Creature_attack_method(self):
        hero = dungeon_dudes.Hero('Generic Hero Name')
        creature = dungeon_dudes.Creature(1)

        hero.attack(creature)
        creature.attack(hero)

        print(hero)
        print(creature)
コード例 #2
0
    def test_object_Creature_damage_method(self):
        creature = dungeon_dudes.Creature(0)
        creature.take_damage(1)
        self.assertEqual(creature.hp, creature.maxHp - 1)
        self.assertEqual(creature.maxHp,
                         dungeon_dudes.Creature.creatureList[0][0])

        #Tests to make hp never drops below 0
        creature.take_damage(10)
        self.assertEqual(creature.hp, 0)
コード例 #3
0
 def test_object_Creature_creation(self):
     creature = dungeon_dudes.Creature(1)
     self.assertEqual(creature.creatureType, 1)
     self.assertEqual(creature.hp,
                      dungeon_dudes.Creature.creatureList[1][0])
     self.assertEqual(creature.maxHp,
                      dungeon_dudes.Creature.creatureList[1][0])
     self.assertEqual(creature.name,
                      dungeon_dudes.Creature.creatureList[1][2])
     self.assertEqual(creature.diceRolls,
                      dungeon_dudes.Creature.creatureList[1][1])
コード例 #4
0
 def test_object_Creature_str_method(self):
     creature = dungeon_dudes.Creature(1)
     string = creature.__str__()
     self.assertEqual(string, 'Giant Rat: 2/2 hp')
コード例 #5
0
 def test_object_Creature_is_dead_method(self):
     creature = dungeon_dudes.Creature(0)
     creature.take_damage(creature.hp)
     self.assertTrue(creature.is_dead())