package
{
import flash.text.*;
/**
* ...
* @author (t)ad
*/
public class blackJackFunctions
{
/* These functions take/use no specific properties, so they can be static
This class and the cardShute are inter related. */
public static function giveCard():String
{
var theCard:String = "A";
theCard = cardShute.retrieveCard();
return(theCard);
}
public static function calculateTwoCardHand(cardOne:String, cardTwo:String):Number
{
var theHand:Number = 0;
if (cardOne == "K" || cardOne == "Q" || cardOne =="J") cardOne = "10";
if (cardTwo == "K" || cardTwo == "Q" || cardTwo == "J") cardTwo = "10";
if (cardOne == "A" && cardTwo != "A")
{
if (11 + int(cardTwo) > 21)
{theHand = 1+ int(cardTwo);}
else
{theHand = 11+ int(cardTwo);}
}
if (cardOne != "A" && cardTwo == "A")
{
if (11 + int(cardOne) > 21)
{theHand = 1 + int(cardOne);}
else
{theHand = 11 + int(cardOne);}
}
if (cardOne == "A" && cardTwo == "A")
{
theHand = 2;
}
if (cardOne != "A" && cardTwo != "A")
{
theHand = int(cardOne) + int(cardTwo);
}
return(theHand);
}
}
}