-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdealer.js
33 lines (31 loc) · 861 Bytes
/
dealer.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
33
var Dealer = function(){
var cards = new Cards()
var scoresDisplay = document.getElementById('dealer-score')
this.hasAce = false
this.hiddenValue = ""
this.totalCardVal = 0
this.addScore = function(hand){
this.totalCardVal += cards.countValue(hand)
}
this.getHiddenValue = function(i, facevalue){
if(i==1){
var secondCard = document.getElementsByClassName('dealerCards')[1]
secondCard.src = "images/cards2/back1.jpg"
this.hiddenValue = facevalue
}
}
this.checkForAce = function(card){
if(card.indexOf('A') > -1){
this.hasAce = true
}
}
this.getFinalValue = function(){
if(this.hasAce && this.totalCardVal > 21){
this.totalCardVal = this.totalCardVal - 10
}
this.hasAce = false
}
this.displayScores = function(){
scoresDisplay.innerHTML = "Dealer: " + this.totalCardVal
}
}