Beispiel #1
0
 def test_vampyre_king_take_damage(self):
     from random import randint
     vampyre_king = VampyreKing('Vampire King')
     while vampyre_king.lives != 0:
         damage = randint(1, 140)
         lives_b4 = vampyre_king.lives
         hit_points_b4 = vampyre_king.hit_points
         vampyre_king.take_damage(damage)
         self.assertTrue(
             TestVampyreKing._damage_inflicted_correctly(
                 damage, lives_b4, hit_points_b4, vampyre_king))
Beispiel #2
0
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)
#random_monster.take_damage(8)
#print(random_monster)
#random_monster.take_damage(9)
#print(random_monster)

#ugly_troll = Troll()
#print("Ugly troll - {}".format(ugly_troll))
#
#another_troll = Troll("ug", 18, 1)
#print("Another troll - {}".format(another_troll))
#
#brother = Troll("Urg", 23)
#print(brother)
#brother.grunt()
#brother.take_damage(5)

vamp = Vampyre("Vlad")
while vamp.alive:
    vamp.take_damage(1)
#    print(vamp)

vampTheGreat = VampyreKing("Big Vlad")
while vampTheGreat.alive:
    vampTheGreat.take_damage(8)
Beispiel #3
0
vamp.take_damage(4)
print(vamp)

another_vamp = Vampyre("Akash")
print("another_vamp - {}".format(another_vamp))
another_vamp.take_damage(3)

print("*" * 40)

another_troll.take_damage(35)
print(another_troll)

vamp._live = 0
vamp._hit_points = 1
print(vamp)

king = VampyreKing("Piyush")
print("VampyreKing - {}".format(king))
king.take_damage(12)
print(king)

king.take_damage(15)
print(king)

king.take_damage(700)
print(king)

king.take_damage(15)
print(king)
Beispiel #4
0
another_troll = Troll("Ug")
print("Another troll - {}".format(another_troll))
another_troll.take_damage(18)
print(another_troll)

brother_troll = Troll("Urg")
print("Brother troll - {}".format(brother_troll))

ugly_troll.grunt()
another_troll.grunt()
brother_troll.grunt()

vamp = Vampyre("Vlad")
print(vamp)

vamp.take_damage(5)
print(vamp)

print("-" * 40)
another_troll.take_damage(30)
print(another_troll)

while vamp.alive:
    vamp.take_damage(1)
    # print(vamp)

vamp_king = VampyreKing("Dracula")
print(vamp_king)
vamp_king.take_damage(8)
print(vamp_king)
Beispiel #5
0
dracula.take_damage(4)
print(dracula)

print("-" * 40)
another_troll.take_damage(30)
print(another_troll)

while dracula._alive:
    dracula.take_damage(1)
    #print(dracula)

vlad = VampyreKing("Vlad")
print(vlad)

while vlad._alive:
    vlad.take_damage(4)

# print(tim.name)
# print(tim.lives)

# tim.lives -= 1
# print(tim.lives)

# print(tim)

# tim._set_level(3)
# print(tim)

# tim._set_level(2)
# print(tim)
Beispiel #6
0
kyle = Player("Kyle")
print(kyle)

hatdog = Enemy("Hatdog", 11, 12)
print(hatdog)

random_monster = Troll("Jorb")
print("Ugly troll - {}".format(random_monster))

another_troll = Troll("Ug")
print(another_troll)

broda = Troll("Urg")
print(broda)

broda.grunt()
another_troll.grunt()
random_monster.grunt()

drac = Vampyre("Drac")
print(drac)

# while drac._alive:
#     drac.take_damage(1)
#     #print(drac)

king = VampyreKing("Robert")
print(king)
while king._hit_points >= 0 and king._lives > 0:
    king.take_damage(200)
    print(king)
"""
Section 10 Challenge - Inheritance
To help consolidate your understanding of Inheritance, we've got a challenge for you to try out.
The challenge is to create a VampyreKing subclass of Vampyre.

A VampyreKing is going to be incredibly powerful, and any points of damage inflicted will be divided by 4.
VampyreKing objects will also start off with 140 hit points.

So extend Vampyre to create a VampyreKing class with those additional properties.
Test the new class by creating a new VampyreKing object and checking that is does start with 140 hit points
and only takes a quarter of the damage inflicted.
"""
from enemy import VampyreKing

