SHARE
TWEET

Untitled

a guest Nov 22nd, 2019 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string>
  4. #include <cstdlib>
  5. #include <ctime>
  6.  
  7. using namespace std;
  8. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  9.  
  10. //function
  11. void gamemode();
  12.    
  13. void player();
  14.  
  15. void ai();
  16.  
  17. //main program 
  18. int main(int argc, char** argv) {
  19.    
  20.     char name[15];
  21.     cout << "Please Enter Your Name ! :" <<endl;
  22.     cin >> name;
  23.  
  24.     gamemode();
  25.    
  26.    
  27.     return 0;
  28. }
  29.  
  30. //function Attributes
  31. void gamemode()
  32. {
  33.        
  34.     int gm;
  35.     cout << "===========================================" << endl;
  36.     cout << "Please choose a Gamemode!" << endl;
  37.     cout << "===========================================" << endl;
  38.     cout << "1. AI" << endl << "2. Multiplayer" << endl;
  39.     cin >> gm;
  40.     switch(gm)
  41.     {
  42.         case 1:
  43.             ai();
  44.             system("CLS");
  45.             break;
  46.         case 2:
  47.             player();
  48.             system("CLS");
  49.             break;
  50.         default:
  51.             cout << "Wrong Input" << endl;
  52.             return gamemode();
  53.     }
  54. }
  55.  
  56. void player()
  57. {
  58.    
  59.     char name1[15], name2[15];
  60.     system("CLS");
  61.     cout<< "1st Player Enter Your Name:"<<endl;
  62.     cin>> name1;
  63.     cout<< name1<< " You have join the game !"<<endl;
  64.     cout << "" << endl;
  65.     cout<< "2nd Player Enter Your Name:"<<endl;
  66.     cin>>name2;
  67.     cout<< name2<< " You have join the game !"<<endl;
  68.     cout << "" << endl;
  69.    
  70.     cout<< name1<< " Choose Your Weapon !"<<endl;
  71.     cout<< "1. ROCK\n2. PAPER\n3. SCISSORS"<<endl;
  72.     int m, n;
  73.     char y;
  74.    
  75.     cin>> m;
  76.     switch(m)
  77.     {
  78.         case 1:
  79.             cout << "you have chosen rock !" << endl;
  80.             system("CLS");
  81.             break;
  82.         case 2:
  83.             cout << "you have chosen paper !" << endl;
  84.             system("CLS");
  85.             break;
  86.         case 3:
  87.             cout << "you have chosen scissor !" << endl;
  88.             system("CLS");
  89.             break;
  90.         default:
  91.             cout << "Invalid input" << endl;
  92.             break;
  93.     }
  94.     cout<< name2 << " Choose Your Weapon !"<<endl;
  95.     cout<< "1. ROCK\n2. PAPER\n3. SCISSORS"<<endl;
  96.     cin>> n;
  97.     system("CLS");
  98.     switch(n)
  99.     {
  100.         case 1:
  101.             cout << "you have chosen Rock !" << endl;
  102.         case 2:
  103.             cout << "you have chosen paper !" << endl;
  104.             break;
  105.         case 3:
  106.             cout << "you have chosen scissor !" << endl;
  107.             break;
  108.         default:
  109.             cout << "Invalid input" << endl;
  110.             break;
  111.     }
  112.     system("CLS");
  113.    
  114.     if (m == 1 && n == 1)
  115.     {
  116.         cout << name1 << ": Choose Rock\t"<< name2 <<": Choose Rock "<< endl;
  117.         cout << "" << endl;
  118.         cout << "===================================================================================" << endl;
  119.         cout << "Both Players Chosen Rock !";
  120.         cout << "\nThis Game Is A Draw !";
  121.         cout << "" << endl;
  122.         cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
  123.         cin >> y;
  124.         system("CLS");
  125.         if (y =='y')
  126.         {
  127.             return player();
  128.         }
  129.         else
  130.         {
  131.             return gamemode();
  132.         }
  133.     }
  134.    
  135.     else if (m == 1 && n == 2)
  136.     {
  137.         cout << name1 << " Choose Rock " << endl << "LORE : CAN KILL SCISSOR WITH A SINGLE HIT !!" << endl;
  138.         cout << "===================================================================================" << endl;
  139.         cout << name2 <<" Choose Paper" << endl << "LORE : CAN KILL ROCK WITH A SINGLE HIT !!" << endl;
  140.         cout<< name2 << " wins !";
  141.         cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
  142.         cin >> y;
  143.         system("CLS");
  144.         if (y =='y')
  145.         {
  146.             return player();
  147.         }
  148.         else
  149.         {
  150.             return gamemode();
  151.         }
  152.     }
  153.    
  154.     else if (m == 1 && n == 3)
  155.     {
  156.         cout << name1 << " Choose Rock " << endl << "LORE : CAN KILL SCISSORS WITH A SINGLE HIT !!" << endl;
  157.         cout << "===================================================================================" << endl;
  158.         cout << name2 << "Choose Scissors" << endl << "LORE : CAN KILL PAPER WITH A SINGLE HIT !!" << endl;
  159.         cout << name1 << " wins !";
  160.         cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
  161.         cin >> y;
  162.         system("CLS");
  163.         if (y =='y')
  164.         {
  165.             return player();
  166.         }
  167.         else
  168.         {
  169.             return gamemode();
  170.         }
  171.     }
  172.    
  173.     else if (m == 2 && n == 1 )
  174.     {
  175.         cout << name1 << " Choose Paper " << endl << "LORE : CAN KILL ROCK WITH A SINGLE HIT !!" << endl;
  176.         cout << "===================================================================================" << endl;
  177.         cout << name2 << " Choose Rock" << endl << "LORE : CAN KILL SCISSORS WITH A SINGLE HIT !!" << endl;
  178.         cout << name1 << " wins !";
  179.         cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
  180.         cin >> y;
  181.         system("CLS");
  182.         if (y =='y')
  183.         {
  184.             return player();
  185.         }
  186.         else
  187.         {
  188.             return gamemode();
  189.         }
  190.     }
  191.    
  192.     else if (m == 2 && n == 2)
  193.     {
  194.         cout << name1 << ": Choose Paper\t"<< name2 <<": Choose Paper "<< endl;
  195.         cout << "" << endl;
  196.         cout << "===================================================================================" << endl;
  197.         cout << "Both Players Chosen Paper !";
  198.         cout << "\nThis game is a Draw !";
  199.         cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
  200.         cin >> y;
  201.         system("CLS");
  202.         if (y =='y')
  203.         {
  204.             return player();
  205.         }
  206.         else
  207.         {
  208.             return gamemode();
  209.         }
  210.     }
  211.    
  212.     else if (m == 2 && n == 3)
  213.     {
  214.         cout << name1 << " Choose Paper " << endl << "LORE : CAN KILL ROCK WITH A SINGLE HIT !!" << endl;
  215.         cout << "===================================================================================" << endl;
  216.         cout << name2 << "Choose Scissors" << endl << "LORE : CAN KILL PAPER WITH A SINGLE HIT !!" << endl;
  217.         cout << name2 << " wins !";
  218.         cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
  219.         cin >> y;
  220.         system("CLS");
  221.         if (y =='y')
  222.         {
  223.             return player();
  224.         }
  225.         else
  226.         {
  227.             return gamemode();
  228.         }
  229.     }
  230.    
  231.     else if (m == 3 && n == 1 )
  232.     {
  233.         cout << name1 << " Choose Scissors " << endl << "LORE : CAN KILL PAPER WITH A SINGLE HIT !!" << endl;
  234.         cout << "===================================================================================" << endl;
  235.         cout << name2 << " Choose Rock" << endl << "LORE : CAN KILL SCISSORS WITH A SINGLE HIT !!" << endl;
  236.         cout << name2 << " wins !";
  237.         cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
  238.         cin >> y;
  239.         system("CLS");
  240.         if (y =='y')
  241.         {
  242.             return player();
  243.         }
  244.         else
  245.         {
  246.             return gamemode();
  247.         }
  248.        
  249.     }
  250.    
  251.     else if (m == 3 && n == 2)
  252.     {
  253.         cout<< name1 << " Choose Scissors " << endl << "LORE : CAN KILL PAPER WITH A SINGLE HIT !!" << endl;
  254.         cout << "===================================================================================" << endl;
  255.         cout << name2 <<" Choose Paper" << endl << "LORE : CAN KILL ROCK WITH A SINGLE HIT !!" << endl;
  256.         cout << name1 << "wins !";
  257.         cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
  258.         cin >> y;
  259.         system("CLS");
  260.         if (y =='y')
  261.         {
  262.             return player();
  263.         }
  264.         else
  265.         {
  266.             return gamemode();
  267.         }
  268.     }
  269.    
  270.     else if (m == 3 && n == 3)
  271.     {
  272.         cout << name1 << ": Choose Scissors\t" << endl << name2 << ": Choose Scissors" << endl;
  273.         cout << "" << endl;
  274.         cout << "===================================================================================" << endl;
  275.         cout << "Both Players Chosen Scissors !";
  276.         cout << "\nThis game is a Draw !";
  277.         cout << endl << "Want to Play Again ? [y] for yes or press any key for exit" << endl;
  278.         cin >> y;
  279.         system("CLS");
  280.         if (y =='y')
  281.         {
  282.             return player();
  283.         }
  284.         else
  285.         {
  286.             return gamemode();
  287.         }
  288.     }
  289. }
  290.  
  291. void ai()
  292. {
  293.     int v1, v2, v3;
  294.     char b1;
  295.     srand((unsigned)time(0));
  296.     int weapon;
  297.     v1 = rand() % 3+1;
  298.     v2 = rand() % 3+1;
  299.     v3 = rand() % 3+1;
  300.     cout<<"====================================================================="<<endl;
  301.     cout<< "You Have Chosen AI MODE ! (You are now Battling Asura The Gambler !)"<<endl;
  302.     cout<< "Choose Your Weapon !"<<endl;
  303.     cout << "1. ROCK"<<endl<<"2. PAPER"<<endl<<"3. SCISSORS"<<endl;
  304.     cout<<"====================================================================="<<endl;
  305.     cin>>weapon;
  306.     system("CLS");
  307.     switch(weapon){
  308.         case 1:
  309.             cout<<"====================================================================="<<endl;
  310.             cout<< "You Have Chosen Rock !"<<endl;
  311.             cout << "ROCK !"<< endl <<"LORE : CAN KILL SCISSOR WITH A SINGLE HIT !!"<< endl;
  312.             cout<<"====================================================================="<<endl;
  313.             if(v1==3){
  314.                 cout<< "-------------------------"<<endl;
  315.                 cout<< "| Asura Pick SCISSORS ! |"<<endl;
  316.                 cout<< "-------------------------"<<endl;
  317.                 cout<< "=========================================="<<endl;
  318.                 cout<< "| You Hit Asura With a Critical Damage ! |"<<endl;
  319.                 cout<< "=========================================="<<endl;
  320.                 cout<< "--------------------------------"<<endl;
  321.                 cout<< "| You Have Won Against Asura ! |"<<endl;
  322.                 cout<< "--------------------------------"<<endl;
  323.                 cout<<v1<<" = Value (for Debug)";
  324.             cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
  325.             cin>>b1;
  326.             system("CLS");
  327.             if (b1=='y'){
  328.                 return ai();
  329.             }else{
  330.                 return gamemode();
  331.             }
  332.             } else if (v1==2){
  333.                 cout<< "-------------------------"<<endl;
  334.                 cout<< "| Asura Pick PAPER ! |"<<endl;
  335.                 cout<< "-------------------------"<<endl;
  336.                 cout<< "=========================================="<<endl;
  337.                 cout<< "| Asura Hit YOU With a Critical Damage ! |"<<endl;
  338.                 cout<< "=========================================="<<endl;
  339.                 cout<< "--------------------------------"<<endl;
  340.                 cout<< "| Asura Have Won Against You ! |"<<endl;
  341.                 cout<< "--------------------------------"<<endl;
  342.                 cout<<v1<<" = Value (for Debug)";
  343.             cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
  344.             cin>>b1;
  345.             system("CLS");
  346.             if (b1=='y'){
  347.                 return ai();
  348.             }else{
  349.                 return gamemode();
  350.             }
  351.             } else {       
  352.                 cout<< "-------------------------"<<endl;
  353.                 cout<< "Asura Pick ROCK !"<<endl;
  354.                 cout<< "-------------------------"<<endl;
  355.                 cout<< "THE FIGHT IS DRAW !"<<endl;
  356.                 cout<<v1<<" = Value (for Debug)"<<endl;        
  357.             }
  358.             cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
  359.             cin>>b1;
  360.             system("CLS");
  361.             if (b1=='y'){
  362.                 return ai();
  363.             }else{
  364.                 return gamemode();
  365.             }
  366.  
  367.         case 2:
  368.             cout<<"====================================================================="<<endl;
  369.             cout<< "You Have Chosen PAPER !"<<endl;
  370.             cout << "PAPER!"<< endl <<"LORE : CAN KILL ROCK WITH A SINGLE HIT !!"<<endl;
  371.             cout<<"====================================================================="<<endl;
  372.             if(v2==3){
  373.                 cout<< "-------------------------"<<endl;
  374.                 cout<< "| Asura Pick ROCK ! |"<<endl;
  375.                 cout<< "-------------------------"<<endl;
  376.                 cout<< "=========================================="<<endl;
  377.                 cout<< "You Hit Asura With a Critical Damage !"<<endl;
  378.                 cout<< "=========================================="<<endl;
  379.                 cout<< "--------------------------------"<<endl;
  380.                 cout<< "| You Have Won Against Asura ! |"<<endl;
  381.                 cout<< "--------------------------------"<<endl;
  382.                 cout<<v2<<" = Value (for Debug)";
  383.             cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
  384.             cin>>b1;
  385.             system("CLS");
  386.             if (b1=='y'){
  387.                 return ai();
  388.             }else{
  389.                 return gamemode();
  390.             }
  391.             } else if (v2==2){
  392.                 cout<< "-------------------------"<<endl;
  393.                 cout<< "| Asura Pick SCISSORS ! |"<<endl;
  394.                 cout<< "-------------------------"<<endl;
  395.                 cout<< "=========================================="<<endl;
  396.                 cout<< "Asura Hit YOU With a Critical Damage !"<<endl;
  397.                 cout<< "=========================================="<<endl;
  398.                 cout<< "--------------------------------"<<endl;
  399.                 cout<< "Asura Have Won Against You !"<<endl;
  400.                 cout<< "--------------------------------"<<endl;
  401.                 cout<<v2<<" = Value (for Debug)";
  402.             cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
  403.             cin>>b1;
  404.             system("CLS");
  405.             if (b1=='y'){
  406.                 return ai();
  407.             }else{
  408.                 return gamemode();
  409.             }
  410.             } else {
  411.                 cout<< "-------------------------"<<endl;      
  412.                 cout<< "| Asura Pick PAPER ! |"<<endl;
  413.                 cout<< "-------------------------"<<endl;
  414.                 cout<< "THE FIGHT IS DRAW !"<<endl;
  415.                 cout<<v2<<" = Value (for Debug)";          
  416.             }
  417.             cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
  418.             cin>>b1;
  419.             system("CLS");
  420.             if (b1=='y'){
  421.                 return ai();
  422.             }else{
  423.                 return gamemode();
  424.             }
  425.         case 3:
  426.             cout<<"====================================================================="<<endl;
  427.             cout<< "You Have Chosen Scissors !"<<endl;
  428.             cout << "SCISSORS !"<< endl <<"LORE : CAN KILL PAPER WITH A SINGLE HIT !!"<<endl;
  429.             cout<<"====================================================================="<<endl;
  430.             if(v3==3){
  431.                 cout<< "-------------------------"<<endl;
  432.                 cout<< "| Asura Pick PAPER ! |"<<endl;
  433.                 cout<< "-------------------------"<<endl;
  434.                 cout<< "=========================================="<<endl;
  435.                 cout<< "| You Hit Asura With a Critical Damage ! |"<<endl;
  436.                 cout<< "=========================================="<<endl;
  437.                 cout<< "--------------------------------"<<endl;
  438.                 cout<< "| You Have Won Against Asura ! |"<<endl;
  439.                 cout<< "--------------------------------"<<endl;
  440.                 cout<<v3<<" = Value (for Debug)";
  441.             cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
  442.             cin>>b1;
  443.             system("CLS");
  444.             if (b1=='y'){
  445.                 return ai();
  446.             }else{
  447.                 return gamemode();
  448.             }
  449.             } else if (v3==2){
  450.                 cout<< "-------------------------"<<endl;
  451.                 cout<< "| Asura Pick ROCK ! |"<<endl;
  452.                 cout<< "-------------------------"<<endl;
  453.                 cout<< "=========================================="<<endl;
  454.                 cout<< "| Asura Hit You With a Critical Damage ! |"<<endl;
  455.                 cout<< "=========================================="<<endl;
  456.                 cout<< "--------------------------------"<<endl;
  457.                 cout<< "Asura Have Won Against You !"<<endl;
  458.                 cout<< "--------------------------------"<<endl;
  459.                 cout<<v3<<" = Value (for Debug)";
  460.             cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
  461.             cin>>b1;
  462.             system("CLS");
  463.             if (b1=='y'){
  464.                 return ai();
  465.             }else{
  466.                 return gamemode();
  467.             }
  468.             } else {
  469.                 cout<< "-------------------------"<<endl;  
  470.                 cout<< "| Asura Pick SCISSOR ! |"<<endl;
  471.                 cout<< "-------------------------"<<endl;
  472.                 cout<< "THE FIGHT IS DRAW !"<<endl;
  473.                 cout<<v3 <<" = Value (for Debug)"<<endl;           
  474.             }
  475.             cout<<endl<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
  476.             cin>>b1;
  477.             system("CLS");
  478.             if (b1=='y'){
  479.                 return ai();
  480.             }else{
  481.                 return gamemode();
  482.             }
  483.                
  484.         default:
  485.             cout<<"Want to Play Again ? [y] for yes or press any key for exit"<<endl;
  486.             cin>>b1;
  487.             system("CLS");
  488.             if (b1=='y'){
  489.                 return ai();
  490.             }else{
  491.                 return gamemode();
  492.             }
  493.     }
  494. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top