Need help with remembering numbers
Ok, so Im making what I call a battle system. I think I pretty much know what I need to know to do it and I've already started working out the logistics of it, but Im not too sure on how you would get it to remember a number. They life points are 100, how do input this number and make its so it will remember whatever would be taken out of it?
This is all I have so far
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int UHP[100]; // Users Hit points
int UATK = rand()%10; // Users Attack points
int UDFC = rand()%10; // Users Defence points
int UACC = rand()%10; // Users Accuracy points
int CHP[100]; // Challengers Hit points
int CATK = rand()%10; // Challengers Attack points
int CDFC = rand()%10; // Challengers Defence points
int CACC = rand()%10; // Challengers Accurasy points
cout<<"As your walking down a path a cloaked swordsman ambushes you.\n";
cout<<"He then challenges you to a fight and you humbly accept.\n";
cin.get();
}
Heres what I was thinking when you type in attack it will see if you hit by ( UACC <= 6 ) if it is then you hit if not you miss. afterwards the challenger would get to use defence if their ( CACC <= 6 ) if not the dont get to defend and it would take the random number generated from UATK and subtract it from CHP. but i cant figure out how you would make it so it would keep it subtracted and not just reset back to 100