Python/Programming help
Started by
Alestance
, Nov 24 2008 07:46 PM
20 replies to this topic
#16
Posted 28 November 2008 - 10:19 PM
Ah, I get it now, I just didn't understand what you were implying.
Whats the difference between "class" and "def"?
Whats the difference between "class" and "def"?
#17
Posted 29 November 2008 - 03:20 AM
Classes can contain data and functions within them. You can also create several instances of a class - if you have a class Enemy, you can have several enemies each with different HP, type and so on.
Something like this:
Due to IPB's broken handling of spaces at the beginning of [ code ] blocks, I'll have to indent with "--".
Something like this:
Due to IPB's broken handling of spaces at the beginning of [ code ] blocks, I'll have to indent with "--".
CODE
class Enemy:
--pass
zol = Enemy()
zol.hp = 10
zol.speed = 2
gel = Enemy()
gel.hp = 5
--pass
zol = Enemy()
zol.hp = 10
zol.speed = 2
gel = Enemy()
gel.hp = 5
#18
Posted 01 December 2008 - 04:37 PM
I'm back to working on the RPG battle system, as I'm using it with the Text Adventure.
I need help again
Alright, sometimes the program crashes on me, and I don't really know why. Here is a link to download said program
I would randomly get this error after attacking(other functions aren't set up yet.)
Here is some basic information.
You're Health is 645.0 and your Magical Energy is 0.
You're enemy's Health is 235 and you're Enemy's Magical Energy is 600.
Choose your action by typing it: Attack(1), Defend(2), Spell(3), Focus(3)
1
Traceback (most recent call last):
File "/home/mike/Python Programs/RPGSystem.py", line 290, in <module>
patk()
File "/home/mike/Python Programs/RPGSystem.py", line 221, in patk
edef = random.randint(lvl, ed) + elck
File "/usr/lib/python2.5/random.py", line 215, in randint
return self.randrange(a, b+1)
File "/usr/lib/python2.5/random.py", line 191, in randrange
raise ValueError, "empty range for randrange() (%d,%d, %d)" % (istart, istop, width)
ValueError: empty range for randrange() (16,7, -9)
Also, if you have to, comment out the stat debug functions, I was using them to test to see if information was being transfered correctly between definitions.
ONE MOAR THING!
The Enemy does not attack yet.
EDIT: Forget this at the moment, I've got to re-rewrite it.
I need help again
Alright, sometimes the program crashes on me, and I don't really know why. Here is a link to download said program
I would randomly get this error after attacking(other functions aren't set up yet.)
CODE
Here is some basic information.
You're Health is 645.0 and your Magical Energy is 0.
You're enemy's Health is 235 and you're Enemy's Magical Energy is 600.
Choose your action by typing it: Attack(1), Defend(2), Spell(3), Focus(3)
1
Traceback (most recent call last):
File "/home/mike/Python Programs/RPGSystem.py", line 290, in <module>
patk()
File "/home/mike/Python Programs/RPGSystem.py", line 221, in patk
edef = random.randint(lvl, ed) + elck
File "/usr/lib/python2.5/random.py", line 215, in randint
return self.randrange(a, b+1)
File "/usr/lib/python2.5/random.py", line 191, in randrange
raise ValueError, "empty range for randrange() (%d,%d, %d)" % (istart, istop, width)
ValueError: empty range for randrange() (16,7, -9)
Also, if you have to, comment out the stat debug functions, I was using them to test to see if information was being transfered correctly between definitions.
ONE MOAR THING!
The Enemy does not attack yet.
EDIT: Forget this at the moment, I've got to re-rewrite it.
Edited by Alestance, 02 December 2008 - 10:09 AM.
#19
Posted 03 December 2008 - 11:04 AM
I know this is not a programming issue, but ...
That's your health. As in "the health that you have", not "you are health".
Just thought I'd point that one out.
QUOTE
You're Health is 645.0 and your Magical Energy is 0.
That's your health. As in "the health that you have", not "you are health".
Just thought I'd point that one out.
#20
Posted 03 December 2008 - 06:40 PM
I would have caught it eventually. I'm rewriting the program now, anyway.
#21
Posted 04 December 2008 - 04:22 PM
Alright, new file, new engine.
This time I'm using Defs and lots of comments to prevent it from getting too messy, but, I still have a problem. File is Here\
and I get this error after a second loop:
Traceback (most recent call last):
File "/home/mike/Python Programs/RNRPG.py", line 390, in <module>
mystat,estat,buff,dec,dead = wratk(lev,mystat,estat,buff,dead,edec)
File "/home/mike/Python Programs/RNRPG.py", line 113, in wratk
atk = random.randint(lev, mystat[0]) + mystat[3]
File "/usr/lib/python2.5/random.py", line 215, in randint
return self.randrange(a, b+1)
TypeError: can only concatenate list (not "int") to list
Some warnings with this build:
Mage doesn't work yet, I have to figure out a way to write the spell book correctly. Enemies will not be confined to a specific class(as their stats are completely psuedorandom.) so, I got to program the spellbook for it too.
Enemies CAN use the "Charge" function, so, if you're not careful, they WILL drive you into the ground, I had an instance where I was nearly 1 hit ko'd because he charged like 10 times before attacking me.
EDIT: I fixed that bug, but I have another bug to deal with, now. Sometimes the enemy's defense(or my extra strength) doesn't reduce over turns, and will keep doubling, which makes it impossible to defeat, if it goes too far out of control(or makes the enemy too easy to defeat if you keep that added buff.)
This time I'm using Defs and lots of comments to prevent it from getting too messy, but, I still have a problem. File is Here\
and I get this error after a second loop:
CODE
Traceback (most recent call last):
File "/home/mike/Python Programs/RNRPG.py", line 390, in <module>
mystat,estat,buff,dec,dead = wratk(lev,mystat,estat,buff,dead,edec)
File "/home/mike/Python Programs/RNRPG.py", line 113, in wratk
atk = random.randint(lev, mystat[0]) + mystat[3]
File "/usr/lib/python2.5/random.py", line 215, in randint
return self.randrange(a, b+1)
TypeError: can only concatenate list (not "int") to list
Some warnings with this build:
Mage doesn't work yet, I have to figure out a way to write the spell book correctly. Enemies will not be confined to a specific class(as their stats are completely psuedorandom.) so, I got to program the spellbook for it too.
Enemies CAN use the "Charge" function, so, if you're not careful, they WILL drive you into the ground, I had an instance where I was nearly 1 hit ko'd because he charged like 10 times before attacking me.
EDIT: I fixed that bug, but I have another bug to deal with, now. Sometimes the enemy's defense(or my extra strength) doesn't reduce over turns, and will keep doubling, which makes it impossible to defeat, if it goes too far out of control(or makes the enemy too easy to defeat if you keep that added buff.)
Edited by Alestance, 05 December 2008 - 03:16 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users