Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- class Character(object):
- def __init__(self, name, level):
- self.name = name
- self.level = level
- self.health = int(level + 5 ** 2) # if level is'nt number this will throw
- def damage(self, dmg):
- block = self.block()
- if dmg-block < 0:
- dmg = 0
- else:
- dmg = dmg - block
- self.health - dmg
- if self.health <= 0:
- print("%s has died!" % self.name)
- return 1
- else:
- print("%s has lost %i health!" % (self.name, dmg))
- return 0
- def block(self):
- rand = random.randint(0,100)
- if rand % 5 == 0 and rand % 2 == 0:
- return int(self.level / 2 * 1.5 /3)
- return 0
- def attack(self):
- dmg = 0
- rand = random.randint(0, 100)
- if rand % 5 == 0:
- dmg = self.level/4 * 1.5
- print("Attack Successful!")
- return dmg
- def win(char1, char2):
- if(char1.health > char2.health):
- winner = char1.name
- else:
- winner = char2.name
- print("%s has won" % winner)
- vilan = Character("Megaman", 13) # :)
- hero = Character("Metroman", 20)
- h = 0
- v = 0
- def fight(char1, char2):
- i = 0
- j = 0
- while j != 1 and i != 1:
- i = char1.damage(vilan.attack())
- j = char2.damage(hero.attack())
- win(char1, char2) #Ivandro Ismael
- fight(vilan, hero)
- #input() #wait here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement