forked from praveenkbarli/blackjack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hand.js
32 lines (27 loc) · 809 Bytes
/
Hand.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var Hand = function(name) {
//member variables
this.cards = [];
this.name = name;
//constructor methods
this.score = function(){
//console.log("Deck constructor called");
var score = 0;
var noOfAces = 0;
console.log("total cards with hand" + this.cards.length);
if(this.cards.length > 0){
for (var i =0; i < this.cards.length; i++) {
// if(card.faceValue == faceValue.ace)
/*if(card.faceValue == faceValue.ace){
noOfAces = noOfAces + 1;
}*/
console.log("facevalue: " + this.cards[i].suitType + this.cards[i].faceValue);
score += faceValue[this.cards[i].faceValue];
}
}
console.log("current score of " + this.name + " is " + score);
return score;
}
this.addCard = function(newCard){
this.cards.push(newCard);
}
}