Esempio n. 1
0
Card *GameBoard::takeFromCenterCards(unsigned int index)
{
    Card * card = NULL;
    assert(index < centercards.size());
    card = centercards[index];
    centercards[index] = drawFromDeck();

    return card;
}
Esempio n. 2
0
void GameBoard::initBoard()
{
    for (list<Card *>::iterator i = deck.begin(); i != deck.end(); i++) {
        grave.push_front(*i);
    }
    deck.clear();

    for (vector<Card *>::iterator i = centercards.begin(); i != centercards.end(); i++) {
        grave.push_front(*i);
    }
    centercards.clear();

    washGraveIntoDeck();

    Card *card = NULL;
    for (int i=0; i<5; i++) {
        card = drawFromDeck();
        centercards.push_back(card);
    }
}
Esempio n. 3
0
void DeckHandler::drawFromDeck(QString code)
{
    for (QList<DeckCard>::iterator it = deckCardList.begin(); it != deckCardList.end(); it++)
    {
        if(it->getCode() == code)
        {
            if(it->remaining>1)
            {
                it->remaining--;
                it->draw(false, this->cardHeight);
            }
            else if(it->remaining == 1)
            {
                it->remaining--;
                it->drawGreyed(true, this->greyedHeight);
            }
            //it->remaining == 0
            //MALORNE
            else if(code == MALORNE)  return;
            //Reajustamos el mazo si tiene unknown cards
            else if(deckCardList[0].total>0)
            {
                deckCardList[0].total--;
                if(deckCardList[0].total == 0)  deckCardList[0].listItem->setHidden(true);
                else                            deckCardList[0].draw(true, this->cardHeight);
                it->total++;

                it->drawGreyed(true, this->greyedHeight);

                emit pDebug("New card: " + it->getName());
                emit pLog(tr("Deck: New card: ") + it->getName());
            }
            else
            {
                emit pDebug("New card but deck is full. " + it->getName(), Warning);
                emit pLog(tr("Deck: WARNING: New card but deck is full. Is the deck right? ") + it->getName());
            }
            return;
        }
    }

    //MALORNE
    if(code == MALORNE)  return;


    if(deckCardList[0].total>0)
    {
        emit pDebug("New card: " +
                          (*cardsJson)[code].value("name").toString());
        emit pLog(tr("Deck: New card: ") +
                          (*cardsJson)[code].value("name").toString());
        newDeckCard(code);
        drawFromDeck(code);
    }
    else
    {
        emit pDebug("New card but deck is full. " +
                      (*cardsJson)[code].value("name").toString(), Warning);
        emit pLog(tr("Deck: WARNING: New card but deck is full. Is the deck right? ") +
                      (*cardsJson)[code].value("name").toString());
    }
}
Esempio n. 4
0
void DeckHandler::showPlayerCardDraw(QString code)
{
    if(this->drawDisappear>=0)    newDrawCard(code);
    drawFromDeck(code);
}