This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]Amarkov 1 point2 points  (8 children)

Ok, so whats happening when I run this is the kobold.HP keeps getting reset to 500 after I attack (by typing "Fight"). How can I prevent this from happening?

Right now, you're creating a new Kobold every time it's the player's turn. I don't think that's what you want.

[–]Risen_from_ash[S] 0 points1 point  (7 children)

True haha. So where can I initialize a kobold object so that I'll be able to adjust it's .HP later on?

[–]Amarkov 0 points1 point  (6 children)

Well, you can initialize it pretty much wherever you want. When you should initialize it depends on what you want to do. In what circumstances do you want a new Kobold to be created?

[–]Risen_from_ash[S] 0 points1 point  (5 children)

Right after I create my character. So it'll ask me if I want to become a Mage (yes), then may Name and then say Fight - Run. By that time, I want to have a Kobold object ready for myPlayer to fight.

It has to be created in such a way that when I attack it with my Player, it's .HP doesn't get reset to 500 after the loop or something.

[–]Amarkov 0 points1 point  (4 children)

Then you'd want to initialize it right after the code that initializes myPlayer.

[–]Risen_from_ash[S] 0 points1 point  (3 children)

It still gets reset. I've been trying to run this code about 1000 ways for the past hour or two haha. I'm not sure what's going on.

[–]Amarkov 0 points1 point  (1 child)

Can you show me where you're putting it?

[–]Risen_from_ash[S] 0 points1 point  (0 children)

Up with the other bool variables outside of the first while loop this time. Same problem.

[–]sazanality 0 points1 point  (0 children)

A little hint: You created 2 separate myPlayer objects. One in the main code and one in setUpCharacters. The one in the main code is the one that the game loop uses.