Exemplo n.º 1
0
void GamePairs::mainGameLoop()
{
    displayDelegate->showRound(round);
    displayDelegate->showBoard();

    Card& cardFirst  = displayDelegate->letUserChooseCard(cards());
    Card& cardSecond = displayDelegate->letUserChooseCard(cards());

    if (cardFirst.isSameCard(cardSecond))
        return cancelSelection(cardFirst, cardSecond);

    if (tryTakeCards(cardFirst, cardSecond))
    {
        displayDelegate->showCurrentPlayerSuccess();
    } else {
        displayDelegate->showCurrentPlayerFail();
        nextRound();
    }
}
Exemplo n.º 2
0
int main(void) {
	// your code goes here
	float n;
	scanf("%f",&n);
	while(n!=0.00)
	{
	    cards(n);
	    scanf("%f",&n);
	}
	return 0;
}
Exemplo n.º 3
0
void RandomNum::shuffleCards(const int cardNum)
{
    vector<int> cards(cardNum);
    for (int i=0; i< cards.size(); i++)
        cards[i] =i;

    srand(time(NULL));
    shuffleCards_2(cards);

    for (int i=0; i< cards.size(); i++)
        cout << cards[i] << " ";
    cout << endl;
}
Exemplo n.º 4
0
double Judge::chance(QQmlObjectListModel<Card> *hand) {
    QVector<int> cards(14,4);
    double sum = 0;

    for (int i = 0; i < hand->size(); ++i) {
        sum += trueValue(hand->at(i)->get_value());
        --cards[hand->at(i)->get_value()];
    }
    if(sum <= 10) return 1.0;
    double goodCard = 0;
    for (int i = 1; i <= (21 - sum); ++i)
        goodCard += cards[i];
    qDebug() << (goodCard)/(52.0 - hand->size());
    return (goodCard)/(52.0 - hand->size());
}
Exemplo n.º 5
0
//***************************************************************************
// Function : constructor                                   
// Process  : Initialize data members to input cards             
// Notes    : None
//
// Revision History:
//
// Date           Author               Description 
// 6.12.11        Donne Martin         Added function
//***************************************************************************
Hand::Hand(
   Card card0,
   Card card1,
   Card card2,
   Card card3,
   Card card4)
{
   vector<Card> cards(Hand::MAXCARDS); // Holds the hand of cards

   cards.push_back(card0);
   cards.push_back(card1);
   cards.push_back(card2);
   cards.push_back(card3);
   cards.push_back(card4);

   this->setCards(cards);
}
Exemplo n.º 6
0
void Manager::throwFailForceDiscard()
{
    const SingleRecord* r = mRes.getLastThrowFail();
    const CardContainer& c = r->cards;
    const CardUnit& u = c.cards().back();
    std::vector<Card> cards(1);
    cards[0] = u.cards.back();
    Seat* s = mPerformer;
    DiscardActionMsg m;
    m.set_seat(s->seat());
    m.set_reason(DiscardActionMsg::ThrowFailForce);
    m.set_order(mRes.resNumber());
    m.set_max(true);
    m.set_score(0);
    m << cards;
    mRes.put(s->seat(), c, true);
    mPerformer = mPerformer->next();
    notifyDiscardAction(m);
    mStatus = DiscardNotify;
}
Exemplo n.º 7
0
void SlickerCardManager::slotShutdown( void )
{
  	KConfig *config = kapp->config();

  	config->setGroup("General");

  	QStringList instances;
  	CardDesk::CardList roots = rootCards();

	//write list of cards (in the correct (important)) order

  	for (CardDesk::CardListIterator it(roots); it.current(); ++it)
  	{

  		CardDesk::Card *root = it.current();

  		for (int i = 0; i < root->deck()->count(); i++)
  		{
  			instances.append(root->deck()->cardAt(i)->cardId());
  		}
  	}
  	config->writeEntry("Cards", instances);

 	/*
 		Write out the cards settings
 	*/

 	CardDesk::CardList all = cards();
 	for (CardDesk::CardListIterator it(all); it.current(); ++it)
 	{
 		CardDesk::Card *card = it.current();
		KConfigGroup group(config,QString("Card_").append(card->cardId()));
 		card->saveConfig(group);
 	}
	config->sync();

	_cards.setAutoDelete(true);
	_cards.clear();
	_cards.setAutoDelete(false);

}
Exemplo n.º 8
0
std::set<CardSet> createCardSet(size_t numCards, Card::Grouping grouping) {
  std::set<CardSet> ret;
  combinations cards(52, numCards);
  do {
    CardSet hand;
    for (size_t i = 0; i < numCards; i++) {
      hand.insert(Card(cards[i]));
    }
    switch (grouping) {
      case Card::RANK_SUIT:
        ret.insert(hand);
        break;
      case Card::SUIT_CANONICAL:
        ret.insert(hand.canonize());
        break;
      case Card::RANK:
        ret.insert(hand.canonizeRanks());
        break;
    };

  } while (cards.next());
  return ret;
}
Exemplo n.º 9
0
int main(int argc, char *argv[]) {
  int n, numCards, prevIndex, length, index, numCardsDropped;
  std::string input, card, word;
  std::stringstream ss;

  while(std::getline(std::cin, input), input.compare("0") != 0) {
    ss << input;
    ss >> n;
    ss.clear();
    ss.str("");


    std::vector<std::string>  cards(n, "");
    numCards = n;
    index = 0;
    numCardsDropped = 0;
    while(n > 0) {
      std::getline(std::cin, input);
      ss << input;
      ss >> card >> word;
      ss.clear();
      ss.str("");

      length = (int)word.length();

      index = (index + length) % (numCards);
        if(index > 0) {
          if(cards[index - 1].compare("") == 0) {
            cards[index - 1] = card;
            //break;
          } else {
            //index = (index + 1) % numCards;
          }
        } else {
          if(cards[index].compare("") == 0) {
            cards[index] = card;
            //break;
          } else {
            //index = (index + 1) % numCards;
          }
        }

      std::cout << "card " << card <<" index  " << (index - 1) << " " <<  " numCards " <<  numCards << std::endl;
      n--;
    }

    for(std::vector<std::string>::iterator it = cards.begin(); it != cards.end(); it++) {
      if((*it).compare("") == 0) {
        std::cout << "-";
      } else {
        std::cout << *it;
      }

      if((it + 1) != cards.end()) {
        std::cout << " ";
      }
    }
    std::cout << std::endl;
  }
  return 0;
}