Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import random
- class Creature:
- def __init__(self,name,level):
- self.name=name
- self.level=level
- def defensive_roll(self):
- roll=random.randint(1,12)
- return(roll*self.level)
- class Dragon(Creature):
- def __init__(self,name,level,scales,breath_fire):
- super().__init__(name,level)
- self.scales=scales
- self.breath_fire=breath_fire
- def breath_weapon(self):
- return(random.randint(1,12)*self.level)
- def defensive_roll(self):
- roll=random.randint(1,12)
- value=roll*self.level
- if self.scales>=roll:
- value=value*2
- return(value)
- class Wizard(Creature):
- def __init__(self,name,level):
- super().__init__(name,level)
- def attack(self,creature):
- my_roll=self.defensive_roll()
- creature_roll=creature.defensive_roll()
- print("You roll {}...".format(my_roll))
- print("{} rolls {}...".format(creature.name,creature_roll))
- if(my_roll>=creature_roll):
- print("The wizard has handily triumphed over {}".format(creature.name))
- return True
- else:
- print("The wizard has been DEFEATED!!!")
- return False
- class SmallAnimal(Creature):
- def __init__(self,name,level):
- super().__init__(name,level)
- def defensive_roll(self):
- roll=random.randint(1, 12)
- value=roll*self.level
- if 2>=roll:
- value=value*2
- return(value)
- class BigAnimal(Creature):
- def __init__(self,name,level):
- super().__init__(name,level)
- def main():
- print("The Adventure Begins")
- creatures=[SmallAnimal("Toad",1),BigAnimal("Tiger",12),Dragon("Dragon",50,75,False),Wizard("Evil Wizard",15)]
- hero=Wizard("Gandalf",75)
- while True:
- active_creature=random.choice(creatures)
- print("A {} of level {} has apeared from a dark and foggy forest...".format(active_creature.name,active_creature.level))
- print()
- cmd=input("Do you [a]ttack, [r]un away, or [l]ook around? ")
- if cmd=="a":
- if hero.attack(active_creature):
- creatures.remove(active_creature)
- else:
- print("The wizard runs and hides taking time to recover...")
- time.sleep(5)
- print("The wizard returns revitalized!")
- elif cmd=="r":
- print("The wizard has become unsure of his power and flees!!!")
- elif cmd=="l":
- print("The wizard {} takes in the surroundings and sees:".format(hero.name))
- for c in creatures:
- print(" * A {} of level {}".format(c.name,c.level))
- else:
- print("OK, exiting game... bye!")
- break
- if __name__=="__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment