0

Hi, I'm new here... Please help me fix it, if I posted at the wrong section, this is about Python but also game development... So I'm not sure? :) anyway:

I need some guide lines to the way of coding? or the use of things within the code...
Here I have a project I'm working on, at the same time learning more about Python and Python-Networking along with MySQL stuff... All I want, is the pro's here to "review" my code and tell me what I'm doing wrong and what will be better. No! need to complete my code only Judge it.

PS. I'm learning by myself.

I thank in advance! :)

#######

#

##   THIS IS THE NOTHINGNESS  ###

###    by *****.

####     version 0.01

#####      License Free / Open source

######

#####

####

###

##

#######



## MAIN IMPORTS



import sys

#import csv 

import MySQLdb # This is here because i used it to test something. and i got it to save in my mysql server :)



## Character creation

class character_Create:

	

	def __init__(self):

		

		# Get player information

		print "Welcome to The Nothingness.  \n\nThis is a text based RPG game derived in a mistical age of random fantasy.\nNext you will be asked to enter the details about your character please\nfollow the directions."

		print "--------------------------------------------------------"

		print 

		player_name = raw_input("Your character name:\n -> ")

		print

		player_race = input("Please pick your Race:\n 1: Humans\n 2: Spirit\n 3: Hellborn.\n -> ")

		print

		player_class = input("Please pick you Class:\n 1: Warrior\n 2: Priest\n 3: Mage\n 4: Ranger.\n -> ")

		print

		player_bio = raw_input("Your character Bio:\n -> ")

		print



##	RACE STATS

class Race_Stats(character_Create):

	

	def __init__(self):

		

		# About player character

		self.health = 100

		self.mana = 100

		self.gold = 0.0

		self.XP = 0.0

		

		

	def human_Race(self):

		self.info_human = '''

		Derived from the gods them self these beings have 

		roamed the earth for many years, they are the more 

		commonly known folk roaming the lands of Pracnna.

		'''

		

	def hellborn_Race(self):

		self.info_hellborn = '''These demonic creatures have been around all the years, dwelling

		the earth with their misleading and destructive tung.  These creatures 

		are dark and misterious, the roam around mostly at night.'''

		

	def spirit_Race(self):

		pass



## CLASS STATS

class pClass_Stats(Race_Stats):

	

	def Warrior(self):

		self.strength = 5

		self.intelect = 2

		self.agility = 3

		self.attack = 4

		self.spellpower = 1

		

	def Priest(self):

		self.strength = 3

		self.intelect = 5

		self.agility = 2

		self.attack = 3

		self.spellpower = 3

		

	def Mage(self):

		self.strength = 1

		self.intelect = 3

		self.agility = 2

		self.attack = 2

		self.spellpower = 5

		

	def Ranger(self):

		self.strength = 2

		self.intelect = 3

		self.agility = 5

		self.attack = 4

		self.spellpower = 2

	

	

	

	

#############################

#############################

##						   ##

##   MAIN FUNCTION HERE!!  ##

##						   ##

#############################



class main(Race_Stats):

	

	# Running the game main

	played_check = raw_input("Have you played this shit yet? 'y' or 'n': \n--> ")

	print 

	print 

	print

	print Race_Stats()

	

	while played_check != 'y': 

		 character_Create()

		 

	else:

		print "START THE GAME MAIN???"

		 

		 



if __name__ == '__main__':

	main()

*Sorry I'm using Geany on linux(ubuntu) and the line spacing is weird...
I made a project hosting page as well to get the idea please visit http://code.google.com/p/the-nothingness/wiki/ProjectPlaning

3
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by lrh9
0

Do you plan to use images? Animations? If you could provide a bit more info on what exactly you're trying to create, and how you want it to come out, I could give ya a few tips.

0

As a designer and coder we should be as abstract as usefully possible. Abstract software is compact and reusable. You are treating classes as namespaces and making a specific class or function for every thing. You should treat classes as blueprints that abstractly specify the attributes and capabilities of a type of objects.

We wouldn't make a class for each Tom, Dick, and Harry. We would make a single Person class that specifies the attributes our people have. Our people have a name. So our Person class specifies that people have a name. We create people by creating instances of the Person class. We differentiate each instance with its name.

class Person:

    def __init__(self, name):
        self.name = name

names = ('Tom', 'Dick', 'Harry')
people = [Person(name) for name in names]

Your RPG has character classes with attributes. We can reduce your 25 lines of code for character classes to 16 (or less) and we can reduce the cost of adding a new class from adding 6 lines to adding 1 line. I'd say not bad.

The key to being a good solo software developer is design.

class Class:

    def __init__(self,
                 strength,
                 intelligence,
                 agility,
                 attack,
                 spellpower):
        self.strength = strength
        self.intelligence = intelligence
        self.agility = agility
        self.attack = attack
        self.spellpower = spellpower

ranger = Class(2, 3, 5, 4, 2)
warrior = Class(5, 2, 3, 4, 1)
priest = Class(3, 5, 2, 3, 3)
mage = Class(1, 3, 2, 2, 5)
print(ranger.strength)
print(warrior.strength)
print(priest.strength)
print(mage.strength)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.