dracula = VampyreKing("Dracula")
print(dracula)
dracula.take_damage(100)
print(dracula)
Beispiel #8
0
# print(f"Another troll {another_troll}")
#
# brother = Troll('Urg')
# print(brother)
#
# ugly_troll.grunt()
# another_troll.grunt()
# brother.grunt()
#
# blood = Vampyre("Blood")
# print(blood)
#
# blood.take_damage(1)
# print(blood)
#
# # while blood.alive:
# #     blood.take_damage(1)
#
# blood._lives = 0
# blood._hit_points = 1
# print(blood)

dracula = VampyreKing("Dracula")
print(dracula)
dracula.take_damage(12)
dracula.take_damage(12)
dracula.take_damage(12)
dracula.take_damage(12)
dracula.take_damage(12)
print(dracula)
Beispiel #9
0
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")
print("ugly troll : {0}".format(ugly_troll))

another_troll = Troll("Ug", 3)
print("another_troll : {0}".format(another_troll))

brother = Troll("Urg")
print(brother)

ugly_troll.grunt()
brother.grunt()

vamp1 = Vampyre("vamp1")
print(vamp1)

print("*" * 40)
while vamp1.alive:
    vamp1.take_damage(5)
    print(vamp1)

vampK = VampyreKing('suresh')
print(vampK)
vampK.take_damage(10)
print(vampK)
Beispiel #10
0
print("-" * 40)
another_troll.take_damage(30)
print(another_troll)
vamp.take_damage(20)
print(vamp)

while vamp.alive:
    vamp.take_damage(4)
    print(vamp)

# Vampyre King insert ######
print("-" * 40)
dracula = VampyreKing("The Vlad")
print(dracula)
dracula.take_damage(22)
print(dracula)

#########################
# Testing for the player
print()
# tim = player.Player("Tim")
tim = Player("Tim")

print(tim.name)
print("lives: ", tim.lives)

tim.level -= 1
tim.level += 3
print(tim)
Beispiel #11
0
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)
Beispiel #12
0
# troll_2 = Enemy("Bog", 10, 1)
# print(troll_2)
#
# # using a subclasses methods
# troll_1.grunt()
#
# # as troll 2 is not a Troll object it cannot use the sub classes methods
# # troll_2.grunts()
#
# Dr_Acula = Vampyre("Dr. Acula")
# print(Dr_Acula)
#
# # subclass using superclasses methods
# troll_1.take_damage(10)
# print(troll_1)

# Dr_Acula.take_damage(13)
# print(Dr_Acula)

print("=" * 40)

# while Dr_Acula.alive:
#     Dr_Acula.take_damage(1)
#     print(Dr_Acula)

VampKing = VampyreKing("Vampyre King")
print(VampKing)

VampKing.take_damage(17)
print(VampKing)
Beispiel #13
0
    then below code will print the values for the enemy class.
    
    in any other language like C++ or Java we have to declare three constructors one for each case 
    with different input parameters, but python doesn't have the concept of overloaded methods.
"""
# ugly_troll = Troll("Pug")
# ugly_troll.take_damage(4)
# ugly_troll.take_damage(9)
# ugly_troll.take_damage(10)
# ugly_troll.take_damage(11)
# print("Ugly troll - {}".format(ugly_troll))
#
# another_troll = Troll("Ug")
# print("Another troll - {}".format(another_troll))
#
# brother = Troll("Urg")
# print("brother - {}".format(brother))
"""
    before extending the Vampire class
