Skip to content

nickgraffis/blackjack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BlackJack

Aβ™₯️ πŸƒ Black Jack!

Demo

demo

~> npm install -g @nickgraffis/blackjack
~> blackjack

Game Play

  • Try to get the highest card total without going over 21.
  • 2 - 9 is face value
  • ['πŸƒ', 'πŸ‘Έ', '🀴'] are all 10
  • 'A' is 11 or 1 if you bust
  • 'A' + ['πŸƒ', 'πŸ‘Έ', '🀴'] is Black Jack! Automatic winner
  • Dealer will not hit past 17
  • Tie goes to the house :(

How it works?

Pretty simple and straight forward, except the recursive design of the computers hand.

var computerAsyncHand = function() {![image](https://user-images.githubusercontent.com/27028689/142096251-23671a4a-0672-4996-a5ad-564153c46782.gif)

  if (computerTurn < 2) {
    computerHand.push(randomPoints());
    computerTurn++;
    computerHand.push(randomPoints());
    computerTurn++;
    console.log(dealCard(computerHand[0], randomInt(4)));
    console.log(dealCard(computerHand[1], randomInt(4)));
    console.log(computerHand.reduce((a, b) => a + b, 0));
    sleep(1000);
  }
  if (computerHand.includes(11)) {
    var Ace = computerHand.indexOf(11);
    computerHand[Ace] = 1;
    console.log('Dealer score is now ' + computerHand.reduce((a, b) => a + b, 0) + ', using the A as a 1!');
  }
  if (computerHand.reduce((a, b) => a + b, 0) > 17) {
    //Game Over
    return;
  } else {
    computerHand.push(randomPoints());
    computerTurn++;
    console.log(dealCard(computerHand[computerTurn - 1], randomInt(4)));
    console.log(computerHand.reduce((a, b) => a + b, 0));
  }
  sleep(1000);
  computerAsyncHand();
}

About

πŸƒ Black Jack!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published