diff --git a/src/main/c/Stefan/slot_machine.c b/src/main/c/Stefan/slot_machine.c index a3731e6..c7bda9e 100644 --- a/src/main/c/Stefan/slot_machine.c +++ b/src/main/c/Stefan/slot_machine.c @@ -2,6 +2,7 @@ #include #include #include +#include void slotMachine(){ @@ -86,9 +87,10 @@ void randomizeSymbols(char symbols[]){ int spin(char symbols[], int bet, int balance){ - showResult(symbols); - int winnings = getWinnings(symbols, bet); + + showResult(symbols, winnings); + balance += winnings; printf("Aktuelles Guthaben: %d\n-------------------------\n", balance); return balance; @@ -125,12 +127,30 @@ int getWinnings(char symbols[], int bet){ return winnings; } -void showResult(char symbols[]){ - printf("\n"); +void showResult(char symbols[], int winnings){ - for (int i = 0; i < ROWS; i++){ - printf(" %c | %c | %c\n", symbols[i * ROWS], symbols[i * ROWS + 1], symbols[i * ROWS + 2]); + char winnerMessage[] = {""}; + + if(winnings > 0){ + strcpy(winnerMessage, " WINNER "); + } else { + strcpy(winnerMessage, " LOSER "); } + + printf("\n" + " .-------.\n" + " {-%s-} \n" + " .=============.\n" + " | | __\n" + " | [%c] [%c] [%c] |( )\n" + " | [%c] [%c] [%c] | ||\n" + " | [%c] [%c] [%c] | ||\n" + " | |_||\n" + " | xxx ::::::: |--'\n" + " | ooo ::::::: |\n" + " | $$$ ::::::: |\n" + " | __ |\n" + " |_____/__\\____|\n\n", winnerMessage, symbols[0], symbols[1], symbols[2], symbols[3], symbols[4], symbols[5], symbols[6], symbols[7], symbols[8]); } void welcomeMessage(){ diff --git a/src/main/c/Stefan/slot_machine.h b/src/main/c/Stefan/slot_machine.h index 3639e7e..c08b4bb 100644 --- a/src/main/c/Stefan/slot_machine.h +++ b/src/main/c/Stefan/slot_machine.h @@ -14,6 +14,6 @@ int subtractBetFromBalance(int bet, int balance); void randomizeSymbols(char symbols[]); int spin(char symbols[], int bet, int balance); int getWinnings(char symbols[], int bet); -void showResult(char symbols[]); +void showResult(char symbols[], int winnings); #endif // SLOT_MACHINE_H \ No newline at end of file