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

Tableau::Tableau ( Deck deck,
int  pileCount,
int  finalCount,
int  deals 
)

Constructor

--- class Tableau ------------------------------------------------------ Constructor

Definition at line 18 of file tableau.c.

References Deck::count(), Pack::deal(), and Pack::initialDeal().

                                                                     :
  dealCount(deals), deck(deck), piles(pileCount), finals(finalCount)
{
  cardsToOpen = deck.count() - (deals + 1) * pileCount;
  for ( ; cardsToOpen < 0; cardsToOpen += pileCount)
    --deals;

  pack = new Pack(deck);
  for (unsigned int p = 0; p < piles.size(); ++p)
    piles[p] = new Pile(deck);
  for (unsigned int f = 0; f < finals.size(); ++f)
    finals[f] = new FinalHeap(deck);

  history = new History();

  // choice of piles for extra deal with remaining cards
  Piles extra(cardsToOpen % pileCount);
  if (!extra.empty())
  {
    int extraMax = extra.size() - 1;
    int pilesMax = piles.size() - 1;
    for (int e = 0; e <= extraMax / 2; ++e)
    {
      int p = (e * pilesMax) / extraMax;
      extra[e] = piles[p];
      extra[extraMax - e] = piles[pilesMax - p];
    }
  }

  // deal cards to open
  pack->initialDeal(piles, cardsToOpen / pileCount, extra);

  // deal one open row
  pack->deal(piles);

  selected = 0;
}


Generated by  Doxygen 1.6.0   Back to index