
#include <iostream>
using namespace std;

#include <textGame.h>


void textGame::printGameState()
{
  hand & dh(pg.deal->hnd);
  hand & ph(pg.player);
  cout << "D: " << dh.calculate() << "  ";
  if (dh.hasAce)
    cout << "hasAce";
  cout << endl;
  cout << "P: " << ph.calculate() << "  ";
  if (ph.hasAce)
    cout << "hasAce";
  cout << endl;
}


textGame::textGame()
{
  char ch;
  for (;;)
  {
    printMenu();

    cin >> ch;
    if (ch=='q')
      return;

    if (pg.alive)
    {
      switch (ch)
      {
        case '1': pg.alive_hold(); break;
        case '2': pg.alive_play(); break;
        case '3': pg.alive_doubleAndPlay(); break;
      }
    }
    else
    {
      switch (ch)
      {
        case '1':  pg.notalive_dealCards(); break;
        case '2':  
          cout << "dealerWins=" << pg.dealerWins << "  ";
          cout << "playerWins=" << pg.playerWins << endl;
          continue;
        case '3': return;
      }
    }

    printGameState();
  }

}

void textGame::printMenu()
{
  if (pg.alive)
    print_alive();
  else
    print_notalive();
}

void textGame::print_alive()
{
  cout << "1.  Hold" << endl;
  cout << "2.  Play" << endl;
  cout << "3.  Double and Play" << endl;
}


void textGame::print_notalive()
{
  cout << "1.  Deal the Cards" << endl;
  cout << "2.  Print Score" << endl;
  cout << "3.  Quit" << endl;
}





