class player: def sethp(self, hp): self.hp = hp def setmp(self, mp): self.mp = mp def setatt(self, att): self.att = att def setdef(self, arm): self.arm = arm def battle(hero, noob): print("hero hp"), hero.hp,("noob hp"), noob.hp battlechoice = input(int("what would u like to do")) if battlechoice==1: noob.hp-(hero.att-noob.arm) else: noob.hp-(hero.att-noob.arm) print("hero hp"), hero.hp,("noob hp"), noob.hp def noob: setmp(noob, 10) sethp(noob, 10) setatt(noob, 10) setdef(noob, 5) def hero: setmp(hero, 10) sethp(hero, 10) setatt(hero, 15) setdef(hero, 10) name = raw_input("enter heroes name") print "what would u like to do", name print "1. fight" choice = input() if choice==1: battle(hero, noob) else: print("boo")
I get a syntax error with the : after defining noob. I'm not sure why. Also i tried to put the class and and the noob and hero definitions in another file and import it but i got an error. I don't fully or much at all understand modules so i just put all the code in one file.
This isn't something that i intend to finish or be enjoyable i am just attempting to produce something with what little python i know to help to not forget it and get a better understanding.
thx for the help guys. I plan on buying the O'reily book on learning python. any good?
This post has been edited by jmanelson: 20 March 2009 - 05:48 PM