int player(t_gboard *p4, char *cl, int player) { int move; int win; move = -1; while (move == -1) { ft_putendl("Your turn you mud !"); if ((move = ft_player()) == -1) { ft_putstr(cl); p4->error = COL_STR; } else { ft_putstr(cl); move = ft_play(p4, move, player); } print_board(p4); if (move != -1) win = check_win(p4, player); } return (win); }
static void ft_playerturn(t_data *data) { int ret; ret = 0; while (ret == 0) { ft_player(data); if ((ret = ft_winner(data, 1)) == 1) { ft_putendl("You WIN !"); return ; } ft_ia(data); ft_aff(data); if ((ret = ft_winner(data, 2)) == 1) { ft_putendl("You lose !"); return ; } } ft_putendl("Draw !"); }
int ft_game(char **m) { t_alcu v; v.turn = 1; v.nbm = 0; v.winner = 2; while (v.winner == 2) { ft_putcolor("cyan"); ft_display_matches(m); v.nbm = ft_nbmatches(m); ft_display_players(v.turn); if (v.turn) m = ft_player(m, v.nbm, &v.turn); else m = ft_ia(m, v.nbm, &v.turn); v.nbm = ft_nbmatches(m); if (v.nbm == 0) v.winner = v.turn; } free(m); return (v.winner); }