Hi there,
JRimmer wrote: |
---|
The first is how, using as much of my existing code as possible, to keep a running total. I need to have this display in a couple of places. |
At the start of each turn, you can create a variable that keeps the old state:
int turn_start_score = playerTotalScore;
That way, if the user roles a 1, you can just do
playerTotalScore = turn_start_score;
.
JRimmer wrote: |
---|
The second issue is how I use my devilAmountToRoll() correctly. |
You are only calling this function once, before your while loop:
int devilTimesToRoll = devilAmountToRoll(); //line 51
What you want to do means that every turn the opponent takes, you need to re-evaluate the amount of times he wants to roll. so you will need to redo
devilTimesToRoll = devilAmountToRoll();
at that point in your code.
Just as a pointer, it's considered good practice not to create global variable, such as your "devilTotalScore". It's very hard to keep track of whih functions actually change this variable. Consider for your functions to take the scores they need as arguments, for example:
int devilAmountToRoll(int devilTotalScore){}
Then you just create them in main():
1 2 3 4 5 6
|
int main()
{
int devil_score=0, devil_amount=0, player_score=0;
//...
devil_amount = devilAmountToRoll(devil_score);
}
|
Hope that helps.
All the best,
NwN