[Image of error](https://i.stack.imgur.com/ze1mq.png) It asks the question twice, just needing it asked once but the loops runs good and in-unison with the other parts of the program. Thank you for any ideas or suggestions, college class btw!

In a new program create the following functions: `Story`, `AskYesNo`; one string argument named `question`, `RollDie`; one int parameter named `sides` with a default value of 6, `Ending`, `Adventure`, obviously `main`.

Create the following global variables: `health`, `totalTreasure`.

The game should run as follows:

The player is told a story prompting them to seek treasure on an adventure. The player is asked if they would like to go adventuring. If the player says yes, numbers for an enemy attack, their own block, and an amount of treasure are randomly generated. If the player's block is higher than the enemy attack, they have successfully blocked and they receive the treasure. However, if the attack is higher, that number is subtracted from their health and they do not get the treasure. The player is then told their health and amount of `totalTreasure` and asked if they would like to adventure again. They can continue to adventure as long as their health is greater than zero, at which point the ending is run and they are told that they are dead If they instead quit before their health is zero, they are told how much health they have and how much treasure they ended up with.

```
// Global variables
int playerHealth = 15;
int playerTreasure = 0;

// Function Prototypes
void ending();
void story();
void adventure();
int rollDie(int sides = 6);

int main() { //My so called storyboard lol
    srand(time(0));
    story();
    adventure();
    ending();
    return 0;
}

//Functions
void ending() {
    if (playerHealth <= 0) {
        cout << endl;
        cout << "Your out of health! :(\n";
        cout << "The treasure you end up with is " << playerTreasure << " pieces!\n";
        cout <<"Thanks for adventuring!\n";
    } else { // if (askYesNo("Do you want to keep adventuring? (y/n)") == "n")
        cout << "You retired from adventuring!\n";
        cout << "You retired with " << playerTreasure << " treasure pieces!\n";
    }
    return;
}

void story() {
    cout << "You wake up in a forrest, by yourself\n";
    cout << "You only have " << playerHealth << " health points left.\n";
    cout << endl; 
}

string askYesNo(string givenQuestion) {
    string input; 
    do {
        cout << givenQuestion << endl;
        cin >> input;
    } while (input != "y" && input != "n");
    return input;
}

int rollDie(int sides) { 
    return rand() % sides + 1;
}

void adventure() {
    do {
        if (askYesNo("Do you want to keep adventuring? (y/n)") == "y")
        {
            int enemyAttack = rollDie(100);
            int playerBlock = rollDie(100);
            if (enemyAttack > playerBlock)
            {
                playerHealth -= 3;
                cout << "The enemy attack points is " << enemyAttack << "\n";
                cout << "Your player block is " << playerBlock << "\n";
                cout << "Your current health is " << playerHealth << " .\n";
                cout << "You did not gain any treasure\n"; 
            } else if (playerBlock >= enemyAttack)
            {
                playerTreasure += rollDie(6);
                cout << "The enemy attack points is " << enemyAttack << "\n";
                cout << "Your player block is " << playerBlock << "\n";
                cout << "You have blocked!\n";
                cout << "You gain treasure! your current treasure is " << playerTreasure << " \n"; 
            }
        } else {
            cout << "Your current health is " << playerHealth << " .\n";
            cout << "Your current amout of treasure is " << playerTreasure << " \n";
            return;
        }
    } while(playerHealth > 0 && askYesNo("Do you want to keep adventuring? (y/n)") == "y");
}

```

No error messages.