//Starts game / stays static void play_stay() { if(gameRunning == 0 && player_bet >= BET_INCREMENT) { deal_card(DEALER); //Display First Card To All Here deal_card(DEALER); deal_card(PLAYER); //Display First Card To All Here deal_card(PLAYER); gameRunning = 1; msg = NONE; change_turn(PLAYER); draw_window(); }else{ //Stay if(gameRunning == 1 && turn == PLAYER) { player_stay = 1; draw_window(); change_turn(DEALER); } } }
//Players turn, skip if staying static void player_turn() { if(gameRunning == 1 && player_stay == 1) { change_turn(DEALER); } }
void lets_play(char **map, int multi) { char ia; char player; char who_play; int nb; who_s_begin(&ia, &player, multi); who_play = PLAYER_A; while (01210) { if (!multi) if ((nb = player_ia_play(map, player, ia, who_play))) return ; if (multi == 1) if ((nb = player_player_play(map, player, ia, who_play))) return ; if (multi == -1) if ((nb = ia_ia_play(map, ia, player, who_play))) return ; if (nb == -1) { ft_putendl_fd("/!\\---There was an error---/!\\", 2); return ; } change_turn(&who_play); } }
/*same functionality as the function in chess.c- but more propriate to graphical mode */ int check_if_continue_playing_gui(SDL_Surface* screen,gameState* state, itemMove* moves){ change_turn(state, state->turn); // need to check if -we- are in check- so we need to change the current turn of the board isCheckWithUpdate(state); // change to original change_turn(state, state->turn); if (isMateWith(state, moves) == TRUE){// after the previous player played his move- check if it is math add_situation_sign(screen, MATE,getEnemyColor(state->turn)); return FALSE; } if (isTie(state, moves) == TRUE){// after the previous player played his move- check if it is tie (no possible moves and the king is not treatend) add_situation_sign(screen, TIE, getEnemyColor(state->turn)); return FALSE; } return TRUE; }
//Deal card to player static void hit_me() { if(gameRunning == 1 && turn == PLAYER) { deal_card(PLAYER); draw_window(); change_turn(PLAYER); } }
//Dealers turn, keep hitting until 17+, once 17+ stay static void dealer_turn() { if(gameRunning == 1) { if(dealer_stay == 0) { if(dealer_hand >= 17) { dealer_stay = 1; msg = DEALER_STAY; }else{ msg = DEALER_HIT; deal_card(DEALER); } } draw_window(); usleep(1000000); change_turn(DEALER); } }