Esempio n. 1
0
/* gets called for target widget */
static void
card_drag_drop (HandDisplay *handdisp, int card, int on_card, int *to_seat)
{
	PROTECT_BEGIN;
	board *b = CUR_BOARD;
	printf("Dropped: %s on seat %c.\n", card_string(card), "WNES"[*to_seat - 1]);
	if (on_card >= 0)
		printf("Dropped on: %s.\n", card_string(on_card));

	if (b->dealt_cards[card] && b->dealt_cards[card] == *to_seat) /* card didn't move */
		PROTECT_RETURN;

	if (b->dealt_cards[card] && !b->cards[card]) {
		board_statusbar(_("Card is in play and cannot be moved"));
		PROTECT_RETURN;
	}

	seat from_seat = b->dealt_cards[card];
	if (on_card >= 0) { /* exchange 2 cards */
		if (b->dealt_cards[on_card] && !b->cards[on_card]) {
			board_statusbar(_("Card is in play and cannot be exchanged"));
			PROTECT_RETURN;
		}

		remove_card(b, *to_seat, on_card);
		if (from_seat) {
			remove_card(b, from_seat, card);
			add_card(b, from_seat, on_card);
		}
		add_card(b, *to_seat, card);
	} else { /* move single card */
		if (b->hand_cards[*to_seat-1] == 13) {
			board_statusbar(_("Hand has already 13 cards"));
			PROTECT_RETURN;
		}

		if (from_seat)
			remove_card(b, from_seat, card);
		add_card(b, *to_seat, card);
	}
	b->par_score = -1;
	invalidate_dd_scores (b);

	board_statusbar(NULL);
	card_window_update(b->dealt_cards);
	show_board(b, REDRAW_HANDS | REDRAW_PAR);
	PROTECT_END;
}
static void process_device(struct userdata *u, struct udev_device *dev) {
    const char *action, *ff;

    pa_assert(u);
    pa_assert(dev);

    if (udev_device_get_property_value(dev, "PULSE_IGNORE")) {
        pa_log_debug("Ignoring %s, because marked so.", udev_device_get_devpath(dev));
        return;
    }

    if ((ff = udev_device_get_property_value(dev, "SOUND_CLASS")) &&
        pa_streq(ff, "modem")) {
        pa_log_debug("Ignoring %s, because it is a modem.", udev_device_get_devpath(dev));
        return;
    }

    action = udev_device_get_action(dev);

    if (action && pa_streq(action, "remove"))
        remove_card(u, dev);
    else if ((!action || pa_streq(action, "change")) && udev_device_get_property_value(dev, "SOUND_INITIALIZED"))
        card_changed(u, dev);

    /* For an explanation why we don't look for 'add' events here
     * have a look into /lib/udev/rules.d/78-sound-card.rules! */
}
Esempio n. 3
0
File: uno.c Progetto: tmacwill/uno
/**
 * Play the given card
 *
 * @param card Card to play
 * @return False if card cannot be played, true otherwise
 *
 */
int play(struct card_t* card) {
    // if either value or color matches, then move is valid
    if (card->value == up_card.value || card->color == up_card.color) {
        // change the up card
        up_card.type = card->type;
        up_card.color = card->color;
        up_card.value = card->value;

        // clear game so we can remove the card that was played
        clear_container(container);
        remove_card(card);

        // draw the new game state
        draw_hand();

        return 1;
    }

    // illegal move
    return 0;
}
void CardCollection_500::remove_card(Card::number_t number, Card::suit_t suit)
{
   Card_500 card = Card_500(number, suit);
   remove_card(&card);
}
Esempio n. 5
0
string solve(string command,user*& cur_user)
{
  vector <string> commands;
  string x;

  string sol;
  commands=parse(command);
  x=commands[0];
  if(x=="exit" || x=="disconnect")
    return x;
  if(x=="signup")
    sol=signup(cur_user,commands);
  if(x=="signin")
    sol=signin(cur_user,commands);
  if(x=="signout" && commands.size()==1)
    {
      cur_user=NULL;
      return "signing out completed.\n";
    }
  if(x=="show_boards")
    sol=show_boards(cur_user);
  if(x=="enter_board")
    sol=enter_board(cur_user,commands);
  if(x=="add_user")
    sol=add_user(cur_user,commands);
  if(x=="remove_user_from_board")
    sol=remove_user_from_board(cur_user,commands);
  if(x=="show_lists" && commands.size()==1)
    sol=show_lists(cur_user);
  if(x=="show_cards")
    sol=show_cards(cur_user,commands);
  if(x=="show_card")
    sol=show_card(cur_user,commands);
  if(x=="create_board")
    sol=create_board(cur_user,commands);
  if(x=="remove_board")
    sol=remove_board(cur_user,commands);
  if(x=="add_list")
    sol=add_list(cur_user,commands);
  if(x=="remove_list")
    sol=remove_list(cur_user,commands);
  if(x=="add_card")
    sol=add_card(cur_user,commands);
  if(x=="remove_card")
    sol=remove_card(cur_user,commands);
  if(x=="move_card")
    sol=move_card(cur_user,commands);
  if(x=="rename_card")
    sol=rename_card(cur_user,commands);
  if(x=="edit_card_description")
    sol=edit_card_des(cur_user,commands);
  if(x=="edit_card_due_date")
    sol=edit_card_date(cur_user,commands);
  if(x=="assign_user")
    sol=assign(cur_user,commands);
  if(x=="remove_user")
    sol=remove_user_from_card(cur_user,commands);
  if(x=="comment")
    sol=commenting(cur_user,commands);
  if(x=="filter")
    sol=filter(cur_user,commands);
  if(sol.size()==0)
    sol="Invalid command.\n";
  return sol;
     
}