Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.17 KB | None | 0 0
  1. void cashIn(int cash) {
  2.     if ((cashInTracker + cash) <= 1000 && (cash == 0 || cash == 20 || cash == 100 || cash == 500)) {
  3.         player += cash;
  4.         cashInTracker += cash;
  5.         killSwitch = 1;
  6.     }
  7.     else {
  8.         cout << "Du får sätta in max 1000kr. Du har satt in " << cashInTracker << " kr." << endl << "Tillåtna insatsmängder är 0, 20, 100 och 500kr." << endl;
  9.     }
  10. }
  11.  
  12. void bet(int betSize) {
  13.     if ((betSize >= 1) && (betSize <= 50) && (betSize <= player)) {
  14.         player -= betSize;
  15.         killSwitch = 1;
  16.     }
  17.     else {
  18.         cout << "Tillåten insats är 1 - 50 kronor. Var god försök igen: " << endl;
  19.     }
  20. }
  21.  
  22. void pull() {
  23.     string o = "[O]", x = "[X]", p = "[P]";
  24.     int random;
  25.     srand(time(0));
  26.  
  27.     for (int i = 0; i < 3; i++) {
  28.  
  29.         for (int j = 0; j < 3; j++) {
  30.  
  31.             random = rand() % 3;
  32.  
  33.             if (random == 0) {
  34.                 interface[i][j] = o;
  35.             }
  36.             else if (random == 1) {
  37.                 interface[i][j] = x;
  38.             }
  39.             else if (random == 2) {
  40.                 interface[i][j] = p;
  41.             }
  42.         }
  43.     }
  44. }
  45.  
  46. void print() {
  47.  
  48.     cout << endl;
  49.  
  50.     for (int i = 0; i < 3; i++)
  51.         for (int j = 0; j < 3; j++) {
  52.             cout << interface[i][j];
  53.             if (j == 2) {
  54.                 cout << endl;
  55.             }
  56.         }
  57.  
  58.     cout << endl << "Du har " << winLines << " lika rader." << endl << "Du har vunnit " << winSize << " kronor." << endl << endl;
  59.        
  60.  
  61.     winLines = 0;
  62. }
  63.  
  64. void payout() {
  65.    
  66.     for (int i = 0; i < 3; i++) {
  67.         if ((interface[i][0] == interface[i][1]) && (interface[i][0] == interface[i][2])) {
  68.             winLines += 1;
  69.         }
  70.     }
  71.     for (int j = 0; j < 3; j++) {
  72.         if ((interface[0][j] == interface[1][j]) && (interface[0][j] == interface[2][j])) {
  73.             winLines += 1;
  74.         }
  75.     }
  76.     if (interface[0][0] == interface[1][1] && interface[1][1] == interface[2][2]) {
  77.         winLines += 1;
  78.     }
  79.     if (interface[2][0] == interface[1][1] && interface[2][0] == interface[0][2]) {
  80.         winLines += 1;
  81.     }
  82.  
  83.  
  84.     if (winLines == 1) {
  85.         winSize = (betSize * (winLines * 2));
  86.     }
  87.     else if (winLines == 2) {
  88.         winSize = (betSize * (winLines * 4));
  89.     }
  90.     else if (winLines == 3) {
  91.         winSize = (betSize * (winLines * 8));
  92.     }
  93.     else if (winLines == 4) {
  94.         winSize = (betSize * (winLines * 16));
  95.     }
  96.     else if (winLines == 8) {
  97.         winSize = (betSize * (winLines * 128));
  98.     }
  99.  
  100.     player += winSize;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement