Advertisement
ivandrofly

Python - Text Game Project Pt 1

Jan 31st, 2014
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. import random
  2.  
  3. class Character(object):
  4.     def __init__(self, name, level):
  5.         self.name = name
  6.         self.level = level
  7.         self.health = int(level + 5 ** 2) # if level is'nt number this will throw
  8.  
  9.     def damage(self, attack):
  10.         self.health -= attack
  11.         if self.health <= 0:
  12.            print("%s has died!" % self.name)
  13.         else:
  14.            print("%s has lost %i health!" % (self.name, attack))
  15.     def attack(self):
  16.         attack = self.level/4 * 1.5
  17.         return attack
  18.  
  19. vilan = Character("Megaman", 13) # :)
  20. hero = Character("Metroman", 20)
  21.  
  22. hero.damage(vilan.attack())
  23. vilan.damage(8) # ;)
  24. vilan.damage(20)
  25. input() #wait here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement