Exemple #1
0
Card *Fortyeight::newCards()
{
    if (Deck::deck()->isEmpty() && lastdeal)
        return 0;

    if (pile->top() && pile->top()->animated())
        return pile->top();

    if (Deck::deck()->isEmpty())
    {
        lastdeal = true;
        while (!pile->isEmpty())
        {
            Card *c = pile->at(pile->cardsLeft()-1);
            c->stopAnimation();
            Deck::deck()->add(c, true);
        }
    }

    Card *c = Deck::deck()->nextCard();
    pile->add(c, true);
    c->stopAnimation();
    qreal x = c->realX();
    qreal y = c->realY();
    c->setPos( Deck::deck()->pos() );
    c->flipTo(x, y, DURATION_FLIP );

    takeState();
    considerGameStarted();
    if ( Deck::deck()->isEmpty() && lastdeal )
        emit newCardsPossible( false );

    return c;
}
Exemple #2
0
bool Fortyeight::newCards()
{
    if ( talon->isEmpty() )
    {
        if ( lastdeal )
        {
            return false;
        }
        else
        {
            lastdeal = true;
            flipCardsToPile( pile->cards(), talon, DURATION_MOVE );
        }
    }
    else
    {
        flipCardToPile( talon->topCard(), pile, DURATION_MOVE );
        setKeyboardFocus( pile->topCard() );
    }

    if ( talon->isEmpty() && lastdeal )
        emit newCardsPossible( false );

    return true;
}
Exemple #3
0
void Gypsy::restart( const QList<KCard*> & cards )
{
    QList<KCard*> cardList = cards;

    for ( int round = 0; round < 8; ++round )
        addCardForDeal(store[round], cardList.takeLast(), false, store[round]->pos() + QPointF(-2*deck()->cardWidth(),-1.1*deck()->cardHeight()));

    for ( int round = 0; round < 8; ++round )
        addCardForDeal(store[round], cardList.takeLast(), true, store[round]->pos() + QPointF(-3*deck()->cardWidth(),-1.6*deck()->cardHeight()));

    for ( int round = 0; round < 8; ++round )
        addCardForDeal(store[round], cardList.takeLast(), true, store[round]->pos() + QPointF(-4*deck()->cardWidth(),-2.1*deck()->cardHeight()));

    while ( !cardList.isEmpty() )
    {
        KCard * c = cardList.takeFirst();
        c->setPos( talon->pos() );
        c->setFaceUp( false );
        talon->add( c );
    }

    startDealAnimation();

    emit newCardsPossible(true);
}
Exemple #4
0
void Fortyeight::restart( const QList<KCard*> & cards )
{
    lastdeal = false;

    QList<KCard*> cardList = cards;

    for ( int r = 0; r < 4; ++r )
    {
        for ( int column = 0; column < 8; ++column )
        {
            QPointF initPos = stack[column]->pos() - QPointF( 0, 2 * deck()->cardHeight() );
            addCardForDeal( stack[column], cardList.takeLast(), true, initPos );
        }
    }

    while ( !cardList.isEmpty() )
    {
        KCard * c = cardList.takeFirst();
        c->setPos( talon->pos() );
        c->setFaceUp( false );
        talon->add( c );
    }

    startDealAnimation();

    flipCardToPile( talon->topCard(), pile, DURATION_MOVE );

    emit newCardsPossible( true );
}
Exemple #5
0
void Fortyeight::restart()
{
    lastdeal = false;
    Deck::deck()->collectAndShuffle();
    deal();
    emit newCardsPossible( true );
}
Exemple #6
0
Card *Gypsy::newCards()
{
    if (Deck::deck()->isEmpty())
        return 0;

    unmarkAll();
    dealRow(true);
    takeState();
    considerGameStarted();
    if (Deck::deck()->isEmpty())
        emit newCardsPossible(false);

    return store[0]->top();
}
Exemple #7
0
bool Gypsy::newCards()
{
    if ( talon->isEmpty() )
        return false;

    for ( int round = 0; round < 8; ++round )
    {
        KCard * c = talon->topCard();
        flipCardToPileAtSpeed( c, store[round], DEAL_SPEED );
        c->setZValue( c->zValue() + 8 - round );
    }

    if (talon->isEmpty())
        emit newCardsPossible(false);

    return true;
}
Exemple #8
0
bool Spider::newCards()
{
    // The solver doesn't distinguish between dealing a new row of cards and
    // removing complete runs from the tableau. So it we're in demo mode and
    // newCards() is called, we should check to see if there are any complete
    // runs to move before dealing a new row.
    if ( isDemoActive() )
    {
        for ( int i = 0; i < 10; ++i )
        {
            if ( pileHasFullRun( stack[i] ) )
            {
                moveFullRunToLeg( stack[i] );
                return true;
            }
        }
    }

    if ( m_redeal > 4 )
        return false;

    redeals[m_redeal]->setVisible(false);
    recalculatePileLayouts();

    for ( int column = 0; column < 10; ++column )
    {
        KCard * c = redeals[m_redeal]->topCard();
        if ( !c )
            break;

        flipCardToPileAtSpeed( c, stack[column], DEAL_SPEED );
        c->setZValue( c->zValue() + 10 - column );
    }

    ++m_redeal;

    if (m_redeal > 4)
        emit newCardsPossible(false);

    return true;
}
Exemple #9
0
void Spider::restart( const QList<KCard*> & cards )
{
    m_pilesWithRuns.clear();

    // make the redeal piles visible
    for (int i = 0; i < 5; ++i )
        redeals[i]->setVisible( true );

    // make the leg piles invisible
    for (int i = 0; i < 8; ++i )
        legs[i]->setVisible( false );

    recalculatePileLayouts();

    m_leg = 0;
    m_redeal = 0;

    QList<KCard*> cardList = cards;

    int column = 0;
    // deal face down cards (5 to first 4 piles, 4 to last 6)
    for ( int i = 0; i < 44; ++i )
    {
        addCardForDeal( stack[column], cardList.takeLast(), m_stackFaceup == 1, randomPos() );
        column = (column + 1) % 10;
    }
    // deal face up cards, one to each pile
    for ( int i = 0; i < 10; ++i )
    {
        addCardForDeal( stack[column], cardList.takeLast(), true, randomPos() );
        column = (column + 1) % 10;
    }
    // deal the remaining cards into 5 'redeal' piles
    for ( int column = 0; column < 5; ++column )
        for ( int i = 0; i < 10; ++i )
            addCardForDeal( redeals[column], cardList.takeLast(), false, randomPos() );

    startDealAnimation();

    emit newCardsPossible(true);
}
Exemple #10
0
bool Grandf::newCards()
{
    if ( numberOfDeals >= 3 )
        return false;

    // NOTE: This is not quite correct. The piles should be turned face down
    //       (i.e. partially reversed) during collection.
    QList<KCard*> collectedCards;
    for ( int pos = 6; pos >= 0; --pos )
    {
        collectedCards << store[pos]->cards();
        store[pos]->clear();
    }
    deal( collectedCards );
    takeState();

    numberOfDeals++;

    if (numberOfDeals == 3)
        emit newCardsPossible(false);

    return true;
}
Exemple #11
0
void Spider::setGameState( const QString & state )
{
    int n = state.toInt();
    int numLegs = n / 10;
    int numRedeals = n % 10;

    if ( numRedeals != m_redeal || numLegs != m_leg )
    {
        m_redeal = numRedeals;
        for ( int i = 0; i < 5; ++i )
            redeals[i]->setVisible( i >= m_redeal );

        m_leg = numLegs;
        for ( int i = 0; i < 8; ++i )
            legs[i]->setVisible( i < m_leg );

        recalculatePileLayouts();
        foreach ( KCardPile * p, piles() )
            updatePileLayout( p, 0 );

        emit newCardsPossible(m_redeal <= 4);
    }
}
Exemple #12
0
void Fortyeight::setGameState( const QString & state )
{
    lastdeal = state.toInt();
    emit newCardsPossible( !lastdeal || !talon->isEmpty() );
}
Exemple #13
0
void Grandf::restart( const QList<KCard*> & cards )
{
    deal( cards );
    numberOfDeals = 1;
    emit newCardsPossible( true );
}
Exemple #14
0
void Gypsy::setGameState( const QString & state )
{
    Q_UNUSED( state )
    emit newCardsPossible(!talon->isEmpty());
}
Exemple #15
0
void Gypsy::setGameState(const QString &)
{
    emit newCardsPossible(!Deck::deck()->isEmpty());
}
Exemple #16
0
void Fortyeight::setGameState( const QString &s )
{
    lastdeal = s.toInt();
    emit newCardsPossible( !lastdeal || !Deck::deck()->isEmpty() );
}
Exemple #17
0
void Grandf::setGameState( const QString & state )
{
    numberOfDeals = state.toInt();
    emit newCardsPossible(numberOfDeals < 3);
}
Exemple #18
0
void Gypsy::restart() {
    Deck::deck()->collectAndShuffle();
    deal();
    emit newCardsPossible(true);
}