def test_troll_take_damage_1(self): troll = Troll(name='Org') troll.take_damage(10) self.assertEqual(troll.hit_points, 13) self.assertEqual(troll.lives, 1) troll.take_damage(13) self.assertEqual(troll.hit_points, 0) self.assertEqual(troll.lives, 0) troll.take_damage(5) self.assertEqual(troll.hit_points, 0) self.assertEqual(troll.lives, 0)
from enemy import Enemy, Troll, Vampire ugly_troll = Troll("Pug") print("Ugly troll - {}".format(ugly_troll)) another_troll = Troll("Ug") print("Another troll - {}".format(another_troll)) another_troll.take_damage(18) print(another_troll) brother = Troll("Urg") print(brother) ugly_troll.grunt() another_troll.grunt() brother.grunt() vamp = Vampire("Vlad") print(vamp) vamp.take_damage(5) print(vamp) print("-" * 40) another_troll.take_damage(30) print(another_troll) # while vamp.alive: # if not vamp.dodges(): # vamp.take_damage(1) # print(vamp)
tim.lives = -1 tim.level = 0 print("-" * 40) enemy = Enemy("Ogre") print(enemy) bigogre = Enemy("BigOgre", 25, 1) print(bigogre) bigogre.take_damage(10) troll = Troll("Ug") print(troll) print("troll taking damage 30 ") troll.take_damage(30) print("-" * 40) vamp = Vampire("dracula") print(vamp) print("dracula taking damage 15 ") vamp.take_damage(15) vamp2 = Vampire("dracula_2") print(vamp2) print("dracula_2 taking damage 55 ") vamp2.take_damage(55) print("dracula_2 again taking damage 35 ") vamp2.take_damage(35)
print("=" * 40) print("Calling Troll5 - grunt") print() print("=" * 20) ugly_troll = Troll5("Ugly_troll") ugly_troll.grunt() print("=" * 20) ugly_troll2 = Troll5("Ugly_troll2") ugly_troll2.grunt() print("=" * 20) ugly_troll3 = Troll5("Ugly_troll3") ugly_troll3.grunt() ugly_troll3.take_damage(5) print(ugly_troll3) # =============================================== # Test Vampire class # =============================================== # import vampire class from enemy import Vampire # Then we create an instance of Vampire and call Vampire class and pass it name (vamp_vlad) print("=" * 20) vamp = Vampire("Vamp_vlad") print(vamp)
random_monster = Enemy("Basic enemy", 12, 1) print(random_monster) random_monster.take_damage(4) print(random_monster) ugly_troll = Troll("Pug") print("Ugly troll - {}".format(ugly_troll)) another_troll = Troll("Ug") print("Another troll - {}".format(another_troll)) brother = Troll("Urg") print(brother) brother.take_damage(3) ugly_troll.grunt() another_troll.grunt() brother.grunt() vamp = Vampyre("Poo") print("new_vampyre - {}".format(vamp)) vamp.take_damage(4) print(vamp) another_vamp = Vampyre("Akash") print("another_vamp - {}".format(another_vamp)) another_vamp.take_damage(3)
from player import Player from enemy import Enemy, Troll, Vampire, VampireKing barney = Troll("Barney") print("Ugly troll - {0._name}".format(barney)) barney.grunt() barney.take_damage(15) print(barney) print("*" * 40) gerard = Vampire("Gerard") print(gerard) gerard.take_damage(10) print(gerard) while gerard._alive: gerard.take_damage(1) print(gerard) print("*" * 40) king = VampireKing("King") print(king) king.take_damage(8) print(king)
from player import Player from enemy import Enemy, Troll, Vampyre, VampyreKing random_monster = Enemy("Basic enemy", 12, 1) print(random_monster) random_monster.take_damage(4) print(random_monster) ugly_troll = Troll("Pug") ugly_troll.take_damage(20) print("Ugly Troll - {}".format(ugly_troll)) another_troll = Troll("Ug") print("Another Troll - {}".format(another_troll)) brother_troll = Troll("Urg") print("Brother - {}".format(brother_troll)) ugly_troll.grunt() another_troll.grunt() brother_troll.grunt() vamp = Vampyre("Vlad") vamp.take_damage(7) print(vamp) king = VampyreKing("Dracula") while vamp._alive:
print("Ugly troll - {}".format(ugly_troll)) another_troll = Troll("Ug") print("Another troll - {}".format(another_troll)) brother = Troll("Urg") print(brother) ugly_troll.grunt() another_troll.grunt() brother.grunt() # will fail # monster = Enemy("Basic enemy") # monster.grunt() ugly_troll.take_damage(12) marty = Vampire("Marty") marty.take_damage(10) print(marty) print("-" * 40) ugly_troll.take_damage(30) print(ugly_troll) # while marty.alive: # marty.take_damage(1) # print(marty) marty._lives = 0 marty._hit_points = 1
#instantiate objects from sub class Troll #Note only name arg is requierd. enemy super class args for hit_points and lives are used ugly_troll = Troll("Pug") print(f"Ugly Troll - {ugly_troll}") #instantiate object another_troll from sub class Troll #Note new args are passed in another_troll = Troll("Ug") print(f"another Troll - {another_troll}") brother = Troll("Urg") print(f"brother - {brother}") ugly_troll.grunt() ugly_troll.take_damage(2) another_troll.grunt() another_troll.take_damage(1) brother.grunt() brother.take_damage(3) John = vampier("John") print(f"John - {John}") John.take_damage(3) print("-" * 40) while John.alive:
from enemy import Troll, Vampyre, VampyreKing from player import Player a = 3 b = "tim" c = 1, 2, 3 print(a) print(b) print(c) p1 = Player("Peter") print(p1) t1 = Troll("To") t1.take_damage(5) print(t1) v1 = Vampyre("Vlad") print(v1) v1.take_damage(3) print(v1) v2 = VampyreKing("Dave") print(v2) v2.take_damage(16) print(v2)
from player import Player from enemy import Enemy, Troll, Vampire tim = Player('Tim') ugly_troll = Troll('Pug') print('Ugly troll - {}'.format(ugly_troll)) another_troll = Troll('Ug') print('Another troll - {}'.format(another_troll), end='\n') brother = Troll('Urg') print('Brother troll - {}'.format(brother)) ugly_troll.grunt() another_troll.grunt() brother.grunt() dracula = Vampire('Drac') print('Vampire - {}'.format(dracula)) dracula.take_damage(10) print(dracula) dracula.take_damage(3) print(dracula) brother.take_damage(4) print(brother)
from enemy import Enemy, Troll, Vampire, VampireKing ugly_troll = Troll("Pug") print("Ugly troll - {}".format(ugly_troll)) another_troll = Troll("Ug") print("Another troll - {}".format(another_troll)) brother = Troll("Urg") print(brother) ugly_troll.grunt() another_troll.grunt() brother.grunt() ugly_troll.take_damage(5) another_troll.take_damage(10) brother.take_damage(3) print(ugly_troll) print(another_troll) print(brother) print("=" * 60) pierre = Vampire("Pierre") vlad = Vampire("Vlad") vamp = Vampire("Drac") vamp_king = VampireKing("Ulrik") # print("Creepy vampire - {}".format(pierre))
from enemy import Troll, Vampire, VampireKing ugly_troll = Troll("Pug") print("Ugly troll - {}".format(ugly_troll)) another_troll = Troll("Ug") print("Another troll - {}".format(another_troll)) brother = Troll("Urg") print("Brother - {}".format(brother)) brother.take_damage(20) print("Brother - {}".format(brother)) ugly_troll.grunt() another_troll.grunt() brother.grunt() nosferatu = Vampire("Nosferatu") print(nosferatu) print("-" * 40) another_troll.take_damage(30) print(another_troll) nosferatu._lives = 0 nosferatu._hit_points = 1 print(nosferatu) print("-" * 40) dracula = VampireKing("Dracula") print(dracula)
pug = Troll('Pug') print("Ugly Troll - {}".format(pug)) ug = Troll('Ug') print("Another Troll - {}".format(ug)) urg = Troll('Urg') print(urg) pug.grunt() ug.grunt() urg.grunt() drakula = Vampire('drakula') print(drakula) pug.take_damage(2) print(pug) drakula.take_damage(2) print(drakula) while drakula._alive: drakula.take_damage(1) #print(drakula) super_draku = VampireKing('KING D.') print(super_draku) while super_draku._alive: super_draku.take_damage(49)
troll1 = Troll( 'Troll-1' ) # will take the init method of its superclass Enemy with default arguments's value print(troll1) troll2 = Troll('Troll-2') print(troll2) troll3 = Troll('Troll-3') print(troll3) troll1.grunt() troll2.grunt() troll1.take_damage(4) print(troll1) troll1.take_damage(20) print(troll1) troll2.take_damage(20) print(troll2) troll2.take_damage(2) print(troll2) troll2.take_damage(1) print(troll2) troll2.take_damage(1)
kuro = Vampire("kuro") shiro = Vampire("shiro") print(kuro) print(shiro) kuro.take_damage(134) shiro.take_damage(24) print(kuro) print(shiro) print('><' * 50) while toll.alive: print(toll) toll.take_damage(random.randint(1, 5)) print(toll) print('><' * 50) while kuro.alive: print(kuro) kuro.take_damage(1) print(kuro) print('><' * 50) shiki = Vampireking("shiki") print(shiki) shiki.take_damage(12) print(shiki)
from enemy import Enemy, Troll, Vampire, VampireKing random_monster = Enemy("Gupta", 12, 1) print(random_monster) random_troll = Troll("Pug") print(random_troll) brother = Troll("Kauwa") print(brother) brother.grunt() brother.take_damage(51) vamp = Vampire("Ujjwal") print(vamp) vampKing = VampireKing("ad") print(vampKing)
from enemy import Enemy, Troll, Vampire, VampireKing ugly_troll = Troll("Pug") print("Ugly troll - {}".format(ugly_troll)) another_troll = Troll("Ug") print("Another troll - {}".format(another_troll)) brother = Troll("Urg") print(brother) ugly_troll.grunt() another_troll.grunt() brother.grunt() awaken_vampire = Vampire("Sleepy") print(awaken_vampire) awaken_vampire.take_damage(10) print(awaken_vampire) awaken_vampire.take_damage(5) print(awaken_vampire) ugly_troll.take_damage(25) print(ugly_troll) vlad = VampireKing("Vlad The King") while vlad._alive: vlad.take_damage(20) # print(awaken_vampire)
from enemy import Enemy, Troll, Vampire, VampireKing ugly_troll = Troll("Pug") print("Ugly Troll - {}".format(ugly_troll)) ugly_troll.take_damage(3) another_troll = Troll("Ug") print("Another Troll - {}".format(another_troll)) brother = Troll("Urg") print(brother) ugly_troll.grunt() another_troll.grunt() brother.grunt() big_Vampire = Vampire("Draculator") print(big_Vampire) big_Vampire.take_damage(7) small_Vampire = Vampire("Draculin") print(small_Vampire) small_Vampire.take_damage(2) print("*" * 80) while big_Vampire.alive: big_Vampire.take_damage(1) dracula = VampireKing("Dracula") print(dracula)