Hello all. This is my first post on this forum, and unfortunately it is an inquiry.

I love video games. Like almost anyone else who grew up playing video games, I have had aspirations to create my own, to implement my own ideas and desires into an interactive experience. This is the first step: I've started learning Python with this text-based RPG. So far, the program allows the user to create their name, to explore, to encounter enemies, to find a merchant, check, status, and other un-exciting things. There are a lot of issues with the code, but for the sake of brevity I would like some help solely with the generation of a random weapon from a set list for a merchant to sell. This part can be found in the Player class, in the def merch block and the def weapon block. Any assistance would be greatly appreciated!!!

p = Player()print ''print "Welcome to the land of Grer, a realm in turmoil due to the recent disposition"print "of the beloved king Quolin. You shall seek your fortune in the dissolution, for"print "riches may be made in such times of strife."print ''p.name = raw_input("What is your character's name? ")print ''print "(type help at any time to get a list of actions)\n"print "%s enters a dark forest, searching for adventure." % p.namewhile(p.health > 0): line = raw_input(">>> ") args = line.split() if len(args) > 0: commandFound = False for c in Commands.keys(): if args[0] == c[:len(args[0])]: Commands[c](p) commandFound = True break if not commandFound: print "%s doesn't understand the suggestion." % p.name

Velcrode wrote:... for the sake of brevity I would like some help solely with the generation of a random weapon from a set list for a merchant to sell. This part can be found in the Player class, in the def merch block and the def weapon block. Any assistance would be greatly appreciated!!!

You posted 500 lines of code and 10 sentences of text but failed to do a basic thing: explain what is your problem.

I didn't fix the indentation, when I read your comment I checked the code and there was no error.

I've spent all of today reading Berkeley's notes on programming with Python (http://inst.eecs.berkeley.edu/~cs61a/sp ... tions.html) and although I still have much more to get through, I have come to this conclusion (along with some assistance from ochichinyezaboombwa's comment):

What I posted was f*cking stupid!

I falsely believed that my question would be explicit in the title of the post, although I foolishly worded it as a statement. My goal is to generate a random weapon for this merchant. In question form: How do I generate a random weapon for a merchant? The reason I inundated my post with code is because I wanted the whole mess to be available to anyone who could help, and if they saw any other inconsistencies in passing they could bring them to my attention. I believe that embarrassing one's self is one of the most powerful ways to learn.

As for the merchweapon's data type... I'm not sure. I'm starting to think it's an issue of parameters, or something, but I have no idea what solution to implement, or how. I believe weapons is a class (I've since changed the code a bit), and the list of weapon names is an if-else function. I took out the "if True:" thing, I have come to realize with the help of too many others that that kind of coding is silly.

tl;dr: I want to get the merchant's output to be a random weapon, with an input from an if-else function. Is this even possible(methinks not)?

is the error shown. How do I remedy this? Also, if anyone can explain it, how will the stats in the dict block be made available to the interpreter so they can be printed? I feel like something's missing.

There must be a simple explanation to the error you get. Computers (in contrast to humans) are straightforward.To get help, you need to show your (obviously changed) merch() code, because Mekire's code works just fine.

def getEquipInfo(self): print "%s has a minDMG of %s and a maxDMG of %s\n%s has a defense of %s" % (self.weaponname, self.weapondamage, self.armorname, self.armordefense)AttributeError: Player instance has no attribute 'weapondamage'

p = Player()print ''print "Welcome to the land of Grer, a realm in turmoil due to the recent disposition"print "of the beloved king Quolin. You shall seek your fortune in the dissolution, for"print "riches may be made in such times of strife."print ''p.name = raw_input("What is your character's name? ")print ''print "(type help at any time to get a list of actions)\n"print "%s enters a dark forest, searching for adventure." % p.namewhile(p.health > 0): line = raw_input(">>> ") args = line.split() if len(args) > 0: commandFound = False for c in Commands.keys(): if args[0] == c[:len(args[0])]: Commands[c](p) commandFound = True break if not commandFound: print "%s doesn't understand the suggestion." % p.name