MCPcopy Create free account
hub / github.com/codemistic/Web-Development / updateAndShowResult

Function updateAndShowResult

blackjackgame/blackjack.js:100–117  ·  view source on GitHub ↗
(card, activePlayer)

Source from the content-addressed store, hash-verified

98}
99
100function updateAndShowResult(card, activePlayer){
101 if(card === 'A'){
102 //if card is A then we have two options to choose as, either 1 or 11, so take 11 if you get sum total <=21
103 if(activePlayer.result + blackjackGame['cardsMap'][card][1] <= 21){
104 activePlayer.result += blackjackGame['cardsMap'][card][1];
105 }else{
106 activePlayer.result += blackjackGame['cardsMap'][card][1];
107 }
108 }else{
109 activePlayer.result = activePlayer.result + blackjackGame['cardsMap'][card];
110 }
111 if(activePlayer['result'] > 21){
112 document.querySelector(activePlayer['resultSpan']).textContent = "BUST!";
113 document.querySelector(activePlayer['resultSpan']).style.color = 'red';
114 }else{
115 document.querySelector(activePlayer['resultSpan']).textContent = activePlayer.result;
116 }
117}
118
119
120function findWinner(){

Callers 2

blackjackHitFunction · 0.85
blackjackStandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected