The tutorial I'm using is discussing list, tuples, and dictionaries. An
exercise at the end wants me to do this:
Write a Character Creator program for a role-playing game. The player should be
given a pool of 30 points to spend on four attributes: Strength,Stamina,
Wisdom, and Dexterity. The player should be able to spend points from the pool
on any attribute and should also be able to take points from an attribute and
put them back into the pool.
I'm wondering if I'm doing this right or is their a different more practical
way of accomplishing this. I tend to over complicate things sometimes. This is
how I've started it and any help pointing me in the right direction or of a
different way of doing this will be apprectiated.
Thanks
Doug:
#user menu
def menu():
choice=None
print'''\n
0. Quit
1. Display attributes
2. Add points to attributes
3. Subtract opints from attributes''' <--not active yet
print'Remaining points=',points
while choice not in('0','1','2','3 '):
choice=raw_input('\nWhat would you like to do? Enter number of
option.\n')
return choice
#variables used
dexterity=0
strength=0
stamina=0
wisdom=0
allot=None
creating=True
change=0
points=30
#list of attributes and their values
attributes=['dexterity=',dexterity ,'strength=',strength, 'stamina=',stamina,
'wisdom=',wisdom]
#creation loop
while creating:
choice=menu()
if choice=='0':
print '\nThank you for using character creator.'
end=raw_input('\n Press enter to end.')
creating=False
elif choice=='1':#prints out list of attributes and their values
for entry in attributes:
print entry,
elif choice=='2':
allot=raw_input('''What attribute would you like to change?
Enter dex for dexterity, str for strength, etc. ''').lower()
if allot=='dex':
change=int(raw_input('How many points do you wish to allot? '))
attributes[1]=dexterity=+change
points=points-change
if allot=='str':
change=int(raw_input('How many points do you wish to allot? '))
attributes[3]=strength=+change
points=points-change
if allot=='stam':
change=int(raw_input('How many points do you wish to allot? '))
attributes[5]=stamina=+change
points=points-change
if allot=='wis':
change=int(raw_input('How many points do you wish to allot? '))
attributes[7]=wisdome=+change
points=points-change
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor