#ifndef PLAYERGAME_H
#define PLAYERGAME_H

#include <hand.h>
#include <deck.h>
#include <dealer.h>

class playerGame
{
public:

  // The deck of cards. 
  deck * cards;
  // The dealer.
  dealer * deal;
  // The players hand, the player is this whole class.
  hand player;

  // Tracking the dealers wins.
  uint dealerWins;
  // Tracking the players wins.
  uint playerWins;
  // The size of the bet can change during play.  Whoever wins has
  //   the bet added to their total wins.
  uint bet;

  // There are two states : alive and not alive.
  // The game is a state machine so only call the functions alive_... when
  //   alive is true.  Similarly call notalive_... when alive is false.
  bool alive;

  // One card is delt to the player and dealer.
  void notalive_dealCards();
  

  // The player sits on their current hand and then dealer plays.
  void alive_hold();
  // The player draws another card to either go bust or better their position.
  void alive_play();
  // The bet is doubled by the player and a normal play occures.
  void alive_doubleAndPlay();

  //void printGameState();
  //void menu();

  // Constructor - starts game in notalive state.
  playerGame();

  // Destructor 
  ~playerGame();

};


class playerGameSimulate : public playerGame
{
public:

  uint nsamples;

  playerGameSimulate( uintc _nsamples=8000 );

  // The player stands and the dealer plays.
  void calculate
  (
    double & win, double & loss,
    uintc dealer0,  // 1..10 where 1 is an ace.
    uintc player0
  );
  // Use the calculate(...) routine to have the dealer fixed 
  //   and vary the players position 12..20 .
  void tableCalculateRowPrint(uintc dealer0);
  // Apply tableCalculateRowPrint(...) for dealer 1..10
  void tableCalculatePrint();


  // The calculateHit routine is like a derivative.  It it one
  //   timestep away from the future.

  // From this position the player hits and stands.
  //   eg player on 17 and dealer has 10, what are the chances
  //   of winning and loosing if the player hits. 
  void calculateHit
  (
    double & win,
    double & loss,
    uintc dealer0,  // 1..10 where 1 is an ace.
    uintc player0
  );
  // Vary the player positions 7..18.
  void tableCalculateHitRowPrint(uintc dealer0);
  // Apply tableCalculateHitRowPrint(...) for dealer 1..10
  void tableCalculateHitPrint();

};


#endif



