Created
October 24, 2012 13:34
-
-
Save rchrand/3946075 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Monster import Monster | |
from Person import Person | |
import random | |
from sys import exit | |
#class Person(object): | |
# def __init__(self, name): | |
# self.name = name | |
# self.life = 100 | |
# | |
# def getLife(self): | |
# return self.life | |
#class Monster(object): | |
# def __init__(self): | |
# self.life = random.randint(89,120) | |
# | |
# def getLife(self): | |
# return self.life | |
class Main(Person, Monster): | |
def __init__(self): | |
Person = Person("Hansi") | |
Monster = Monster() | |
def main(self): | |
print "You get caught in a terrible battle!" | |
while True: | |
raAttack = random.randint(1, 25) | |
Person.life = Person.life - raAttack | |
Monster.life = Monster.life - raAttack | |
print "%s hit the monster for %d life! monster has %d life left" % (Person.name, raAttack, Monster.life) | |
print "The monster took %d of your life, you have %d left!\n" % (raAttack, Person.life) | |
if Monster.life <= 0 and Person.life > 0: | |
print "You won! you had %d life left!" % Person.life | |
exit(0) | |
elif Person.life <= 0 and Monster.life >0: | |
print "You lost, the monster had %d life left!" % Monster.life | |
exit(0) | |
if __name__ == "__main__": | |
spille = Main() | |
spille.main() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
class Monster(object): | |
def __init__(self): | |
self.life = random.randint(89,120) | |
def getLife(self): | |
return self.life |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person(object): | |
def __init__(self, name): | |
self.name = name | |
self.life = 100 | |
def getLife(self): | |
return self.life |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment