Advertisement
Guest User

Untitled

a guest
Dec 11th, 2013
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.93 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <ctime>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. void greenDice();
  7. void yellowDice();
  8. void redDice();
  9. int fish();
  10. int hook();
  11. int boot();
  12.  
  13. int main()
  14. {
  15.     int playerScore[4];
  16.     int turn[3];
  17.     int players;
  18.     int input;
  19.  
  20.     cout << "Welcome to the Fish Die game!";
  21.     cout << "Press 1 for rules, or 2 to start the game.";
  22.     cin >> input;
  23.  
  24.     if(input == 1) {
  25.         cout << "The rules are simple! Pick 3 dice out of the cup, then roll!\n";
  26.         cout << "Each fish you roll counts as 1 point,\n";
  27.         cout << "Each boot you roll counts as a strike, and any hooks can be rerolled. ";
  28.         cout << "Each roll set aside any fish and boots and reroll 3 die again.\n";
  29.         cout << "The first to 12 fish wins. If you get 3 boots, you get 0, and your turn is over.\n";
  30.     } else {
  31.         cout << "How many players will there be?\nEnter a number greater than 2\n";
  32.     }
  33.  
  34.     while(players >= 2 && players <= 12) {
  35.         cin >> players;
  36.         cout << "Please enter a valid number";
  37.     }
  38.  
  39.     system("PAUSE");
  40.     return 0;
  41. }
  42.  
  43. void roll()
  44. {
  45.     srand(time(0));
  46.     int s;
  47.  
  48.     for (int x = 1; x < 4; x++)
  49.         s = rand()%13;
  50.  
  51.     if (s < 6) {
  52.         greenDice();
  53.     } else if(s > 5 && s<9) {
  54.         yellowDice();
  55.     } else if(s>8) {
  56.         redDice();
  57.     }
  58. }
  59.  
  60. void greenDice()
  61. {
  62.     srand(time(0));
  63.     int g;
  64.  
  65.     g = rand()%6;
  66.  
  67.     if(g< 3) {
  68.         fish();
  69.     } else if(g>2 && g<5) {
  70.         hook();
  71.     } else if(g>4) {
  72.         boot();
  73.     }
  74. }
  75.  
  76. void yellowDice()
  77. {
  78.     srand(time(0));
  79.     int y;
  80.  
  81.     y = rand()%6;
  82.  
  83.     if(y<2) {
  84.             fish();
  85.     } else if(y>1 && y<4) {
  86.         hook();
  87.     } else if(y>3) {
  88.         boot();
  89.     }
  90. }
  91.  
  92. void redDice()
  93. {
  94.     srand (time(0));
  95.     int r;
  96.     r = rand()%6;
  97.    
  98.     if (r<1) {
  99.         fish();
  100.     } else if(r>0 && r< 3) {
  101.         hook();
  102.     } else if(r>2) {
  103.         boot();
  104.     }
  105. }
  106.  
  107. int fish()
  108. {
  109.     cout << "You rolled a fish";
  110.     ++turn[1];
  111. }
  112.  
  113. int hook()
  114. {
  115.     cout << "You rolled a hook";
  116.     ++turn[2];
  117. }
  118.  
  119. int boot()
  120. {
  121.     cout <<"You rolled a boot.";
  122.     ++turn[3];
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement