Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- //function
- void gamemode();
- void player();
- void ai();
- //main program
- int main(int argc, char** argv) {
- char name[15];
- cout << "Please Enter Your Name ! :" <<endl;
- cin >> name;
- gamemode();
- return 0;
- }
- //function Attributes
- void gamemode()
- {
- int gm;
- cout << "===========================================" << endl;
- cout << "Please choose a Gamemode!" << endl;
- cout << "===========================================" << endl;
- cout << "1. AI" << endl << "2. Multiplayer" << endl;
- cin >> gm;
- switch(gm)
- {
- case 1:
- ai();
- system("CLS");
- break;
- case 2:
- player();
- system("CLS");
- break;
- default:
- cout << "Wrong Input" << endl;
- return gamemode();
- }
- }
- void player()
- {
- char name1[15], name2[15];
- system("CLS");
- cout<< "1st Player Enter Your Name:"<<endl;
- cin>> name1;
- cout<< name1<< " You have join the game !"<<endl;
- cout << "" << endl;
- cout<< "2nd Player Enter Your Name:"<<endl;
- cin>>name2;
- cout<< name2<< " You have join the game !"<<endl;
- cout << "" << endl;
- cout<< name1<< " Choose Your Weapon !"<<endl;
- cout<< "1. ROCK\n2. PAPER\n3. SCISSORS"<<endl;
- int m, n;
- char y;
- cin>> m;
- switch(m)
- {
- case 1:
- cout << "you have chosen rock !" << endl;
- system("CLS");
- break;
- case 2:
- cout << "you have chosen paper !" << endl;
- system("CLS");
- break;
- case 3:
- cout << "you have chosen scissor !" << endl;
- system("CLS");
- break;
- default:
- cout << "Invalid input" << endl;
- break;
- }
- cout<< name2 << " Choose Your Weapon !"<<endl;
- cout<< "1. ROCK\n2. PAPER\n3. SCISSORS"<<endl;
- cin>> n;
- system("CLS");
- switch(n)
- {
- case 1:
- cout << "you have chosen Rock !" << endl;
- case 2:
- cout << "you have chosen paper !" << endl;
- break;
- case 3:
- cout << "you have chosen scissor !" << endl;
- break;
- default:
- cout << "Invalid input" << endl;
- break;
- }
- system("CLS");
- if (m == 1 && n == 1)
- {
- cout << name1 << ": Choose Rock\t"<< name2 <<": Choose Rock "<< endl;
- cout << "" << endl;
- cout << "===================================================================================" << endl;
- cout << "Both Players Chosen Rock !";
- cout << "\nThis Game Is A Draw !";
- cout << "" << endl;
- cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
- cin >> y;
- system("CLS");
- if (y =='y')
- {
- return player();
- }
- else
- {
- return gamemode();
- }
- }
- else if (m == 1 && n == 2)
- {
- cout << name1 << " Choose Rock " << endl << "LORE : CAN KILL SCISSOR WITH A SINGLE HIT !!" << endl;
- cout << "===================================================================================" << endl;
- cout << name2 <<" Choose Paper" << endl << "LORE : CAN KILL ROCK WITH A SINGLE HIT !!" << endl;
- cout<< name2 << " wins !";
- cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
- cin >> y;
- system("CLS");
- if (y =='y')
- {
- return player();
- }
- else
- {
- return gamemode();
- }
- }
- else if (m == 1 && n == 3)
- {
- cout << name1 << " Choose Rock " << endl << "LORE : CAN KILL SCISSORS WITH A SINGLE HIT !!" << endl;
- cout << "===================================================================================" << endl;
- cout << name2 << "Choose Scissors" << endl << "LORE : CAN KILL PAPER WITH A SINGLE HIT !!" << endl;
- cout << name1 << " wins !";
- cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
- cin >> y;
- system("CLS");
- if (y =='y')
- {
- return player();
- }
- else
- {
- return gamemode();
- }
- }
- else if (m == 2 && n == 1 )
- {
- cout << name1 << " Choose Paper " << endl << "LORE : CAN KILL ROCK WITH A SINGLE HIT !!" << endl;
- cout << "===================================================================================" << endl;
- cout << name2 << " Choose Rock" << endl << "LORE : CAN KILL SCISSORS WITH A SINGLE HIT !!" << endl;
- cout << name1 << " wins !";
- cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
- cin >> y;
- system("CLS");
- if (y =='y')
- {
- return player();
- }
- else
- {
- return gamemode();
- }
- }
- else if (m == 2 && n == 2)
- {
- cout << name1 << ": Choose Paper\t"<< name2 <<": Choose Paper "<< endl;
- cout << "" << endl;
- cout << "===================================================================================" << endl;
- cout << "Both Players Chosen Paper !";
- cout << "\nThis game is a Draw !";
- cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
- cin >> y;
- system("CLS");
- if (y =='y')
- {
- return player();
- }
- else
- {
- return gamemode();
- }
- }
- else if (m == 2 && n == 3)
- {
- cout << name1 << " Choose Paper " << endl << "LORE : CAN KILL ROCK WITH A SINGLE HIT !!" << endl;
- cout << "===================================================================================" << endl;
- cout << name2 << "Choose Scissors" << endl << "LORE : CAN KILL PAPER WITH A SINGLE HIT !!" << endl;
- cout << name2 << " wins !";
- cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
- cin >> y;
- system("CLS");
- if (y =='y')
- {
- return player();
- }
- else
- {
- return gamemode();
- }
- }
- else if (m == 3 && n == 1 )
- {
- cout << name1 << " Choose Scissors " << endl << "LORE : CAN KILL PAPER WITH A SINGLE HIT !!" << endl;
- cout << "===================================================================================" << endl;
- cout << name2 << " Choose Rock" << endl << "LORE : CAN KILL SCISSORS WITH A SINGLE HIT !!" << endl;
- cout << name2 << " wins !";
- cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
- cin >> y;
- system("CLS");
- if (y =='y')
- {
- return player();
- }
- else
- {
- return gamemode();
- }
- }
- else if (m == 3 && n == 2)
- {
- cout<< name1 << " Choose Scissors " << endl << "LORE : CAN KILL PAPER WITH A SINGLE HIT !!" << endl;
- cout << "===================================================================================" << endl;
- cout << name2 <<" Choose Paper" << endl << "LORE : CAN KILL ROCK WITH A SINGLE HIT !!" << endl;
- cout << name1 << "wins !";
- cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
- cin >> y;
- system("CLS");
- if (y =='y')
- {
- return player();
- }
- else
- {
- return gamemode();
- }
- }
- else if (m == 3 && n == 3)
- {
- cout << name1 << ": Choose Scissors\t" << endl << name2 << ": Choose Scissors" << endl;
- cout << "" << endl;
- cout << "===================================================================================" << endl;
- cout << "Both Players Chosen Scissors !";
- cout << "\nThis game is a Draw !";
- cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
- cin >> y;
- system("CLS");
- if (y =='y')
- {
- return player();
- }
- else
- {
- return gamemode();
- }
- }
- }
- void ai()
- {
- int v1, v2, v3;
- char b1;
- srand((unsigned)time(0));
- int weapon;
- v1 = rand() % 3+1;
- v2 = rand() % 3+1;
- v3 = rand() % 3+1;
- cout<<"====================================================================="<<endl;
- cout<< "You Have Chosen AI MODE ! (You are now Battling Asura The Gambler !)"<<endl;
- cout<< "Choose Your Weapon !"<<endl;
- cout << "1. ROCK"<<endl<<"2. PAPER"<<endl<<"3. SCISSORS"<<endl;
- cout<<"====================================================================="<<endl;
- cin>>weapon;
- system("CLS");
- switch(weapon){
- case 1:
- cout<<"====================================================================="<<endl;
- cout<< "You Have Chosen Rock !"<<endl;
- cout << "ROCK !"<< endl <<"LORE : CAN KILL SCISSOR WITH A SINGLE HIT !!"<< endl;
- cout<<"====================================================================="<<endl;
- if(v1==3){
- cout<< "-------------------------"<<endl;
- cout<< "| Asura Pick SCISSORS ! |"<<endl;
- cout<< "-------------------------"<<endl;
- cout<< "=========================================="<<endl;
- cout<< "| You Hit Asura With a Critical Damage ! |"<<endl;
- cout<< "=========================================="<<endl;
- cout<< "--------------------------------"<<endl;
- cout<< "| You Have Won Against Asura ! |"<<endl;
- cout<< "--------------------------------"<<endl;
- cout<<v1<<" = Value (for Debug)";
- cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
- cin>>b1;
- system("CLS");
- if (b1=='y'){
- return ai();
- }else{
- return gamemode();
- }
- } else if (v1==2){
- cout<< "-------------------------"<<endl;
- cout<< "| Asura Pick PAPER ! |"<<endl;
- cout<< "-------------------------"<<endl;
- cout<< "=========================================="<<endl;
- cout<< "| Asura Hit YOU With a Critical Damage ! |"<<endl;
- cout<< "=========================================="<<endl;
- cout<< "--------------------------------"<<endl;
- cout<< "| Asura Have Won Against You ! |"<<endl;
- cout<< "--------------------------------"<<endl;
- cout<<v1<<" = Value (for Debug)";
- cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
- cin>>b1;
- system("CLS");
- if (b1=='y'){
- return ai();
- }else{
- return gamemode();
- }
- } else {
- cout<< "-------------------------"<<endl;
- cout<< "Asura Pick ROCK !"<<endl;
- cout<< "-------------------------"<<endl;
- cout<< "THE FIGHT IS DRAW !"<<endl;
- cout<<v1<<" = Value (for Debug)"<<endl;
- }
- cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
- cin>>b1;
- system("CLS");
- if (b1=='y'){
- return ai();
- }else{
- return gamemode();
- }
- case 2:
- cout<<"====================================================================="<<endl;
- cout<< "You Have Chosen PAPER !"<<endl;
- cout << "PAPER!"<< endl <<"LORE : CAN KILL ROCK WITH A SINGLE HIT !!"<<endl;
- cout<<"====================================================================="<<endl;
- if(v2==3){
- cout<< "-------------------------"<<endl;
- cout<< "| Asura Pick ROCK ! |"<<endl;
- cout<< "-------------------------"<<endl;
- cout<< "=========================================="<<endl;
- cout<< "You Hit Asura With a Critical Damage !"<<endl;
- cout<< "=========================================="<<endl;
- cout<< "--------------------------------"<<endl;
- cout<< "| You Have Won Against Asura ! |"<<endl;
- cout<< "--------------------------------"<<endl;
- cout<<v2<<" = Value (for Debug)";
- cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
- cin>>b1;
- system("CLS");
- if (b1=='y'){
- return ai();
- }else{
- return gamemode();
- }
- } else if (v2==2){
- cout<< "-------------------------"<<endl;
- cout<< "| Asura Pick SCISSORS ! |"<<endl;
- cout<< "-------------------------"<<endl;
- cout<< "=========================================="<<endl;
- cout<< "Asura Hit YOU With a Critical Damage !"<<endl;
- cout<< "=========================================="<<endl;
- cout<< "--------------------------------"<<endl;
- cout<< "Asura Have Won Against You !"<<endl;
- cout<< "--------------------------------"<<endl;
- cout<<v2<<" = Value (for Debug)";
- cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
- cin>>b1;
- system("CLS");
- if (b1=='y'){
- return ai();
- }else{
- return gamemode();
- }
- } else {
- cout<< "-------------------------"<<endl;
- cout<< "| Asura Pick PAPER ! |"<<endl;
- cout<< "-------------------------"<<endl;
- cout<< "THE FIGHT IS DRAW !"<<endl;
- cout<<v2<<" = Value (for Debug)";
- }
- cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
- cin>>b1;
- system("CLS");
- if (b1=='y'){
- return ai();
- }else{
- return gamemode();
- }
- case 3:
- cout<<"====================================================================="<<endl;
- cout<< "You Have Chosen Scissors !"<<endl;
- cout << "SCISSORS !"<< endl <<"LORE : CAN KILL PAPER WITH A SINGLE HIT !!"<<endl;
- cout<<"====================================================================="<<endl;
- if(v3==3){
- cout<< "-------------------------"<<endl;
- cout<< "| Asura Pick PAPER ! |"<<endl;
- cout<< "-------------------------"<<endl;
- cout<< "=========================================="<<endl;
- cout<< "| You Hit Asura With a Critical Damage ! |"<<endl;
- cout<< "=========================================="<<endl;
- cout<< "--------------------------------"<<endl;
- cout<< "| You Have Won Against Asura ! |"<<endl;
- cout<< "--------------------------------"<<endl;
- cout<<v3<<" = Value (for Debug)";
- cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
- cin>>b1;
- system("CLS");
- if (b1=='y'){
- return ai();
- }else{
- return gamemode();
- }
- } else if (v3==2){
- cout<< "-------------------------"<<endl;
- cout<< "| Asura Pick ROCK ! |"<<endl;
- cout<< "-------------------------"<<endl;
- cout<< "=========================================="<<endl;
- cout<< "| Asura Hit You With a Critical Damage ! |"<<endl;
- cout<< "=========================================="<<endl;
- cout<< "--------------------------------"<<endl;
- cout<< "Asura Have Won Against You !"<<endl;
- cout<< "--------------------------------"<<endl;
- cout<<v3<<" = Value (for Debug)";
- cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
- cin>>b1;
- system("CLS");
- if (b1=='y'){
- return ai();
- }else{
- return gamemode();
- }
- } else {
- cout<< "-------------------------"<<endl;
- cout<< "| Asura Pick SCISSOR ! |"<<endl;
- cout<< "-------------------------"<<endl;
- cout<< "THE FIGHT IS DRAW !"<<endl;
- cout<<v3 <<" = Value (for Debug)"<<endl;
- }
- cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
- cin>>b1;
- system("CLS");
- if (b1=='y'){
- return ai();
- }else{
- return gamemode();
- }
- default:
- cout<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
- cin>>b1;
- system("CLS");
- if (b1=='y'){
- return ai();
- }else{
- return gamemode();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement