コード例 #1
0
ファイル: main.py プロジェクト: vgrozev/ptn_obj_tst
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)

vamp._lives = 0
vamp._hit_points = 1
コード例 #2
0
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)
vamp.take_damage(5)
print(vamp)

# # ================================================
# # We will use a while loop to test self.alive
# # ================================================
#
# print("="*20)
# while vamp.alive:
#     vamp.take_damage(1)
#     print(vamp)

# # ========================================================
# # We will test this to check if vamp dodges i.e. gets a 3
コード例 #3
0
ファイル: game_main.py プロジェクト: 8314home/pycodes
    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("dracula_2 again taking damage 25 ")
    vamp2.take_damage(25)

    print("dracula_2 again taking damage 165 ")
コード例 #4
0
# print(random_monster)

beautiful_troll = Troll("Pug")
print("Beautfiful Troll - {}".format(beautiful_troll))

another_troll = Troll("Ug")
print("Another troll - {}".format(another_troll))

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

beautiful_troll.grunt()
another_troll.grunt()
brother.grunt()

dracula = Vampire("Dracula")
# print(dracula)
# dracula.take_damage(5)
# print(dracula)
# dracula.take_damage(6)
# print(dracula)
# dracula.reincarnate()

while dracula.alive:
    dracula.take_damage(1)
    print(dracula)

dracula.reincarnate()

==========================================================================================================================
コード例 #5
0
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)
コード例 #6
0
ファイル: main.py プロジェクト: ron71/PythonLearning
#
# """We can observe that we are using Three different constructors even without making them.
#     we can say that its a type of constructor overloading. But this is not true.
#     This is because python does not supports method overloading.
#     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)
コード例 #7
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)
コード例 #8
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)
コード例 #9
0
ファイル: main2.py プロジェクト: alpitanand/python-learn
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)
コード例 #10
0
ファイル: main.py プロジェクト: ndrichter/udemy_python
from player import Player
from enemy import Enemy, Troll, Vampire, VampireKing

nate = Player("Nate")

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

nasty_vampire = Vampire("Nosferatu")
print(nasty_vampire)

# while nasty_vampire._alive:
#     nasty_vampire.take_damage(2)
#     print(nasty_vampire)

dracula = VampireKing("Dracula")
print(dracula)
dracula.take_damage(12)
コード例 #11
0
ファイル: main.py プロジェクト: vgrozev/ptn_obj_tst
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:
    vamp.take_damage(1)
    print(vamp)

コード例 #12
0
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)
コード例 #13
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)
コード例 #14
0
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)
while dracula.alive:
    dracula.take_damage(10)
コード例 #15
0
ugly_troll = Troll("grr")
print("Here comes the Ugly - {} ".format(ugly_troll))

toll = Troll("Yuck")
print("Here comes another one - {} ".format(toll))

ugly_troll.grunt()
toll.grunt()

# toll.take_damage(12)
# print(toll)

print('><' * 50)

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)
コード例 #16
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 = Troll("Urg")
print("Brother troll - {}".format(brother_troll))

basic_vampire = Vampire("Vlad")
print("Vlad - {}".format(basic_vampire))

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

print("-" * 40)

while basic_vampire.alive:
    basic_vampire.take_damage(6)
    print(basic_vampire)

print("-" * 40)

dracula = VampireKing("Dracula")
print(dracula)
dracula.take_damage(12)
print(dracula)
コード例 #17
0
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
print(marty)
コード例 #18
0
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)
dracula.take_damage(12)
print(dracula)