User Controls

Help me find wtf is wrong with my c++ code

  1. #1
    Dissociator African Astronaut
    I think its something to do with new line idk because my brain is fried someone help me out here

    #include <iostream>
    #include <cctype>
    #include <cstdlib>
    using namespace std;

    int main()
    {
    system("color 21");
    int Attack = 1;
    int Defence = 1;
    int Health = 3;
    int Stats = 10;
    int Pick = 0;
    int Boss = 1;
    double Picker = 0;
    int Level = 1;
    int Exp = 0;
    int Gold = 300;
    int NextLevel = 10;
    char Ch = 0;
    char Ch1 = 0;
    int Full = Health;
    int RatA = 3;
    int RatD = 2;
    int RatH = 9;
    int Nothing = 0;
    int PickA = 0;
    int KingA = 6;
    int KingD = 4;
    int KingH = 16;
    int SkeletonA = 4;
    int SkeletonD = 2;
    int SkeletonH = 12;
    int GhostA = 8;
    int GhostD = 6;
    int GhostH = 21;
    int CyclopsA = 6;
    int CyclopsD = 4;
    int CyclopsH = 14;
    int DragonA = 12;
    int DragonD = 8;
    int DragonH = 25;

    cout << "Welcome to some bullshit *+=Made by Dissociator=+*" << endl;
    for( ; Stats > 0 ; )
    {

    cout << "Choose your Stats"
    << " (1)Attack(" << Attack <<") (2)Defence(" <<Defence << ") (3)Health(" <<Health << ") {you have["
    << Stats << "] left}" << endl;

    cin >> Pick;

    if(Pick == 1)
    {
    ++Attack;
    --Stats;
    }
    if(Pick == 2)
    {
    ++Defence;
    --Stats;
    }
    if(Pick == 3)
    {
    ++++++Health;
    --Stats;
    }
    }
    cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
    << "You picked " << Attack << " Attack " << Defence << " Defence "
    << Health << " Health Press any Number and Enter to Confirm\n\n\n\n\n\n\n";
    cin >> Nothing;
    cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
    Full = Health;
    for( ; ; )
    {
    cout << "(1)Stats (2)Heal (3)Level Up (4)Train (5)Boss "
    << Boss << endl;

    cin >> Picker;

    if((Picker < 0) || (Picker > 5))
    {
    cout <<"Invalid Number try again"
    << endl;
    }
    if(Picker == 1)
    {
    cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
    << "Yor Stats are " << Attack << " Attack " << Defence
    << " Defence " << Health << "/" << Full << " Health " << endl
    << "Level " << Level << endl
    << Exp << " exp " << endl
    << "Next Level " << NextLevel <<"exp." << endl
    << Gold << "Gold" << endl;
    }
    if(Picker == 2)
    {
    cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
    << "Do you want to get healed for 100 Gold?\n" << endl
    << " (y/n)" << endl;

    cin >> Ch;
    if((tolower(Ch) == 'y') && (Gold >= 100))
    {
    Gold = Gold - 100;
    Full = Health;
    cout << "\n\n\n You Are Healed!" << endl << endl;
    }
    if((Gold < 0) && (tolower(Ch) == 'y'))
    {
    cout << "You do not have enoth money";
    }
    }
    if(Picker == 3)
    {
    cout << "Do you want to level up?" <<endl << "You need "
    << NextLevel << endl << "You have " << Exp << endl
    << " (y/n)" << endl;
    cin >> Ch1;
    if((tolower(Ch1) == 'y') && (Exp >= NextLevel))
    {
    Exp = Exp - NextLevel;
    NextLevel = NextLevel + 5;
    ++Level;

    cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
    << " Choose a Stat (1)Attack(" << Attack
    << ") (2)Defence(" << Defence
    << ") (3)Health (" <<Health << ")" << endl;

    cin >> Pick;

    if(Pick == 1)
    {
    ++Attack;
    }
    if(Pick == 2)
    {
    ++Defence;
    }
    if(Pick == 3)
    {
    ++++++Health;
    Full = Health;
    }
    }
    }

    // Gaint Rat Starts Here
    if((Picker == 4) && (Boss == 1))
    {
    cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
    << " ***Gaint Rat***" << endl
    << "You get first strike" << endl;
    for( ; (Full > 0) && ( RatH > 0) ; )
    {
    cout << "Health " << Health << "/" << Full << endl << "(1)Run Away"
    << endl << "(2)Attack " << endl;

    cin >> PickA;

    if((PickA == 1) && (Level >= 2))
    {
    cout << "you ran away" << endl;
    break;
    break;
    }
    if((PickA == 1) && (Level <= 1))
    {
    cout << " you failed to escape" << endl;
    }
    if(PickA == 2)
    {
    RatH = RatH + (RatD / 2 - Attack);
    cout << "Gaint Rat took " << -(RatD / 2 - Attack)
    << " Damage" << endl;
    if(RatH <= 0)
    {
    cout << "***Gaint Rat Died!***" << endl << " you gained 4 exp."
    << endl << " you got 30 gold" << endl;
    Exp = Exp + 4;
    Gold = Gold + 30;
    }
    if(RatH > 0)
    {
    Full = Full + (Defence / 2 - RatA);
    cout << "You took " << -(Defence / 2 - RatA)
    << " Damage" << endl;
    if(Full <= 0)
    {
    cout << "***You Lost!***" << endl << " you lost half your exp."
    << endl << " you lost half your gold" << endl;
    Exp = Exp / 2;
    Gold = Gold / 2;
    }
    }
    }
    }
    }

    RatH = 9;
    if(Full <= 0)
    {
    Full = 1;
    }
    if(Full > Health)
    {
    Full = Health;
    }
    // Gaint Rat Ends Here
    // King Rat Starts Here
    if((Picker == 5) && (Boss == 1))
    {
    Picker = 45;
    cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
    << " +++King Rat+++" << endl
    << "You Don't get first strike" << endl;
    for( ; (Full > 0) && ( KingH > 0) ; )
    {
    cout << "Health " << Health << "/" << Full << endl << "(1)Run Away"
    << endl << "(2)Attack " << endl;

    cin >> PickA;

    if((PickA == 1) && (Level >= 4))
    {
    cout << "you ran away" << endl;
    break;
    break;
    }
    if((PickA == 1) && (Level <= 3))
    {
    cout << " you failed to escape" << endl;
    }
    if(PickA == 2)
    {
    if(KingH > 0)
    {
    Full = Full + (Defence / 2 - KingA);
    cout << "You took " << -(Defence / 2 - KingA)
    << " Damage" << endl;
    if(Full <= 0)
    {
    cout << "***You Lost!***" << endl << " you lost half your exp."
    << endl << " you lost half your gold" << endl;
    Exp = Exp / 2;
    Gold = Gold / 2;
    }
    if(Full >=1)
    {
    KingH = KingH + (KingD / 2 - Attack);
    cout << "King Rat took " << -(KingD / 2 - Attack)
    << " Damage" << endl;
    if(KingH <= 0)
    {
    cout << "***King Rat Died!***" << endl << " you gained 12 exp."
    << endl << " you got 90 gold" << endl;
    Exp = Exp + 12;
    Gold = Gold + 90;
    Boss = Boss + 1;
    system("color 37");

    }
    }

    }
    }
    }
    }

    KingH = 18;
    if(Full <= 0)
    {
    Full = 1;
    }
    if(Full > Health)
    {
    Full = Health;
    }
    // King Rat Ends Here
    // Skeleton Starts Here
    if((Picker == 4) && (Boss == 2))
    {
    cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
    << " ***Skeleton***" << endl
    << "You get first strike" << endl;
    for( ; (Full > 0) && ( SkeletonH > 0) ; )
    {
    cout << "Health " << Health << "/" << Full << endl << "(1)Run Away"
    << endl << "(2)Attack " << endl;

    cin >> PickA;

    if((PickA == 1) && (Level >= 3))
    {
    cout << "you ran away" << endl;
    break;
    break;
    }
    if((PickA == 1) && (Level <= 2))
    {
    cout << " you failed to escape" << endl;
    }
    if(PickA == 2)
    {
    SkeletonH = SkeletonH + (SkeletonD / 2 - Attack);
    cout << "Skeleton took " << -(SkeletonD / 2 - Attack)
    << " Damage" << endl;
    if(SkeletonH <= 0)
    {
    cout << "***Skeleton Died!***" << endl << " you gained 6 exp."
    << endl << " you got 45 gold" << endl;
    Exp = Exp + 6;
    Gold = Gold + 45;
    }
    if(SkeletonH > 0)
    {
    Full = Full + (Defence / 2 - SkeletonA);
    cout << "You took " << -(Defence / 2 - SkeletonA)
    << " Damage" << endl;
    if(Full <= 0)
    {
    cout << "***You Lost!***" << endl << " you lost half your exp."
    << endl << " you lost half your gold" << endl;
    Exp = Exp / 2;
    Gold = Gold / 2;
    }
    }
    }
    }
    }

    SkeletonH = 12;
    if(Full <= 0)
    {
    Full = 1;
    }
    if(Full > Health)
    {
    Full = Health;
    }
    // Skeleton Ends Here
    // Ghost Starts Here
    if((Picker == 5) && (Boss == 2))
    {
    Picker = 45;
    cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
    << " +++Ghost+++" << endl
    << "You Don't get first strike" << endl;
    for( ; (Full > 0) && ( GhostH > 0) ; )
    {
    cout << "Health " << Health << "/" << Full << endl << "(1)Run Away"
    << endl << "(2)Attack " << endl;

    cin >> PickA;

    if((PickA == 1) && (Level >= 4))
    {
    cout << "you ran away" << endl;
    break;
    break;
    }
    if((PickA == 1) && (Level <= 3))
    {
    cout << " you failed to escape" << endl;
    }
    if(PickA == 2)
    {
    if(GhostH > 0)
    {
    Full = Full + (Defence / 2 - GhostA);
    cout << "You took " << -(Defence / 2 - GhostA)
    << " Damage" << endl;
    if(Full <= 0)
    {
    cout << "***You Lost!***" << endl << " you lost half your exp."
    << endl << " you lost half your gold" << endl;
    Exp = Exp / 2;
    Gold = Gold / 2;
    }
    if(Full >=1)
    {
    GhostH = GhostH + (GhostD / 2 - Attack);
    cout << "Ghost took " << -(GhostD / 2 - Attack)
    << " Damage" << endl;
    if(GhostH <= 0)
    {
    cout << "***Ghost Died!***" << endl << " you gained 16 exp."
    << endl << " you got 110 gold" << endl;
    Exp = Exp + 16;
    Gold = Gold + 110;
    Boss = Boss + 1;
    system("color 41");
    }
    }

    }
    }
    }
    }

    GhostH = 18;
    if(Full <= 0)
    {
    Full = 1;
    }
    if(Full > Health)
    {
    Full = Health;
    }
    // Ghost Ends Here
    // Cyclops Starts Here
    if((Picker == 4) && (Boss == 3))
    {
    cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
    << " ***Cyclops***" << endl
    << "You get first strike" << endl;
    for( ; (Full > 0) && ( CyclopsH > 0) ; )
    {
    cout << "Health " << Health << "/" << Full << endl << "(1)Run Away"
    << endl << "(2)Attack " << endl;

    cin >> PickA;

    if((PickA == 1) && (Level >= 6))
    {
    cout << "you ran away" << endl;
    break;
    break;
    }
    if((PickA == 1) && (Level <= 5))
    {
    cout << " you failed to escape" << endl;
    }
    if(PickA == 2)
    {
    CyclopsH = CyclopsH + (CyclopsD / 2 - Attack);
    cout << "Cyclops took " << -(CyclopsD / 2 - Attack)
    << " Damage" << endl;
    if(CyclopsH <= 0)
    {
    cout << "***Cyclops Died!***" << endl << " you gained 10 exp."
    << endl << " you got 60 gold" << endl;
    Exp = Exp + 10;
    Gold = Gold + 60;
    }
    if(CyclopsH > 0)
    {
    Full = Full + (Defence / 2 - CyclopsA);
    cout << "You took " << -(Defence / 2 - CyclopsA)
    << " Damage" << endl;
    if(Full <= 0)
    {
    cout << "***You Lost!***" << endl << " you lost half your exp."
    << endl << " you lost half your gold" << endl;
    Exp = Exp / 2;
    Gold = Gold / 2;
    }
    }
    }
    }
    }

    CyclopsH = 9;
    if(Full <= 0)
    {
    Full = 1;
    }
    if(Full > Health)
    {
    Full = Health;
    }
    // Cyclops Ends Here
    // Dragon Starts Here
    if((Picker == 5) && (Boss == 3))
    {
    cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
    << " +++Dragon+++" << endl
    << "You Don't get first strike" << endl;
    for( ; (Full > 0) && ( DragonH > 0) ; )
    {
    cout << "Health " << Health << "/" << Full << endl << "(1)Run Away"
    << endl << "(2)Attack " << endl;

    cin >> PickA;

    if((PickA == 1) && (Level >= 8))
    {
    cout << "you ran away" << endl;
    break;
    break;
    }
    if((PickA == 1) && (Level <= 7))
    {
    cout << " you failed to escape" << endl;
    }
    if(PickA == 2)
    {
    if(DragonH > 0)
    {
    Full = Full + (Defence / 2 - DragonA);
    cout << "You took " << -(Defence / 2 - DragonA)
    << " Damage" << endl;
    if(Full <= 0)
    {
    cout << "***You Lost!***" << endl << " you lost half your exp."
    << endl << " you lost half your gold" << endl;
    Exp = Exp / 2;
    Gold = Gold / 2;
    }
    if(Full >=1)
    {
    DragonH = DragonH + (DragonD / 2 - Attack);
    cout << "Dragon took " << -(DragonD / 2 - Attack)
    << " Damage" << endl;
    if(DragonH <= 0)
    {
    cout << "***Dragon Died!***" << endl << " you gained 32 exp."
    << endl << " you got 160 gold" << endl;
    Exp = Exp + 32;
    Gold = Gold + 160;
    Boss = Boss + 1;
    system("color 21");
    cout << "Good Job! " << endl << "You Won!"
    << endl << "this game was made by"
    << " ***Eric Sondraal!***" << endl;
    return 0;
    }
    }

    }
    }
    }
    }

    DragonH = 25;
    if(Full <= 0)
    {
    Full = 1;
    }
    if(Full > Health)
    {
    Full = Health;
    }
    // Dragon Ends Here
    }


    return 0;
    }
  2. #2
    Lanny Bird of Courage
    lol, use code tags and tell us what expected vs. actual behavior is.
  3. #3
    Lanny Bird of Courage
    also

    for( ; Stats > 0 ; )


    is bad style. Use a while loop if you don't have initialization and per-iteration instructions.
  4. #4
    Lanny Bird of Courage
    also put it in the right forum ffs
  5. #5
    SBTlauien African Astronaut
    Also use in-line if-statements.
Jump to Top