Advertisement
codecstasy

5-10 Game update

Sep 29th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 12.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void menu()
  5. {
  6.     system("cls");
  7. }
  8.  
  9. int main()
  10. {
  11.     cout << "Welcome to 5-10 game!" << endl << "In this game, you can add 5 or 10 to the previous number."<<endl<<"Your target is to reach 100 first. The game always starts with 0."<<endl<<"For example, if you are provided with 50, in this case you can jump to 55 or 60. From 15, you can jump to 20 or 25."<<endl<<"Hope you enjoy the game! Best of luck"<<endl<<endl;
  12.     int game;
  13.     cout << "Press 1 to enter the game : ";
  14.     cin >> game;
  15.     menu();
  16.     cout << "Press 1 for single player / ";
  17.     cout << "Press 2 for multiplayers : ";
  18.     int game_players;
  19.     cin >> game_players;
  20.     menu();
  21.     if(game_players == 1)
  22.     {
  23.         cout << "Open first? Y/N : ";
  24.         char opening;
  25.         cin >> opening;
  26.         menu();
  27.         if(opening=='Y')
  28.         {
  29.             int x,y=0;
  30.             while(1)
  31.             {
  32.                 cout<<"You: ";
  33.                 cin >> x;
  34.                 if(x==y+5 || x==y+10)
  35.                 {
  36.                     if(x==5)
  37.                     {
  38.                         y=10;
  39.                         cout<<"CPU: "<<y<<endl;
  40.                     }
  41.                     if(x==10)
  42.                     {
  43.                         y=15;
  44.                         cout<<"CPU: "<<y<<endl;
  45.                     }
  46.                     if(x==15)
  47.                     {
  48.                         y=20;
  49.                         cout<<"CPU: "<<y<<endl;
  50.                     }
  51.                     if(x==20)
  52.                     {
  53.                         y=30;
  54.                         cout<<"CPU: "<<y<<endl;
  55.                     }
  56.                     if(x==25)
  57.                     {
  58.                         y=30;
  59.                         cout<<"CPU: "<<y<<endl;
  60.                     }
  61.                     if(x==30)
  62.                     {
  63.                         y=40;
  64.                         cout<<"CPU: "<<y<<endl;
  65.                     }
  66.                     if(x==35)
  67.                     {
  68.                         y=40;
  69.                         cout<<"CPU: "<<y<<endl;
  70.                     }
  71.                     if(x==40)
  72.                     {
  73.                         y=45;
  74.                         cout<<"CPU: "<<y<<endl;
  75.                     }
  76.                     if(x==45)
  77.                     {
  78.                         y=55;
  79.                         cout<<"CPU: "<<y<<endl;
  80.                     }
  81.                     if(x==50)
  82.                     {
  83.                         y=55;
  84.                         cout<<"CPU: "<<y<<endl;
  85.                     }
  86.                     if(x==55)
  87.                     {
  88.                         y=60;
  89.                         cout<<"CPU: "<<y<<endl;
  90.                     }
  91.                     if(x==60)
  92.                     {
  93.                         y=70;
  94.                         cout<<"CPU: "<<y<<endl;
  95.                     }
  96.                     if(x==65)
  97.                     {
  98.                         y=70;
  99.                         cout<<"CPU: "<<y<<endl;
  100.                     }
  101.                     if(x==70)
  102.                     {
  103.                         y=75;
  104.                         cout<<"CPU: "<<y<<endl;
  105.                     }
  106.                     if(x==75)
  107.                     {
  108.                         y=85;
  109.                         cout<<"CPU: "<<y<<endl;
  110.                     }
  111.                     if(x==80)
  112.                     {
  113.                         y=85;
  114.                         cout<<"CPU: "<<y<<endl;
  115.                     }
  116.                     if(x==85)
  117.                     {
  118.                         y=90;
  119.                         cout<<"CPU: "<<y<<endl;
  120.                     }
  121.                     if(x==90)
  122.                     {
  123.                         y=100;
  124.                         cout<<"CPU: "<<y<<endl;
  125.                         cout<<"Sorry! You lose"<<endl;
  126.                         cout<<"Press 0 to exit the game ";
  127.                         int exit;
  128.                         cin>>exit;
  129.                         if(exit==0) return 0;
  130.                     }
  131.                     if(x==95)
  132.                     {
  133.                         y=100;
  134.                         cout<<"CPU: "<<y<<endl;
  135.                         cout<<"Sorry! You lose"<<endl;
  136.                         cout<<"Press 0 to exit the game ";
  137.                         int exit;
  138.                         cin>>exit;
  139.                         if(exit==0) return 0;
  140.                     }
  141.                     if(x==100)
  142.                     {
  143.                         cout<<"Congratulations! You win"<<endl;
  144.                         cout<<"Press 0 to exit the game ";
  145.                         int exit;
  146.                         cin>>exit;
  147.                         if(exit==0) return 0;
  148.                     }
  149.                 }
  150.                 else
  151.                 {
  152.                     cout << "Wrong Input. Bye"<<endl;
  153.                     cout<<"Press 0 to exit the game ";
  154.                         int exit;
  155.                         cin>>exit;
  156.                         if(exit==0) return 0;
  157.                 }
  158.             }
  159.         }
  160.         else
  161.         {
  162.             int x,y=10;
  163.             cout<<"CPU: "<<y<<endl;
  164.             while(1)
  165.             {
  166.                 cout<<"You: ";
  167.                 cin>>x;
  168.                 if(x==y+5 || x==y+10)
  169.                 {
  170.                     if(x==15)
  171.                     {
  172.                         y=20;
  173.                         cout<<"CPU: "<<y<<endl;
  174.                     }
  175.                     if(x==20)
  176.                     {
  177.                         y=30;
  178.                         cout<<"CPU: "<<y<<endl;
  179.                     }
  180.                     if(x==25)
  181.                     {
  182.                         y=30;
  183.                         cout<<"CPU: "<<y<<endl;
  184.                     }
  185.                     if(x==30)
  186.                     {
  187.                         y=40;
  188.                         cout<<"CPU: "<<y<<endl;
  189.                     }
  190.                     if(x==35)
  191.                     {
  192.                         y=40;
  193.                         cout<<"CPU: "<<y<<endl;
  194.                     }
  195.                     if(x==40)
  196.                     {
  197.                         y=45;
  198.                         cout<<"CPU: "<<y<<endl;
  199.                     }
  200.                     if(x==45)
  201.                     {
  202.                         y=55;
  203.                         cout<<"CPU: "<<y<<endl;
  204.                     }
  205.                     if(x==50)
  206.                     {
  207.                         y=55;
  208.                         cout<<"CPU: "<<y<<endl;
  209.                     }
  210.                     if(x==55)
  211.                     {
  212.                         y=60;
  213.                         cout<<"CPU: "<<y<<endl;
  214.                     }
  215.                     if(x==60)
  216.                     {
  217.                         y=70;
  218.                         cout<<"CPU: "<<y<<endl;
  219.                     }
  220.                     if(x==65)
  221.                     {
  222.                         y=70;
  223.                         cout<<"CPU: "<<y<<endl;
  224.                     }
  225.                     if(x==70)
  226.                     {
  227.                         y=75;
  228.                         cout<<"CPU: "<<y<<endl;
  229.                     }
  230.                     if(x==75)
  231.                     {
  232.                         y=85;
  233.                         cout<<"CPU: "<<y<<endl;
  234.                     }
  235.                     if(x==80)
  236.                     {
  237.                         y=85;
  238.                         cout<<"CPU: "<<y<<endl;
  239.                     }
  240.                     if(x==85)
  241.                     {
  242.                         y=90;
  243.                         cout<<"CPU: "<<y<<endl;
  244.                     }
  245.                     if(x==90)
  246.                     {
  247.                         y=100;
  248.                         cout<<"CPU: "<<y<<endl;
  249.                         cout<<"Sorry! You lose"<<endl;
  250.                         cout<<"Press 0 to exit the game ";
  251.                         int exit;
  252.                         cin>>exit;
  253.                         if(exit==0) return 0;
  254.                     }
  255.                     if(x==95)
  256.                     {
  257.                         y=100;
  258.                         cout<<"CPU: "<<y<<endl;
  259.                         cout<<"Sorry! You lose"<<endl;
  260.                         cout<<"Press 0 to exit the game ";
  261.                         int exit;
  262.                         cin>>exit;
  263.                         if(exit==0) return 0;
  264.                     }
  265.                     if(x==100)
  266.                     {
  267.                         cout<<"Congratulations! You win"<<endl;
  268.                         cout<<"Press 0 to exit the game ";
  269.                         int exit;
  270.                         cin>>exit;
  271.                         if(exit==0) return 0;
  272.                     }
  273.                 }
  274.                 else
  275.                 {
  276.                     cout << "Wrong Input. Bye"<<endl;
  277.                     cout<<"Press 0 to exit the game ";
  278.                         int exit;
  279.                         cin>>exit;
  280.                         if(exit==0) return 0;
  281.                 }
  282.             }
  283.         }
  284.     }
  285.     else
  286.     {
  287.         char player1[100],player2[100];
  288.         cout<<"Enter the first name of player 1 : ";
  289.         scanf("%s",player1);
  290.         cout<<"Enter the first name of player 2 : ";
  291.         scanf("%s",player2);
  292.         int x=0,y=0;
  293.         printf("Who want to move first? Player 1(Press 1) or Player 2(Press 2) : ");
  294.         int first_move;
  295.         cin >> first_move;
  296.         menu();
  297.         for(int i=1 ; ; i++)
  298.         {
  299.             if(i%2!=0 && first_move==1)
  300.             {
  301.                 printf("turn of %s : ",player1);
  302.                 cin>>x;
  303.                 if(x==y+5 || x==y+10)
  304.                 {
  305.                     if(x==100)
  306.                     {
  307.                         printf("%s wins\n",player1);
  308.                         cout<<"Press 0 to exit the game ";
  309.                         int exit;
  310.                         cin>>exit;
  311.                         if(exit==0) return 0;
  312.                     }
  313.                 }
  314.                 else
  315.                 {
  316.                     cout << "Wrong Input. Bye"<<endl;
  317.                     cout<<"Press 0 to exit the game ";
  318.                         int exit;
  319.                         cin>>exit;
  320.                         if(exit==0) return 0;
  321.                 }
  322.             }
  323.             else if(i%2==0 && first_move==1)
  324.             {
  325.                 printf("turn of %s : ",player2);
  326.                 cin>>y;
  327.                 if(y==x+5 || y==x+10)
  328.                 {
  329.                     if(y==100)
  330.                     {
  331.                         printf("%s wins\n",player2);
  332.                         cout<<"Press 0 to exit the game ";
  333.                         int exit;
  334.                         cin>>exit;
  335.                         if(exit==0) return 0;
  336.                     }
  337.                 }
  338.                 else
  339.                 {
  340.                     cout << "Wrong Input. Bye"<<endl;
  341.                     cout<<"Press 0 to exit the game ";
  342.                         int exit;
  343.                         cin>>exit;
  344.                         if(exit==0) return 0;
  345.                 }
  346.             }
  347.             if(i%2!=0 && first_move==2)
  348.             {
  349.                 printf("turn of %s : ",player2);
  350.                 cin>>x;
  351.                 if(x==y+5 || x==y+10)
  352.                 {
  353.                     if(x==100)
  354.                     {
  355.                         printf("%s wins\n",player2);
  356.                         cout<<"Press 0 to exit the game ";
  357.                         int exit;
  358.                         cin>>exit;
  359.                         if(exit==0) return 0;
  360.                     }
  361.                 }
  362.                 else
  363.                 {
  364.                     cout << "Wong Input. Bye"<<endl;
  365.                     cout<<"Press 0 to exit the game ";
  366.                         int exit;
  367.                         cin>>exit;
  368.                         if(exit==0) return 0;
  369.                 }
  370.             }
  371.             else if(i%2==0 && first_move==2)
  372.             {
  373.                 printf("turn of %s : ",player1);
  374.                 cin>>y;
  375.                 if(y==x+5 || y==x+10)
  376.                 {
  377.                     if(y==100)
  378.                     {
  379.                         printf("%s wins\n",player1);
  380.                         cout<<"Press 0 to exit the game ";
  381.                         int exit;
  382.                         cin>>exit;
  383.                         if(exit==0) return 0;
  384.                     }
  385.                 }
  386.                 else {
  387.                     cout << "Wrong Input. Bye"<<endl;
  388.                     cout<<"Press 0 to exit the game ";
  389.                         int exit;
  390.                         cin>>exit;
  391.                         if(exit==0) return 0;
  392.                 }
  393.             }
  394.         }
  395.     }
  396.     return 0;
  397. }
  398.  
  399.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement