#include <hand.h>


bool const hand::isbusted() const
{
  if (calculate()>21)
    return true;

  return false;
}


void hand::reset()
{
  hasAce=false;
  value=0;
}

void hand::reset(uintc card)
{
  hasAce=false;
  value=0;

  add(card);
}



void hand::add(uintc card)
{
  if (card!=1)
  {
    value += card;
    return;
  }

  if (hasAce)
  {
    value += card;
    return;
  }

  hasAce = true;
}


uintc hand::calculate() const
{
  if (hasAce==false)
    return value;

  if (value+11<=21)
    return value+11;

  return value + 1;
}









