Exemple #1
0
int		launch_solve_by_length(t_case *root)
{
  t_link	*last;
  t_link	*root_pile;
  char		go_back;

  if (!(last = init_pile_root(root->next)))
    return (1);
  root_pile = last;
  go_back = 0;
  while (last)
    {
      last->cas->path = 1;
      if (last->cas->next == root)
	return (free_pile(root_pile), 0);
      if (add_to_pile(&go_back, &last))
	return (1);
      if (go_back)
	{
	  remove_from_pile(&last);
	  go_back = 0;
	}
    }
  return (2);
}
Exemple #2
0
static void play_from_face_up(struct game_t *game, struct player_t *player,
    const struct card_t *to_lay, const int num_cards)
{
    int i;

    for (i = 0; i < num_cards; i++) {
        add_to_pile(game->pile, &game->pile_size, to_lay[i]);
        remove_from_face_up(player, &to_lay[i]);
    }
}
Exemple #3
0
static void play_from_hand(struct game_t *game, const struct card_t *to_lay, 
    const int num_cards)
{
    int i;
    struct player_t *player = &game->players[game->current_player];

    for (i = 0; i < num_cards; i++) {
        add_to_pile(game->pile, &game->pile_size, to_lay[i]);
        remove_from_hand(player, &to_lay[i]);
        
        if (game->deck_size > 0 && (player->hand_size < game->num_cards_each)) {
            deal_to_hand(player, game->deck[game->deck_size-1]);
            game->deck_size--;
        }
    }

    sort_cards(player->hand, player->hand_size);
}