Brain is turned to mush for the day, I just screwed something up need a hand

After question 8 the rings stop counting down.
Also I can’t figure out why I need to fail twice to kill it. will return with a fresh set of eyes tomorrow but help would be appreciated

//includes basic functions to save time
#include <iostream>

//List of Questions for quick reference

const std::string Question1 = "A Familiar figure from a past life appears...\nLooking you in the eye they ask:\n\n    \"Who is responsible for the worst thing you've ever done?\"";
const std::string Question2 = "Another Question2";
const std::string Question3 = "Another Question3";
const std::string Question4 = "Another Question4";
const std::string Question5 = "Another Question5";
const std::string Question6 = "Another Question6";
const std::string Question7 = "Another Question7";
const std::string Question8 = "Another Question8";
const std::string Question9 = "Another Question9";
const std::string Question10 = "Another Question10";

//List of Answers for quick reference

const std::string Answer1 = "Me";
const std::string Answer2 = "answer2";
const std::string Answer3 = "answer3";
const std::string Answer4 = "answer4";
const std::string Answer5 = "answer5";
const std::string Answer6 = "answer6";
const std::string Answer7 = "answer7";
const std::string Answer8 = "answer8";
const std::string Answer9 = "answer9";
const std::string Answer10 = "answer10";

//List Of Variables Used Throughout for quick reference

int RingOfHell = 9;
std::string UserResponse;
std::string Question;
std::string Answer;

//Included Funtions Ending with Main. Organized in order of occurence
//Except whe needed to include a function with-in a function


void AskQuestion()
{
    std::cout << Question << std::endl;
    std::cin >> UserResponse;
    std::cout << std::endl;
}

bool CheckAnswer()
{
    if (UserResponse == Answer)
    {
        RingOfHell = RingOfHell-1;
        if (RingOfHell > 1)
        {
            std::cout << RingOfHell << " Rings Remain.\n\n";
            return true;
        
        if (RingOfHell == 1)
        {
            std::cout <<RingOfHell<< " Ring Remains.\n\n";
            return true;
        }
        if (RingOfHell == 0)
        {
            std::cout << "Congratulations, You've made it to Purgatory. Continue?: ";
            std::cin >> UserResponse;
            std::cout <<std::endl;
            if (UserResponse == "yes")
            {
                return true;
            }
            else
            {
                std::cout << "  Thank You For Playing!\n\n";
                return false;
                }
            }
        }
        else
        {
            return 0;
        }
    }

    else
    {
        std::cout << "  Delusion betrays you...\n\n  Play again?: ";
        std::cin >> UserResponse;
        std::cout <<std::endl;
        if (UserResponse == "yes")
        {
            RingOfHell = 9;
            Answer = Answer1;
            return true;
        }
        else
        {
            std::cout << "  Thank You For Playing!\n\n";
            return false;
        }
    }
}

void NextQuestion()
{
    if (RingOfHell == 9)
    {
        Question = Question1;
        Answer = Answer1;
        return;
    }
    if (RingOfHell == 8)
    {
        Question = Question2;
        Answer = Answer2;
        return;
    }
    if (RingOfHell == 7)
    {
        Question = Question3;
        Answer = Answer3;
        return;
    }
    if (RingOfHell == 6)
    {
        Question = Question4;
        Answer = Answer4;
        return;
    }
    if (RingOfHell == 5)
    {
        Question = Question5;
        Answer = Answer5;
        return;
    }
    if (RingOfHell == 4)
    {
        Question = Question6;
        Answer = Answer6;
        return;
    }
    if (RingOfHell == 3)
    {
        Question = Question7;
        Answer = Answer7;
        return;
    }
    if (RingOfHell == 2)
    {
        Question = Question8;
        Answer = Answer8;
        return;
    }
    if (RingOfHell == 1)
    {
        Question = Question9;
        Answer = Answer9;
        return;
    }
    if (RingOfHell == 0)
    {
        Question = Question10;
        Answer = Answer10;
        return;
    }
    else
    {
        std::cout << "  Conratulations, you looked inward and discovered the truth we are all part of the greater Self.\n" <<
        "  You are free from our reign.\n\n";
        return;
    }
}

void PlayIntro()
{
//Feeling
    std::cout << 
    "\nYou awaken cold and confused, sweating from every pore.\n" <<
    "A Sinister Voice echoes:\n\n";

//Dialogue
    std::cout <<
    "   \"Welcome to the ninth ring of Hell\n" <<
    "    You will be tested and tried\n" <<
    "    Answer the questions correctly to move on\n" <<
    "    Answer incorrectly and spend eternity\n" <<
    "    Hopelessly trying to escape.\" \n\n";

//Feeling
    std::cout << "  You feel the presence leave, you are completely alone.\n\n";
}

bool PlayGame()
{
    if (RingOfHell == 9)
    {
        PlayIntro();
        NextQuestion();
    }
    AskQuestion();
    if (CheckAnswer())
    {
        NextQuestion();
        return true;
    }
    else
    {
        return false;
    }
    
}

int main()
{
    while (PlayGame())
    {
    PlayGame();
    }

    return 0;
}
if (RingOfHell > 1)
{
    // code...
}
else
{
    return 0;
}

Whn RingOfHell is 1 then that condition is false and thus 0 is returned from the function. Though you should use true/false for a function returning bool.

Also please look into maps.

I go past RingOfHell = 0 tho

That’s not mutually exclusive because you call PlayGame in the condition as well as the body of the loop.
When RingOfHell == 2. That’s happening in the body of the loop, when you return false during that it’s not stopping the loop, the returned value ends up being discarded.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms