|
@ -1,20 +1,23 @@ |
|
|
#include "slot_machine.h" |
|
|
#include "slot_machine.h" |
|
|
#include <stdio.h> |
|
|
#include <stdio.h> |
|
|
|
|
|
#include <stdlib.h> |
|
|
|
|
|
#include <time.h> |
|
|
|
|
|
|
|
|
void slotMachine(){ |
|
|
void slotMachine(){ |
|
|
|
|
|
|
|
|
welcomeMessage(); |
|
|
welcomeMessage(); |
|
|
|
|
|
|
|
|
|
|
|
Symbol symbols[NUM_OF_SYMBOLS]; |
|
|
|
|
|
|
|
|
int balance = getBalance(); |
|
|
int balance = getBalance(); |
|
|
|
|
|
|
|
|
while(balance > 0){ |
|
|
while(balance > 0){ |
|
|
|
|
|
|
|
|
int bet = getBet(balance); |
|
|
int bet = getBet(balance); |
|
|
balance = subtractBetFromBalance(bet, balance); |
|
|
balance = subtractBetFromBalance(bet, balance); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createSymbols(symbols); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -50,6 +53,41 @@ int subtractBetFromBalance(int bet, int balance){ |
|
|
return balance - bet; |
|
|
return balance - bet; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void createSymbols(Symbol symbols[]){ |
|
|
|
|
|
|
|
|
|
|
|
char possibleLetter[] = "ABCD"; |
|
|
|
|
|
int possibleValue[] = { 3,5,10,20 }; |
|
|
|
|
|
|
|
|
|
|
|
srand(time(NULL)); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < NUM_OF_SYMBOLS; i++) { |
|
|
|
|
|
|
|
|
|
|
|
int r = rand() % 100; |
|
|
|
|
|
|
|
|
|
|
|
// 35% chance für A |
|
|
|
|
|
if (r < 35) { |
|
|
|
|
|
symbols[i].letter = possibleLetter[0]; |
|
|
|
|
|
symbols[i].value = possibleValue[0]; |
|
|
|
|
|
} |
|
|
|
|
|
// 30% chance für B |
|
|
|
|
|
else if (r < 65) { |
|
|
|
|
|
symbols[i].letter = possibleLetter[1]; |
|
|
|
|
|
symbols[i].value = possibleValue[1]; |
|
|
|
|
|
} |
|
|
|
|
|
// 20% chance für C |
|
|
|
|
|
else if (r < 85) { |
|
|
|
|
|
symbols[i].letter = possibleLetter[2]; |
|
|
|
|
|
symbols[i].value = possibleValue[2]; |
|
|
|
|
|
} |
|
|
|
|
|
// 15% chance für D |
|
|
|
|
|
else { |
|
|
|
|
|
symbols[i].letter = possibleLetter[3]; |
|
|
|
|
|
symbols[i].value = possibleValue[3]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void welcomeMessage(){ |
|
|
void welcomeMessage(){ |
|
|
printf("Herzlich Willkommen zur \n\n" |
|
|
printf("Herzlich Willkommen zur \n\n" |
|
|
" _ _ _ _ \n" |
|
|
" _ _ _ _ \n" |
|
|