daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest Jul 7th, 2012 16 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Enemy.py
  2. from random import randint
  3. import Character
  4.  
  5. Character = Character.Character()
  6.  
  7. class Enemy(Character):
  8.  
  9.     def __init__(self, player):
  10.         Character.__init__(self)
  11.         self.name = 'a goblin'
  12.         self.health = randint(1, player.health)
  13.  
  14. #Character.py
  15. from random import randint
  16. import Enemy
  17. import Player
  18. import Rpg
  19.  
  20. class Character:
  21.  
  22.     def __init__(self):
  23.         self.name = ""
  24.         self.health = 1
  25.         self.health_max = 1
  26.  
  27.     def do_damage(self, enemy):
  28.         damage = min(
  29.             max(randint(0, self.health) - randint(0, enemy.health), 0), enemy.health)
  30.         enemy.health = enemy.health - damage
  31.         if damage == 0: print "%s evades %s's attack." % (enemy.name, self.name)
  32.         else: print "%s hurts %s!" % (self.name, enemy.name)
  33.         return enemy.health <= 0
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top