increasing a variable for no reason

im working on a mini rpg and it is driving me mad right now

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{
    srand(time(0));
    int exp = 1; // Experiance
    int life = 40;
    int e1health = 10; // Bloodfly Health
    int gold = 0; // starting gold
    int level = 1; // starting level
    int hp = 15; // Health points
    int mp = 10; // Mana Points
    int la = 2; // LA = Leather Armour
    int LS = 1; // LS = Leather Sheild
    int ndmg = rand(); // npc damage
    char dagger = 3; // Dagger = Weapon
    int weapon = dagger; // Equipped Weapon
    int armour = la; // Equipped Armour
    int sheild = LS; // Equipped Sheild
    int damage = (weapon); // your damage is judged by your equiped wepon
    char choice; // allows the user to make choices
    const int MAX_ITEMS = 5; // max invintory items (not yet used)
    string setup[MAX_ITEMS];

    int items = 0; // the amount of items you start with
    cout << "Welcome To Krentark, This RPG may be easy at first but it will test your skills\nYou start with a dagger, leather sheild and leather curiass " ;
    cin >> choice;
    {

    if (choice == 'f'|| choice == 'F')
    {
     weapon = (dagger + 0);
     cout << "You hit a " << weapon << endl;
     weapon = (dagger + 0);
     cout << "You hit a " << weapon << endl;
     cin >> choice;
    }
    }

    if (choice = 'c')
    {cout << "exp " << exp << endl;
    cin >> choice;}

    if (choice == 'e')
        {
        if (exp = 10)
        {level = (level + 1);
        life = (life + 10);
        cout << "you are now level " << level << " congradulations" << endl;
        cout << "Your exp is " << exp << endl ;}
        else if (exp < 10)
        {cout << "you do not have enough exp\n";}
        }
}


at the minute im just setting up the variables and checking they work, the problem is as you see, if you type c it will tell you current exp which should be 1 and it does, but if you type e it checks if you can can level up or not, the problem is if you type e it changes the exp to 10 for no reason and then levels the user up? why is this happening, its a carbon copy of my working use potion on my other script

1
2
3
4
5
6
7
8
9
10
if (choice == 'p')
        {
        if (potion >= 1)
        {potion = (potion - 1);
        life = (life + 20);
        cout << "you not have" << potion << "left ";
        cout << "Your health is now" << life << endl ;}
        else if (potion < 1)
        {cout << "you do not have enough potions\n";}
        }


anyone have any ideas how to fix this "bug"?
if (exp = 10)

= is assignment

you wanted ==, which is comparison
OHHHHH .. this has been destroying my head for like 20 minutes :L thanks for the help dude :)
let me know when u are finished with the mini rpg.. I wanna play it :)
Topic archived. No new replies allowed.