Пример #1
0
/** Thread that reads user input to choose a card and play it
 * 
 */
 void *playCard(void *ptr) {
  char ch;
  char chosen_card[4];
  int cardNumber;
  
  
  int i=0;
  while (1) {

    printf("Insert card: \n");
    
    while (read(STDIN_FILENO, &ch, 1) == 1) {
      if (ch != '\n') {
       chosen_card[i] = ch;
       i++;
     }
     else {
       chosen_card[i] = '\0';
       break;
     }
   }

   cardNumber = searchCard(chosen_card,i);
   if (cardNumber != -1) {
    break;
  }
  else {
    printf("\nWrong Card! Try again.\n");
    i=0;
  }
}

printf("card played: %s\n", hand[cardNumber]);

callPlayEvent(cardNumber);

addCardToTable(cardNumber);

removeCardFromHand(cardNumber);

updatePlayersTurn();

return NULL;
}
Пример #2
0
// Discard Card
void Player::discardCard(const Suit suit, const Rank rank){
    
    //remove the card from hand and add it into the list of discarded cards
    Card* card = removeCardFromHand(suit, rank);
    playerData->discardedCards_.push_back(card);
}
Пример #3
0
// Responds to the "play" command
// If the card is invalid play, throw runtime_error
// If the card is valid play, remove the card from hand and return the card
Card* Player::playCard(const Suit suit, const Rank rank){
    Card* card = removeCardFromHand(suit, rank);
    return card;
}