try change
Code:
//if the card is already used, get a new card
if (validcard == false)
{
  thecard();
}
into
Code:
if (validcard == false)  //or just simply:  if (!validcard)
{
  return thecard();
}
PS, In future, please use codeTags ( [code ] your code here [/ code], but then without the spaces)