Logo Search packages:      
Sourcecode: vdr-plugin-spider version File versions

int Tableau::autoMove ( int  p  ) 

Search best move from p-th pile, return destination

Definition at line 210 of file tableau.c.

References allCardsMatches(), Deck::cardsInSuit, move(), select(), Pile::selected(), and Pile::selectionMatchesTo().

{
  int i = -1;
  if (!piles[p]->empty())
  {
    if (selected != piles[p])
      select(p);
    if (allCardsMatches() && selected->selected() == deck.cardsInSuit)
      remove();
    else
    {
      i = p;
      while ((i = (i + 1) % piles.size()) != p)
        if (selected->selectionMatchesTo(piles[i], true))
          break;
      if (i == p)
        while ((i = (i + 1) % piles.size()) != p)
          if (selected->selectionMatchesTo(piles[i], false))
            break;
      if (i == p)
        while ((i = (i + 1) % piles.size()) != p)
          if (piles[i]->empty())
            break;
      if (i != p)
        move(i);
      else
        i = -1;
    }
  }
  return i;
}


Generated by  Doxygen 1.6.0   Back to index