#include <iostream>#include "spaceship.h"//includes the spaceship.h file//using std::cin;using std::cout;using std::endl;#include<ctime>//allows us to use time for the roller function//#include "roller.h"//includes roller, allowing us to have random numbers//string ItemNames[] = {"Special Attack", "Fix More Damage", "Upgrade Hull", "Upgrade Laser", "Point Status"};//creates an array which stores the menu options//int DisplayMessage(){ int an; for(int j = 0; j < 4; j++) cout<<j+1<<"-"<<ItemNames[j]<<endl; cout<<"What do you want to do?"<<endl; cin>>an; return an;//stores and returns the number inputed by the user//}string OptNames[] = {"Attack", "Fix Damage", "Scan enemies ship", "Status", "Use Item"};//creates an array which stores the menu options//int DoMenu()//displays the menu options along with numbers//{ int ans; for(int i = 0; i < 4; i++) cout<<i+1<<"-"<<OptNames[i]<<endl; cout<<"What do you want to do?"<<endl; cin>>ans; return ans;//stores and returns the number inputed by the user//}int main(){string PName;//Remembers important numbers and pilots name//int ant = 3;//Upgrade hull strength//int amnt = 3;//Upgrade laser power//int MaxD = 30;//Maximum damage//int LP = 3;//Laser power//int HS = 3;//Hull strength//const int Num_Enemies = 3;//Makes the number of enemies 3//Spaceship enemies[Num_Enemies];//creates enemy object//Spaceship spaceship1;//create spaceship object//Spaceship spaceitem;cout<< "Please enter your name: "<<endl;//Ask user to enter information to remember//cin>>PName;//Pilot Name// spaceship1.setPilotName(PName); //sets values above into the member functions belonging to the spaceship1 object. I do this by using the variables defined above as parameters.// spaceship1.setMaxDamagePoints(MaxD); spaceship1.setLaserPower(LP); spaceship1.setHullStrength(HS); enemies[0].setPilotName("The Terminator");//sets values and names for the enemies// enemies[0].setHullStrength(2); enemies[0].setMaxDamagePoints(20); enemies[0].setLaserPower(2); enemies[1].setPilotName("Shrek"); enemies[1].setHullStrength(3); enemies[1].setLaserPower(3); enemies[1].setMaxDamagePoints(30); enemies[2].setPilotName("Darth Vaider"); enemies[2].setHullStrength(9); enemies[2].setMaxDamagePoints(40); enemies[2].setLaserPower(9);srand(static_cast<unsigned int>(time(NULL)));//returns a value of the time_t type and srand() takes a parameter of unsigned int type//Roller oneToTwenty(1, 20);//Create objects and make scope for random numbers//Roller Fix(1, (spaceship1.getHullStrength() + 2));//create object and scope for random numbers//int ro =Fix.GetRoll();//Declare ro and set it equal to random numbers//int Roll = oneToTwenty.GetRoll();//Declare Roll and set it equal to random numbers// for (int currEn=0; currEn<=2; currEn++)//rotates through the enemies and allows the user to battle each// { if( (currEn > 0) && (!(spaceship1.IsDead())))//if the user defeats an enemy the following apears on the screen// { point = point + 5;//If the user kills the enemy, the user is awarded 5 points// cout<<"Nice to see you again Captain "<<spaceship1.getPilotName()<<". Your new enemy is "<<enemies[currEn].getPilotName()<<" and his stats are: "<<endl; enemies[currEn].PrintStats(); } if( (currEn == 0) && (!(spaceship1.IsDead())))//for the first enemy, the following apears after the user enters a name// { cout<< "Welcome captain "<<spaceship1.getPilotName()<<". Your enemy's name is " <<enemies[currEn].getPilotName()<<" and his stats are: "<<endl; enemies[currEn].PrintStats(); cout<<"Now here are your options, choose wisely: "<<endl; } Roller Attack(1,(spaceship1.getLaserPower() + 2));//Create objects and make scope for random numbers// int rol = Attack.GetRoll();//sets rol equal to the random numbers// Roller EAttack(1,(enemies[currEn].getLaserPower() + 2));//Create objects and make scope for random numbers// int ol = EAttack.GetRoll();//seys ol equal to random numbers while(!(spaceship1.IsDead())&&!(enemies[currEn].IsDead())) { point++;//Gives the user a point for every turn// int opt = DoMenu();//sets opt equal to the number returned by the user after seeing the menu// switch(opt)//decides which case, depending on what opt is// { case 1: Roll = oneToTwenty.GetRoll();//makes Roll equal new random numbers// enemies[currEn].IsHit(Roll); if (enemies[currEn].IsHit(Roll))//checks if the enemy is hit// { rol = Attack.GetRoll();//makes rol equal to new random numbers// cout<<endl<<"You have hit the enemy! You did "<<rol<<" points of damage to the enemy."<<endl;//informs the user the enemy has been hit, and gives the amount of damage received// enemies[currEn].GiveDamage(rol );//gives damage to the enemy// } else cout<<endl<<"You have missed the enemy!"<<endl; break; case 2: ro = Fix.GetRoll();//makes ro equal to new random numbers// spaceship1.FixDamage(ro);//fixes damages done to users ship// break; case 3: enemies[currEn].PrintStats();//prints enemies stats// break; case 4: spaceship1.PrintStats();//prints users stats// break; case 5: int answer = DisplayMessage(); switch(answer) { case 1: enemies[currEn].GiveDamage(point );//gives damage to the enemy// cout<<"You have done "<< point<< " points of damage to the enemy!"<<endl; break; case 2: spaceship1.FixDamage(point);//fixes damages done to users ship// cout<<"You have fixed "<< point<< " points of damage to your ship!"<<endl; break; case 3: spaceship1.UpgradeHull(point); cout<<"You have added "<< point<< " points to your hull!"<<endl;//informs the user of the amount upgraded// break; break; case 4: spaceship1.UpgradeLaser(point); cout<<"You have added "<< point<< " points to your lasers!"<<endl;//informs the user of the amount upgraded// break; case 5: cout<< "You have "<<spaceitem.GetPoints()<<" points"<<endl;//shows the user available points// break; default: cout<<"Please enter a number(1-4)!"<<endl;//prints if the user types in an invalid entry// break; } default: cout<<"Please enter a number(1-4)!"<<endl;//prints if the user types in an invalid entry// break; }//end switch// if(opt == 4)//allos the user to check the enemy and user's stats without wasting the users turn// continue; Roller Efix(1, (enemies[currEn].getHullStrength() + 2));//Create objects and make scope for random numbers// int o = Efix.GetRoll();//makes o equal to random numbers// Roller Enemy(1,2);//Creates object and scope for random numbers// int en = Enemy.GetRoll();//makes en equal to the random numbers// if(!(enemies[currEn].IsDead()))//continues only if the enemy is alive// { switch(en)//uses the random number en to decide what the computer is going to do// { case 1: Roll = oneToTwenty.GetRoll();//makes Roll equal new random numbers// spaceship1.IsHit(Roll); if (spaceship1.IsHit(Roll))//Tests to see if the users spaceship is hit// { ol = EAttack.GetRoll();//sets ol equal to new random numbers// cout<<enemies[currEn].getPilotName()<<" has hit you! He has done "<<ol<<" points of damage to you."<<endl; spaceship1.GiveDamage(ol );//gives damage to the users ship// } else cout<<"He missed You!"<<endl; break; case 2: enemies[currEn].FixDamage(o);//fixes the enemies ship// cout<<enemies[currEn].getPilotName()<< " has repaired "<<o<<" points to his ship."<<endl; break; }//end switch// }//end if(!(enemies[currEn].IsDead()))// if(!(spaceship1.IsDead())&&!(enemies[currEn].IsDead()))//continues if both ships are alive// continue; else { if(spaceship1.IsDead())//outputs the following if the user has been killed// cout<<"The enemy has defeated you, better luck next time!"<<endl; else { spaceship1.UpgradeHull(ant);//if the user defeats the enemy, his hull and laser are upgraded by the amounts at the beggining of main// spaceship1.UpgradeLaser(amnt); spaceship1.setCurrentDamagePoints(0);//resets current damage to 0// cout<<"Good job! Because of your glorious battle, I have given you a new ship, check out the stats: "<<endl; spaceship1.PrintStats();//informs the user of the upgrade and prints the status// } } }//end while// }//end for// return 0; }//end main//