Example #1
0
# cogel.suck()
#
# cogel.take_damage(15)
# lucy.take_damage(8)
# ugly_troll.take_damage(22)
# another_troll.take_damage(30)
#
# print(cogel, lucy, ugly_troll, another_troll, sep="\n")
#
# print("*" * 80)
# # while cogel._alive:
# #     # if not cogel.dodges():
# #     cogel.take_damage(1)
# #     print(cogel)

Mah_king = VampireKing("ruty")
print(Mah_king)
Mah_king.take_damage(40)
print(Mah_king)

# tim = Player.Player("Tim")
# 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)
Example #2
0
# 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
print(marty)

phil = VampireKing("Phil")
print(phil)
phil.take_damage(100)
print(phil)

while phil._alive:
    phil.take_damage(100)


Example #3
0
from enemy import Enemy, Troll, Vampire, VampireKing

loki_king = VampireKing('loki')
print(loki_king)

while loki_king.alive:
    loki_king.take_damage(40)
    print(loki_king)

Example #4
0
from player import Player
from enemy import Enemy, Troll, Vampire, VampireKing

# ugly_troll = Troll("Pug")
# print("Ugly troll {}.".format(ugly_troll))
#
# ugly_troll.grunt()
# ugly_troll.take_damage(19)
#
# dracula = Vampire("Dracula")
#
king_vamp = VampireKing("King Vampire")
print(king_vamp)

king_vamp.take_damage(12)
print(king_vamp)

king_vamp.take_damage(12)
print(king_vamp)

king_vamp.take_damage(12)
print(king_vamp)
# One way to change the names of those in {0.name} is using ==> Edit > Find > Replace
# Under Replace box ===> (\{\d\.)  <<=== This will find anything matching {d. where d is any digit
# Under Replace with ==> $1_  <<==== which replaces . with ._
# Remember to check the box for Regex

vamp.lives = 0
vamp.hit_points = 1
print(vamp)

# ============================================
# Testing Inheritance challenge - VampireKing
# ============================================

# We will create an instance of VampireKing called Dracula

# first import VampireKing class from enemy.py

from enemy import VampireKing

# dracula is an instance of VampireKing class and we pass its name i.e. Dracula

print("=" * 20)
dracula = VampireKing("Dracula")
print(dracula)
dracula.take_damage(
    40)  # we give it 40 points damage which will be divided by 4 to become 10
print(
    dracula
)  # Result will be 130 points remaining, unless he dodges and avoids all damage
Example #6
0
    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("dracula_2 again taking damage 25 ")
    vamp2.take_damage(25)

    print("dracula_2 again taking damage 165 ")
    vamp2.take_damage(165)

    print("-" * 40)
    print("New Vamp King created")
    vamp_king = VampireKing("DraculaKing")

    print("DraculaKing again taking damage 165 ")
    vamp_king.take_damage(165)

    print("\nEnding program")
Example #7
0
# print(brother)
#
# # Python doesn't have overloaded methods, might be worth looking into for educational purposes
# # for example Troll(), Troll("Urg, 23), Troll("Ug", 18, 1) would all need different init methods in Java!
#
# ugly_troll.grunt()
# another_troll.grunt()
# brother.grunt()
#
# vamp_1 = Vampire("Mr. Vamp")
# print("First Vamp: {}".format(vamp_1))
#
# ugly_troll.take_damage(3)
# vamp_1.take_damage(2)
#
# # while vamp_1.alive:
# #     vamp_1.take_damage(1)
# #     print(vamp_1)
#
# vamp_1._lives = 0
# vamp_1._hit_points = 1
# print(vamp_1)
#
# print("=" * 50)
#
dracula = VampireKing("Dracula")
print(dracula)
dracula.take_damage(12)
print(dracula)

Example #8
0
#
# ugly_troll.grunt()
# another_troll.grunt()
# talented_troll.grunt()
#
# ugly_troll.take_damage(2)
# print(ugly_troll)
#
# liff_v = Vampire("Liff")
# print(liff_v)
# hanz_v = Vampire("Hanzz")
# print(hanz_v)
#
# liff_v.take_damage(3)
# hanz_v.take_damage(13)
# print(hanz_v)
#
# print("-"*40)
# another_troll.take_damage(30)
# print(another_troll)
#
# while liff_v._alive:
#     # if not liff_v.dodges():
#     liff_v.take_damage(1)
#     print(liff_v)

vamp = VampireKing("Drac")
print(vamp)

vamp.take_damage(14)
print(vamp)
Example #9
0
# 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:
#     vamp.take_damage(1)

# print(vamp)

vking = VampireKing("Dracula")
print(vking)

vking.take_damage(1)
print(vking)

vking.take_damage(1)
print(vking)

vking.take_damage(3)
print(vking)

vking.take_damage(4)
print(vking)
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)
Example #11
0
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)
Example #12
0
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)
Example #13
0
from player import Player
from enemy import Enemy, Troll, Vampire, VampireKing

vamp = Vampire("Kyle")
print(vamp)

while vamp._alive:
    vamp.take_damage(2)
    print(vamp)
    print()

print('*' * 40)

king = VampireKing('George')
print(king)

# brandon = Player('brandon')
# print(brandon)  # all that is needed to call the __str__ method for this class instance
# print(brandon.get_lives())  # gets the value of class attribute 'lives'
# brandon.set_lives(50)  # sets the value of class attribute 'lives' to 50
# print(brandon.get_lives())
#
# print()
#
# parker = Player("Parker")
# print(parker)
# parker.set_level(2)
# print(parker)
# parker.set_level(4)
# print(parker)
# parker.set_level(1)
Example #14
0
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))
# print("Evil vampire - {}".format(vlad))

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

while vamp_king.alive:
    vamp_king.take_damage(40)
    print(vamp_king)
Example #15
0
#     If we try, the last method we defined in the coned will be the only ine be exist.
#     Actually above all constructors are same, they have different no of parameters because
#     we have specified the default values of the rest parameters in the base class.
# """

ug_troll = Troll("Ug")
print(ug_troll)
# O/p:
# Name : Ug	Hit_points : 23	Lives : 1
ug_troll.grunt()

blood_drinker = Vampire("Blood Drinker")
print(blood_drinker)
blood_drinker.take_damage(6)

print(blood_drinker)

blood_sipper = Vampire("Blood Sipper")
print(blood_sipper)

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

blood_king = VampireKing("Blood King")
print(blood_king)

while blood_king._alive:
    blood_king.take_damage(4)
    print(blood_king)