I wrote this:
health = 10
money = 1
population = 0
def goblinshot(dmg):
global health
health = health - dmg
print "You're now down to", health,"health!"
def goblinheal(healing):
global health
health = health + healing
print "You now have", health,"health! Hooray!"
class Character:
def __init__():
self.name = name
self.hitPoints = hitPoints
def printName(self):
global population
population = population + 1
def howMany(self):
global population
if population == 1:
print "'It's just me and you!' he exclaims."
else:
print "'I'm here with", population - 1,"other characters.'"
def regAttack(self):
print "Attack"
def healsYou(self):
print "Heals"
class Goblin(Character):
def __init__(self):
self.hitPoints = 5
self.name = goblinList[0]
print "Someone new shows up!"
print "He says, 'Hi, I'm",
self.name,"'"
goblinList[0:1] = []
print goblinList
print "'I have", self.hitPoints,"hit points left!', he says."
def regattack(self):
print "The goblin punches you!"
goblinshot(1)
class GoodGoblin(Goblin):
money = 5
def _init_(self):
self.hitPoints = 3
print "I have",money,"money!"
def healsyou(self):
print "The goblin heals you a little bit!"
goblinheal(1)
def giveMoney(self):
print "The goblin drops a dollar!"
self.money = self.money - 1
print "He now has",
print self.money, "dollars!"
global money
money = money + 1
print "You pick up the dollar!"
print "You now have", money,"dollars!"
class NigerianGoblin(Goblin):
def goChoppa(self):
print "The goblin go choppa your dolla!"
global money
money = money - 1
print "You now have", money,"dollars!"
goblinList = ['Grandmaster Flash', 'Thuggy McPicklephile', 'Bob Deathstrike', 'Loki Lackluster', 'Cyberviking X', 'Chuck D', 'Osama bin Smokin']
Bob = Goblin()
Bob.printName()
Bob.howMany()
Bob.regattack()
Bob.regattack()
Bob.regattack()
Bob.regattack()
barrett = GoodGoblin()
barrett.printName()
barrett.howMany()
barrett.healsyou()
barrett.giveMoney()
Berkman = NigerianGoblin()
Berkman.printName()
Berkman.regattack()
Berkman.goChoppa()