Exemplo n.º 1
0
bool TableauToFoundation::PerformMovement(BoardLayout* layout)
{
  assert(layout);
  bool movement_performed;
  PileSet* pile_set = layout->GetPileSet();
  assert(pile_set);
  Card* card = NULL;
  Tableau* tableau = (*(pile_set->GetTableaus()))[m_origin_tableau];

  if(!tableau || (tableau->Size() == 0)) {
    movement_performed = false;
  }
  else {
    card = tableau->BottomCard();
    Foundation* foundation = pile_set->GetFoundation(card->GetSuit());
    if(!card || !foundation || !foundation->Push(card)) {
      // QUIT
      if(!card) {
        std::cout << "NO CARD IN TABLEAU:" << card->ToShortString();
      }
      else {
        std::cout << "CARD:" << card->ToShortString();
      }
      //

      movement_performed = false;
    }
    else {
      tableau->Pop();
      movement_performed = true;
    }

  }
  m_complete = false;
  return movement_performed;
}
Exemplo n.º 2
0
void InterfaceDrawVisitor::DrawTableausInLine(std::vector<Tableau*>* tableaus,
                                              const uint8_t& line) const
{
  assert(tableaus);
  for (auto tableau_it : *tableaus) {
    Card* card = tableau_it->CardAt(line);
    if(card) {
      std::cout.width(6);
      std::cout << std::right << card->ToShortString();
    }
    else {
      std::cout.width(6);
      std::cout << std::right << "";
    }
  }
}