Quote:
Originally Posted by xpi0t0s View Post
What's with all the asterisks? Makes the code very unreadable. Use spaces for indentation and code blocks when posting code here to preserve formatting.

Could you also give a screenshot (copy and paste the text, not a bitmap) of the input you give and output you get?

In case 2, what is the value of mGoldRequired just before the if?
Sorry, dont know why all the * came up.

I think that is the issue, it does not know the value of mGoldRequired, but here is where it is confusing.

Take the 2 seperate cpp files

1. Player.cpp
2. Store.cpp

Now in the player code, I use spells which cost magicPoints, if I go to cast a spell, it tests to see if the player has enough magicPoints before casting the spell, if you dont have enough, then it will not let you cast that spell. Now the code in the store.cpp, is the same as the spell code, but what happens when you try to buy potions, is on the first pass it will let you buy something no matter how much gold you have, then put you into negative gold. Once you have purchased a potion, it will then not let you buy anything if you dont have enough gold. So why does it work on 1 piece of code and not the other. I have included both cpp files in my original post.

In this example, I have from the onset 5 magic points and 10 gold.

Spell:

You encountered a goblin
Prepare for battle

1) Attack, 2) Cast Spell, 3) Run Away:

Please select your spell

1) FireBall 10 Magic Points
2) Water Jet 9 Magic Points
3) Lightening Bolt 8 Magic Points
4) Poison Wrap 7 Magic Points

1

You dont have enough Magic Points

1) Attack, 2) Cast Spell, 3) Run Away:

Now potions:

Welcome to my store, what can I do for you?

1) View Prices, 2) Buy Potions, 3) Buy Armor, 4) Rest a while, 5) Leave...

2

What Potions would you like to buy?

We have 1) Belt, 2) Heal, 3) Poison, 4) Invisability...

You have purchased a Heal Potion for 100 Gold

1) View Prices, 2) Buy Potions, 3) Buy Armor, 4) Rest a while, 5) Leave...

Now if I try to buy it wont let me, as my gold is in the minus figures