public bool IsValidAction(ActionType action)
{
// can always hit
if (action == ActionType.Hit)
return true;
// can always stand
if (action == ActionType.Stand)
return true;
// surrender only available on the first two cards
// and when no other action has been yet made
if (action == ActionType.Surrender)
{
if (player_handset.HandCount == 1 && !player_handset.ActiveHand.Acted)
return true;
return false;
}
// double is available as a first action on hand
// and the hand isn't blackjack, or on splits
if (action == ActionType.Double)
{
if (!player_handset.ActiveHand.Acted)
return true;
return false;
}
// split is available as long as split cap hasn't been
// reached and there's no other action done and the hand is a pair
if (action == ActionType.Split)
{
if (split_count < rules.Splits &&
!player_handset.ActiveHand.Acted &&
player_handset.ActiveHand.IsPair())
return true;
return false;
}
// should never reach here
return false;
}