// Saints Final Drive.cpp
// created by Adam Wisbrock
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
    srand((unsigned)time(0));
    bool scored_touchdown = false;
    bool lost_ball = false;
    int yards = 75;
    int first_down = 10;
    int attempts = 4;
    int play_call;   
    cout << "Welcome to Saints Super Bowl Final Drive!\n";
    cout << "Time to take over the Saints offense. The score is 31-27 Colts, and\n";
    cout << "the ball is on your own 25-yd. line.\n";
    cin.get();    
    while (scored_touchdown == false && lost_ball == false && attempts > 0)
    {
          cout << "What do you do, Drew? You have " << yards << " yards to go.\n";
          cout << "There are " << first_down << " yards before a first down, and\n";
          cout << "you have " << attempts << " attempts.\n";
          cin.get();
          cout << "1. Hand it off to Pierre Thomas\n";
          cout << "2. Screen pass to Reggie Bush\n";
          cout << "3. Play action pass to Marques Colston\n";
          cout << "4. Deep pass to Robert Meachem\n";
          cin >> play_call;
          switch ( play_call )
          {
                 case 1:
                      {
                      cout << "You hand it off to Pierre Thomas!\n";
                      int thomas = rand() % (10 - 1 + 1) - 4;
                      int fumble = rand() % (60 - 1 + 1) + 1;
                      if (fumble == 1)
                      {
                                 cout << "You fumble the ball!\n";
                                 cin.get();
                                 cout << "The Colts kneel out the clock and win Super Bowl XLIV!\n";
                                 cout << "Better luck next time.\n";
                                 lost_ball = true;
                      }
                      else
                      {     
                                 cout << "Pierre Thomas runs the ball up the middle for a net gain of " << thomas << " yards!\n";
                                 yards = yards - thomas;
                                 first_down = first_down - thomas;
                                 attempts = attempts - 1;
                                 if (yards == 0 || yards < 0)
                                 {
                                           cout << "TOUCHDOWN! THE SAINTS WIN!\n";
                                           scored_touchdown = true;
                                 }
                              
                                 if (first_down == 0 || first_down < 0)
                                 {
                                                cout << "That's a first down!\n";
                                                attempts = 4;
                                                first_down = 10;
                                 }
                       
                                 
                       }
                      break;
                      }
                 case 2:
                      {
                      int bush = rand() % (9 - 1 + 1) + 1;
                      int bush_catch = rand() % (10 - 1 + 1) + 1;
                      cout << "You throw a screen pass to Reggie Bush!\n";
                      if (bush_catch < 6)
                      {
                                     cout << "That's an incomplete pass!\n";
                                     attempts = attempts - 1;
                      }
                      else
                      {
                          cout << "He catches the ball for a gain of " << bush << " yards!\n";
                          yards = yards - bush;
                          first_down = first_down - bush;
                          attempts = attempts - 1;
                          if (yards == 0 || yards < 0)
                                 {
                                           cout << "TOUCHDOWN! THE SAINTS WIN!\n";
                                           scored_touchdown = true;
                                 }
                              
                          else if (first_down == 0 || first_down < 0)
                                 {
                                                cout << "That's a first down!\n";
                                                attempts = 4;
                                                first_down = 10;
                                 }
                       
                                           
                          
                      }
                      
                 break;
                 }
                 case 3:   
                        {           
                      cout << "You throw a play action pass to Marques Colston!\n";
                      int colston = rand() % (15 - 1 + 1) + 5;
                      int colston_catch = rand() % (10 - 1 + 1) + 1;
                      if (colston_catch < 8)
                      {
                                cout << "It's incomplete!\n";
                                attempts = attempts - 1;
                      }
                      else
                      {
                          cout << "He catches the ball for a gain of " << colston << " yards!\n";
                          yards = yards - colston;
                          first_down = first_down - colston;
                          attempts = attempts - 1;
                          if (yards == 0 || yards < 0)
                                 {
                                           cout << "TOUCHDOWN! THE SAINTS WIN!\n";
                                           scored_touchdown = true;
                                 }
                                 if (first_down == 0 || first_down < 0)
                                 {
                                                cout << "That's a first down!\n";
                                                attempts = 4;
                                                first_down = 10;
                                 }
                      
                          
                          }
                      
                      break;
                 }
                 case 4:  
                      {            
                      cout << "You throw it deep to Robert Meachem!\n";
                      int meachem = rand() % (40 - 1 + 1) + 20;
                      int meachem_catch = rand() % (10 - 1 + 1) + 1;
                      if (meachem_catch < 10)
                      {
                                        cout << "It's incomplete.\n";
                                        attempts = attempts - 1;
                      }
                      else
                      {
                          cout << "He catches the ball for a gain of " << meachem << " yards!\n";
                          yards = yards - meachem;
                          first_down = first_down - meachem;
                          attempts = attempts - 1;
                          if (yards == 0 || yards < 0)
                                 {
                                           cout << "TOUCHDOWN! THE SAINTS WIN!\n";
                                           scored_touchdown = true;
                                 }
                              
                                 if (first_down == 0 || first_down < 0)
                                 {
                                                cout << "That's a first down!\n";
                                                attempts = 4;
                                                first_down = 10;
                                 }
                       
                                                
                      }
                      
                 break;
                 }
                 }     
          }
if (attempts == 0)
{
                                              cout << "The Saints turn the ball over!\n";
                                              cout << "The Colts kneel out the clock and win Super Bowl XLIV!\n";
                                              cout << "Better luck next time.\n";
                                              lost_ball = true;
}  
cin.get();
cin.get();
return 0;
}

                          
                      
          
    

