def a(classname,highdamageweaponname,lowdamageweaponname,ldmgname,hdmgname,yourhealth,enemyhealth,ldmgspellname,hdmgspellname):
	import os
	import random
	os.system("clear")
	monsters = ['cyclopse', 'duck', 'dragon', 'wizard', 'magician']
	randommonster = random.choice(monsters)	
	print "Class: %s" % classname
	print "1) %s (More damage, but less armor)" % highdamageweaponname
	print "2) %s (Less damage, but more armor)" % lowdamageweaponname
	a = int(raw_input("You are battling a %s what weapon do you want?: " % randommonster))
	while enemyhealth >= -1 and yourhealth >= -1:
		hdmg = [0,5,0,15,0,20,30]
		ldmg = [0,5,6,7,8,9,10]	
		ldmgrandom = random.choice(ldmg)
		hdmgrandom = random.choice(hdmg)
		edmg = [ldmgrandom,hdmgrandom]	
		edmgrandom = random.choice(edmg)		
		mdmg = [1,2,3]
		mdmgrandom = random.choice(mdmg)
		os.system("clear")
		if a == 1:
			print "you have chosen a %s" % highdamageweaponname
			print "Your Armor: ", yourhealth
			print "Enemy Armor: ", enemyhealth
			print "1) %s (High damage | High chance of missing)" % hdmgname
			print "2) %s (Low damage | Low chance of missing)" % ldmgname
			c = int(raw_input("Choose your attack: "))
			if c == 1:
				ddmg = hdmgrandom
				yourhealth = yourhealth - edmgrandom
				enemyhealth= enemyhealth- ddmg
				print "You Did ", ddmg, "Damage"
				raw_input("Press Enter To Continue")
			elif c == 2:
				ddmg = hdmgrandom
				yourhealth = yourhealth - edmgrandom
				enemyhealth= enemyhealth- ddmg
				print "You Did ", ddmg, "Damage"
				raw_input("Press Enter To Continue")
		if a == 2:
			print "you have chosen a %s" % lowdamageweaponname			
			print "Your Armor: ", yourhealth + 20
			print "Enemy Armor: ", enemyhealth
			print "1) %s (High damage | High chance of missing)" % hdmgspellname
			print "2) %s (Low damage | Low chance of missing)" % ldmgspellname
			c = int(raw_input("Choose your attack: "))
			
			if c == 1:
				ddmg = hdmgrandom
				yourhealth = yourhealth - edmgrandom
				enemyhealth= enemyhealth- (ddmg - mdmgrandom)
				print "You Did ", ddmg, "Damage"
				raw_input("Press Enter To Continue")				
			elif c == 2:
				ddmg = ldmgrandom
				yourhealth = yourhealth - edmgrandom
				enemyhealth= enemyhealth- (ddmg - mdmgrandom)
				print "You Did ", ddmg, "Damage"
				raw_input("Press Enter To Continue")	
		if c > 2 or c < 1:
			print "Invalid attack"
			raw_input("Press Enter To Continue")
	if yourhealth <= 0:
		os.system("clear")
		print "You Died..."
		
	elif enemyhealth<= 0:
		os.system("clear")	
		print "You Killed Him!"
def menu():
	import os
	import random
	os.system("clear")
	print "############################################"
	print "       City of Warscape "
	print "###########################################"
	print " "
	print "Choose Your Class"
	print "1) Warrior"
	print "2) Ranger"
	print "3) Mage"
	x = int(raw_input("What Class What You Like To Be?: "))
	if x == 1:
		a('Warrior','Mace','Sword','Pound','Bash',100,100,'Slice','Dice')
	if x == 2:	
		a('Ranger','Bow','Knives','Steady Shot','Power Shot',100,100,'Toss','Hurl')
	if x == 3:
		a('Mage','Staff','Wand','Poke','Slash',100,100,'Fireball','Froststrike')
menu()
Comments
Neither attempts to ask a question or discuss a topic. Is simply a release of (poor) code.

import shall not be inside a function(always first) an 8 space indent(in python we use 4 always),and long functions a.

Sorry but i dont se the point in just post this code without any question.
And this code dos not help beginners at all,maybe to show how python code not shall look.

Edited 7 Years Ago by snippsat: n/a

Jesus Christ. Get some object oriented design and code in that program ASAP!

Graphical user interfaces and object oriented program are not the same thing.

Object oriented programming is designing and coding programs based on objects and their interactions.

Object oriented programming would allow you to code more in less time and greatly improve the structure and function of your programs. Only requiring a little forethought.

This code has a lot of room for improvement. It would benefit you to read up on classes and functions, as well as PEP 8 (recommended Python coding guidelines).

Maybe you should challenge yourself to improve the style of your coding and make your program more readable. Also it would be interesting if you modularized your code so that you could reuse elements in future games (this would speed up your game development on subsequent titles).

hi
that's a nice game idea but it would be much better to divide the big function into 2 or 3 smaller ones. Also I noticed that you're using a variable that has the same name as the function :)

def a(classname,highdamageweaponname,lowdamageweaponname,ldmgname,hdmgname,yourhealth,enemyhealth,ldmgspellname,hdmgspellname):
...
a = int(raw_input("You are battling a %s what weapon do you want?: " % randommonster))

try to avoid doing that. Use a different variable name. :) Again nice game :)

Good effort, but super-long variable names and tab indentations make this code hard to fathom. Please avoid tab indentations as they translate into 8 spaces here in the DaniWeb code field. The standard that most folks are accustomed to is 4 space indentations for Python.

Again, the general coding guide for Python is:
http://www.python.org/dev/peps/pep-0008/

Good effort, but super-long variable names and tab indentations make this code hard to fathom. Please avoid tab indentations as they translate into 8 spaces here in the DaniWeb code field. The standard that most folks are accustomed to is 4 space indentations for Python.

Again, the general coding guide for Python is:
http://www.python.org/dev/peps/pep-0008/

Thanks you, I will keep that in mind.

This article has been dead for over six months. Start a new discussion instead.