Skip to content

Commit

Permalink
Update soft hand rule and fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
prajwalkulkarni committed Feb 3, 2024
1 parent 80ece5e commit 213bd9b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
8 changes: 5 additions & 3 deletions bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Game extends Card {
_classPrivateMethodGet(this, _gameOver, _gameOver2).call(this);
return;
}
if (!this.isPlayingDoubleDown) {
if (!this.isPlayingDoubleDown || this.isPlayingDoubleDown && !this.isPlayerTurn) {
_classPrivateMethodGet(this, _continueGame, _continueGame2).call(this);
}
}
Expand Down Expand Up @@ -191,7 +191,9 @@ class Game extends Card {
this.cash -= this.stake;
this.stake *= 2;
this.hit();
this.stand();
if (this.playerCardSummation <= 21) {
this.stand();
}
break;
}
case 4:
Expand Down Expand Up @@ -280,7 +282,7 @@ function _continueGame2() {
}
_classPrivateMethodGet(this, _gameOver, _gameOver2).call(this);
} else {
if (this.dealerCardSummation < 17 && this.dealerCardSummation <= this.playerCardSummation) {
if (this.dealerCardSummation < 17) {
this.hit();
} else if (this.dealerCardSummation === this.playerCardSummation && this.dealerCardSummation >= 17 && this.dealerCardSummation <= 21) {
console.log("Push");
Expand Down
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class Game extends Card {

return;
}
if (!this.isPlayingDoubleDown) {
if (!this.isPlayingDoubleDown || (this.isPlayingDoubleDown && !this.isPlayerTurn)) {
this.#continueGame();
}
}
Expand Down Expand Up @@ -263,8 +263,7 @@ class Game extends Card {
this.#gameOver();
} else {
if (
this.dealerCardSummation < 17 &&
this.dealerCardSummation <= this.playerCardSummation
this.dealerCardSummation < 17
) {
this.hit();
} else if (
Expand Down Expand Up @@ -334,7 +333,9 @@ class Game extends Card {
this.cash -= this.stake;
this.stake *= 2;
this.hit();
this.stand();
if(this.playerCardSummation <= 21){
this.stand();
}
break;
}
case 4:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "blackjack21",
"version": "1.0.6",
"version": "1.0.7",
"description": "Blackjack on command line",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "vite build"
"build": "npx babel index.js --out-file bin.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 213bd9b

Please sign in to comment.