示例#1
0
文件: game.c 项目: ralight/ggz
void game_get_play(int play_hand, int num_valid_cards,
		   card_t * valid_cards)
{
	int play_num, hand_num;
	hand_t *hand = &ggzcards.players[play_hand].hand;
	bool valid_plays[hand->hand_size];
	card_t play;

	assert(play_hand == ggzcards.play_hand);

	for (hand_num = 0; hand_num < hand->hand_size; hand_num++)
		valid_plays[hand_num] = FALSE;
	for (play_num = 0; play_num < num_valid_cards; play_num++) {
		card_t play_card = valid_cards[play_num];
		for (hand_num = 0; hand_num < hand->hand_size; hand_num++) {
			card_t hand_card = hand->cards[hand_num];
			if (are_cards_equal(play_card, hand_card)) {
				valid_plays[hand_num] = TRUE;
				break;
			}
		}
		assert(hand_num < hand->hand_size);
	}

	play = get_play(ggzcards.play_hand, valid_plays);

	ggz_debug(DBG_PLAY, "We're playing the %s of %s.",
		  get_face_name(play.face), get_suit_name(play.suit));

	make_play(play);
}
示例#2
0
void	play_the_game(t_rows **begin)
{
    int i;

    i = 0;
    while ((*begin)->line[0] != 0)
    {
        get_play(begin, i);
        if ((*begin)->line[0] == '\0' && (*begin)->next)
            delete_row(begin);
        i++;
    }
    free((*begin)->line);
    free(*begin);
    display_winner(i);
}
示例#3
0
文件: display.c 项目: jwalle/filler
void	display(GLFWwindow *win, t_env *e)
{
	char	*line;
	float	eom;
	char	**got;

	while (!glfwWindowShouldClose(win) && !glfwGetKey(win, 256))
	{
		glfwPollEvents();
		if (get_next_line(0, &line) > 0)
		{
			glClear(GL_COLOR_BUFFER_BIT);
			if (ft_strstr(line, "<got"))
				got = ft_strsplit(line, ' ');
			else if (ft_strstr(line, "Plateau"))
			{
				e->map_size = get_size_bonus(line, e);
				if (e->map_size && !e->sz)
					e->sz = get_square_size(e->map_size);
				get_next_line(0, &line);
				e->map = get_map(e, line);
				eom = disp_grid(e->map_size, -0.95, 0.95, e->sz);
				if (e->piece_size[0] > 0)
					disp_piece(e, eom);
				put_map_square(e);
				if (got != NULL)
					get_play(eom, got, e);
				glfwSwapBuffers(win);
			}
		}
		else
		{
			put_winner(e, eom);
			glfwSwapBuffers(win);
			glfwWaitEvents(); //TODO BETTER HOLD
		}
	}
}
示例#4
0
文件: play.c 项目: sdzharkov/ECS30
//function to print the board and say how many mines are left 
void play_game(Board board) {
	get_play(board);
	printf("There are %d mines left\n", board.mine - marked_mines(board)); //print how many  mines are left
	print_board(board);
	return;
}