noobish question

This is the place for queries that don't fit in any of the other categories.

noobish question

Postby Donovanx » Thu Jun 06, 2013 8:47 am

Hi I want to have my list (tuple I belive not sure can't remb I'll look it up in a second )to be called. It has three races namely orgs,els and templars now I've given some atributes (skills)that I want them to have and be able to lvl up as they gain xp points.
My question is simple and I'm not sure if my format way. Is posable but I want is close to the way I have it listed but I'm not sure how to do it could you guys help me out? I have a list with the races then I want the script to be able to cal them is the list format and get the skills that I stil to input here's my format(code)
Code: Select all
def Chars
race = [("Org"),("Elf"),("Templar")]]
health = [(""),(""),("")]
strentgh = [(""),(""),("")]
defense = [(""),(""),("")]
magic = [(""),(""),("")]
agility = [(""),(""),("")]
ranged = [(""),(""),("")]

I aded the code function myself since its hard to do with a blackberry sry if it dosint come out right mod feel free to ffix if it isint
Donovanx
 
Posts: 13
Joined: Fri May 10, 2013 1:54 pm

Re: noobish question

Postby MichelFJM » Thu Jun 06, 2013 9:38 am

Hello

I'm sorry, but I think that your actual programming skills does not allow you to make a game with leveling characters. If it is a game that you are planning, star your game with one fixed character. After that, what you need will be more clear. If not, explain us better what you are expecting to do.
MichelFJM
 
Posts: 19
Joined: Wed May 22, 2013 1:41 pm

Re: noobish question

Postby setrofim » Thu Jun 06, 2013 9:45 am

You definitely don't want to be using tuples for this because tuples are immutable. That means that once created, they cannot be modified. The best way to structure your character data would probably be to define a class and then to instantiate it with specific values. Something like

Code: Select all
class Character(object):

    def __init__(self, race, health, strength, defence, magic, agaility, ranged):
        self.race = race
        self.strength = strength
        self.defence = defence
        self.magic = magic
        self.agility = agility
        self.ranged = ranged


characters = [
    Character("Org", 100, 10, 10, 5, 8, 5),
    Character("Elf", 90, 8, 8, 10, 10, 12),
    Character("Templar", 120, 10, 12, 10, 5, 5),
]
setrofim
 
Posts: 288
Joined: Mon Mar 04, 2013 7:52 pm

Re: noobish question

Postby Mike_S » Thu Jun 06, 2013 12:34 pm

Hi Donovanx

You might find this 'Invent with Python' blog post helpful.

... http://inventwithpython.com/blog/2013/0 ... -fortress/
* Portable-Python 2.7.5.1 * Windows XP (x86) *
User avatar
Mike_S
 
Posts: 8
Joined: Sat Feb 09, 2013 4:59 am
Location: >!<

Re: noobish question

Postby micseydel » Fri Jun 07, 2013 6:11 am

setrofim wrote:The best way to structure your character data would probably be to define a class...

I'm of the belief that classes (a tool for object-oriented programming and design patterns) are an advanced topic for somewhat more mature programmers than the OP likely is. Which is unfortunate, because I whole-heartedly agree that OOP is the best way to design this program.

That said, I think dictionaries are a good surrogate for an intro user, and functions which create a user (a dictionary with predictable values) are a good way to encapsulate the data in the short term. After gaining experience from a project like this, it would be wonderful exercise to convert it to true OOP, hopefully not being too hard but clearly showing the benefits.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 929
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 4 guests