Skip to content

Instantly share code, notes, and snippets.

@emkay
Created October 10, 2010 04:11
Show Gist options
  • Save emkay/618940 to your computer and use it in GitHub Desktop.
Save emkay/618940 to your computer and use it in GitHub Desktop.
var Card = function (rank, suit) {
this.rank = rank;
this.suit = suit;
this.getRank = function () { return this.rank; };
this.softValue = function () {
var result = '';
switch (this.rank) {
case 1: // Ace
result = 11;
break;
case 11: case 12: case 13: // Face card
result = 10;
break;
default:
result = this.rank; // 2-10
}
return result;
};
this.hardValue = function () {
var result = '';
switch (this.rank) {
case 1: // Ace
result = 1;
break;
case 11: case 12: case 13: // Face card
result = 10;
break;
default:
result = this.rank; // 2-10
}
return result;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment