MoveHint GypsySolver::translateMove( const MOVE &m ) { //print_layout(); if ( m.from == deck ) return MoveHint(); PatPile *frompile = deal->store[m.from]; KCard *card = frompile->at( frompile->count() - m.card_index - 1); if ( m.totype == O_Type ) { PatPile *target = 0; PatPile *empty = 0; for (int i = 0; i < 8; ++i) { KCard *c = deal->target[i]->topCard(); if (c) { if ( c->suit() == card->suit() && c->rank() == card->rank() - 1) { target = deal->target[i]; break; } } else if ( !empty ) empty = deal->target[i]; } if ( !target ) target = empty; return MoveHint( card, target, m.pri ); } return MoveHint( card, deal->store[m.to], m.pri ); }
MoveHint GolfSolver::translateMove( const MOVE &m ) { if ( m.from >= 7 ) return MoveHint(); PatPile *frompile = deal->stack[m.from]; KCard *card = frompile->at( frompile->count() - m.card_index - 1); return MoveHint( card, deal->waste, m.pri ); }
MoveHint ClockSolver::translateMove( const MOVE &m ) { PatPile *frompile = deal->store[m.from]; KCard *card = frompile->topCard(); if ( m.totype == O_Type ) { return MoveHint( card, deal->target[m.to], m.pri ); } else { return MoveHint( card, deal->store[m.to], m.pri ); } }
MoveHint Mod3Solver::translateMove( const MOVE & m ) { if ( m.from == deck ) return MoveHint(); PatPile *frompile = deal->stack[m.from / 8][m.from % 8]; KCard *card = frompile->topCard(); if ( m.to == aces ) { return MoveHint( card, deal->aces, m.pri ); } else { return MoveHint( card, deal->stack[m.to / 8][m.to % 8], m.pri ); } }
void Spider::cardsMoved( const QList<KCard*> & cards, KCardPile * oldPile, KCardPile * newPile ) { PatPile * p = dynamic_cast<PatPile*>( newPile ); // The solver treats the removal of complete runs from the table as a // separate move, so we don't do it automatically when the demo is active. if ( !isDemoActive() && p && p->pileRole() == PatPile::Tableau && pileHasFullRun( p ) ) { m_pilesWithRuns << p; } DealerScene::cardsMoved( cards, oldPile, newPile ); }
MoveHint SimonSolver::translateMove( const MOVE &m ) { Q_ASSERT( m.from < 10 && m.to < 10 ); PatPile *frompile = deal->store[m.from]; KCard *card = frompile->at( frompile->count() - m.card_index - 1); if ( m.totype == O_Type ) { for ( int i = 0; i < 4; ++i ) if ( deal->target[i]->isEmpty() ) return MoveHint( card, deal->target[i], 127 ); } Q_ASSERT( m.to < 10 ); return MoveHint( card, deal->store[m.to], m.pri ); }
MoveHint IdiotSolver::translateMove( const MOVE &m ) { if ( m.from >=4 ) return MoveHint(); PatPile *frompile = deal->m_play[m.from]; KCard *card = frompile->at( frompile->count() - m.card_index - 1); Q_ASSERT( card ); PatPile *target = nullptr; if ( m.to == 5 ) target = deal->m_away; else target = deal->m_play[m.to]; return MoveHint( card, target, m.pri ); }
MoveHint KlondikeSolver::translateMove( const MOVE &m ) { PatPile *frompile = 0; if ( m.from == 8 && m.to == 7 ) return MoveHint(); Q_ASSERT( m.from != 8 ); if ( m.from == 7 ) frompile = deal->pile; else frompile = deal->play[m.from]; KCard *card = frompile->at( frompile->count() - m.card_index - 1); if ( m.totype == O_Type ) { PatPile *target = 0; PatPile *empty = 0; for (int i = 0; i < 4; ++i) { KCard *c = deal->target[i]->topCard(); if (c) { if ( c->suit() == card->suit() ) { target = deal->target[i]; break; } } else if ( !empty ) empty = deal->target[i]; } if ( !target ) target = empty; return MoveHint( card, target, m.pri ); } else { if ( m.to == 7 ) { return MoveHint( card, deal->pile, m.pri ); } else if ( m.to == 8 ) return MoveHint(); else return MoveHint( card, deal->play[m.to], m.pri ); } }
MoveHint FreecellSolver::translateMove( const MOVE &m ) { // this is tricky as we need to want to build the "meta moves" PatPile *frompile = 0; if ( m.from < 8 ) frompile = deal->store[m.from]; else frompile = deal->freecell[m.from-8]; KCard *card = frompile->at( frompile->count() - m.card_index - 1); if ( m.totype == O_Type ) { PatPile *target = 0; PatPile *empty = 0; for (int i = 0; i < 4; ++i) { KCard *c = deal->target[i]->topCard(); if (c) { if ( c->suit() == card->suit() ) { target = deal->target[i]; break; } } else if ( !empty ) empty = deal->target[i]; } if ( !target ) target = empty; return MoveHint( card, target, m.pri ); } else { PatPile *target = 0; if ( m.to < 8 ) target = deal->store[m.to]; else target = deal->freecell[m.to-8]; return MoveHint( card, target, m.pri ); } }
void Spider::moveFullRunToLeg( KCardPile * pile ) { QList<KCard*> run = pile->topCards( 13 ); PatPile * leg = legs[m_leg]; ++m_leg; leg->setVisible( true ); recalculatePileLayouts(); for ( int i = 0; i < 10; ++i ) if ( stack[i] != pile ) updatePileLayout( stack[i], DURATION_RELAYOUT ); for ( int i = 0; i < run.size(); ++i ) { KCard * c = run.at( i ); leg->add( c ); int duration = DURATION_AUTODROP * (0.7 + i / 10.0); c->animate( leg->pos(), leg->zValue() + i, 0, true, true, duration ); } updatePileLayout( pile, DURATION_RELAYOUT ); }