"""
# vampire1 = Vampire("Vampire")
# vampire1.take_damage(5)
# print(vampire1)
#
# while vampire1._alive:
#     vampire1.take_damage(1)
#     # print(vampire1)

vampK = VampyreKing("Vlad")
vampK.take_damage(8)
print(vampK)
Beispiel #14
0
# print(another_troll)
# another_troll.take_damage(18)
# print (another_troll)
#
# brother = Troll("Urg")
# print(ugly_troll)
# print(brother)
#
#
#
# ugly_troll.grunt()
# another_troll.grunt()
#
# vamp = Vampyre("Vam")
# print(vamp)
# vamp.take_damage(2)
# vamp.dodges()
#
# print("__" *20)
# another_troll.take_damage(30)
# print(another_troll)
#
# while vamp._alive:
#     vamp.take_damage(1)

print("--" * 20)

dracula = VampyreKing("drac")
print(dracula)
dracula.take_damage(55)
print(dracula)
Beispiel #15
0
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:
    vamp.take_damage(1)
    king.take_damage(10)
    print(king)
Beispiel #16
0
#
# another_troll = Troll("Ug")
# print("Another troll - {}".format(another_troll))
#
# brother = Troll("Urg")
# print(brother)
#
# vlad = Vampyre("Vlad")
# print(vlad)
#
# ugly_troll.grunt()
# another_troll.grunt()
# brother.grunt()
# brother.take_damage(2)
#
# print("=" * 40)
# another_troll.take_damage(30)
# print(another_troll)
#
# # while vlad.alive:
# #     vlad.take_damage(1)
# #     print(vlad)
#
# vlad._lives = 0
# vlad._hit_points = 1
# print(vlad)

dunitru = VampyreKing("Dunitru")
while dunitru._alive:
    dunitru.take_damage(8)
Beispiel #17
0
from player import Player  #refer to the player class as "Player"

#don't use getters and setters in Python since no objects are hidden!
#getter: a method used to get the value of a class data attribute
#setter: a method used to set the value of a class data attribute

from enemy import Enemy, Troll, Vampyre, VampyreKing

king = VampyreKing("King")
print(king)
king.take_damage(12)
print(king)

# 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()

# test_vamp = Vampyre("Vamp")
# print(test_vamp)
# test_vamp.take_damage(2)
# print(test_vamp)
Beispiel #18
0
# print(brother)

# brother.take_damage(3)
# print(brother)

# brother.take_damage(5)
# print(brother)

# ugly_troll.grunt()
# another_troll.grunt()
# brother.grunt()

# vampyre_instance = Vampyre("FirstVampyre")
# print(vampyre_instance)

# vampyre_instance.take_damage(4)
# print(vampyre_instance)

# vampyre_instance.take_damage(6)
# print(vampyre_instance)

# while vampyre_instance.alive:
#     vampyre_instance.take_damage(1)
# print(vampyre_instance)

vamp = VampyreKing("VKing")
print(vamp)

vamp.take_damage(8)
print(vamp)
# print("Ugly troll - {}".format(ugly_troll))
#
# another_troll = Troll("Ug")
# print(another_troll)
#
# brother_troll = Troll("Urg")
# print(brother_troll)
#
# ugly_troll.grunt()
# another_troll.grunt()
# brother_troll.grunt()

# ugly_troll.take_damage(22)
# print(ugly_troll)
#
# ugly_troll.take_damage(5)
# print(ugly_troll)

# blood_vampyre = Vampyre("Vlad")
# print(blood_vampyre)
#
# while blood_vampyre._alive:
#     blood_vampyre.take_damage(4)
#     print(blood_vampyre)

king = VampyreKing("Dracul")
print(king)

king.take_damage(40)
print(king)
Beispiel #20
0
from player import Player
from enemy import Enemy, Troll, Vampyre, VampyreKing

vking = VampyreKing("Vking")
print(vking)
vking.take_damage(12)
print(vking)

# # random_monster =  Enemy("Basic Enemy",12,1)
# # print(random_monster)
# #
# # random_monster.take_damage(8)
# # print(random_monster)
# #
# '''
# pug = Troll("Pug")
# print("pug - {} ".format(pug))
#
# another_troll = Troll("Ug")
# another_troll.take_damage(18)
# print("Ug - {} ".format(another_troll))
#
# bro = Troll("Urg")  #brother = Enemy("Urg",23) -< This statment will also give the same result
# print("bro - {} ".format(bro), end = " ")
# print(bro)
#
# pug.grunt() '''
# #
# vamp = Vampyre("Vlad")
# # #print(vamp)
# # #vamp.take_damage(3)