HTML and CSS Reference
In-Depth Information
Code
Explanation
for (n=0;n<13;n++) {
Iterates over the cards in a suit
picname=suitnames[si]+"-"+nums[n]+
"-75.png";
Constructs the name of the file
deck[i]=new MCard(n+1,suitnames[si],
picname);
Construct an MCard with the
indicated values
i++;
Increments i
}
Closes the inner for loop
}
Closes the outer for loop
}
Closes the function
function MCard(n, s, picname){
Header for the constructor function
for making objects
this.num = n;
Sets the num value
if (n>10) n = 10;
Makes an adjustment in the cases of
the face cards
this.value = n;
Set the value
this.suit = s;
Set the suit
this.picture = new Image();
Creates a new Image object and
assigns it as an attribute
this.picture.src = picname;
Set the src attribute of this Image
object to the picture file name
this.dealt = 0;
Initializes the dealt attribute to 0
}
Closes the function
function add_up_player() {
Header for the function determining
the value of player's hand
var ac = 0;
Holds the count of aces
Search WWH ::




Custom Search