Skip to content

Commit

Permalink
fixed the bug that does not display dealer hand when game has ended
Browse files Browse the repository at this point in the history
  • Loading branch information
agionoja committed Jan 19, 2024
1 parent 42070cb commit 2246633
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion scripts/eventHandlers/hitHandler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export function hitBtn() {

// console.log(playerHand)
// console.log(playerScore)
displayDealerFullHand();
gameOutcome();
displayDealerFullHand();
updateStakeSuggestionButtonTexts(balance);
displayStakeSuggestionBtn(balance);
}, 1000);
Expand Down
3 changes: 1 addition & 2 deletions scripts/eventHandlers/newGameHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { gameBodyEl, newGameEl } from "../functions/gamePage.mjs";
import { stakeCtnEl } from "../functions/stake.mjs";
import { gameInit } from "../functions/gameInit.mjs";
import { balance, setBalance } from "../functions/balance.mjs";
import { mainGameInit } from "../functions/mainGameInit.mjs";
import {
Expand All @@ -12,9 +11,9 @@ import {

export function newGame() {
newGameEl.addEventListener("click", function () {
mainGameInit();
updateStakeSuggestionButtonTexts(balance);
stakeBtnEventLister();
mainGameInit();

gameBodyEl.classList.toggle("hidden");
stakeCtnEl.classList.remove("hidden");
Expand Down
2 changes: 1 addition & 1 deletion scripts/eventHandlers/standHanler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function standBtn() {


}
setIsEnded(true)
// setIsEnded(true)
gameOutcome(true)
displayDealerFullHand()

Expand Down
40 changes: 23 additions & 17 deletions scripts/main.mjs
Original file line number Diff line number Diff line change
@@ -1,44 +1,50 @@
"use strict";

// Importing functions and event handlers
import {gameInit} from "./functions/gameInit.mjs";
import {initiateGameStartSequence} from "./eventHandlers/startGameSequenceHandler.mjs";
import {clearStakeButtonClick, playBtn, removePopup, showPopup} from "./eventHandlers/stakeHandler.mjs";
import {hitBtn} from "./eventHandlers/hitHandler.mjs";
import {restartGame} from "./eventHandlers/restartHandler.mjs";
import {populateDeckWithImages} from "./functions/uiFunctions.mjs";
import {newGame} from "./eventHandlers/newGameHandler.js";
import {standBtn} from "./eventHandlers/standHanler.mjs";
import {balance} from "./functions/balance.mjs";
import {betMinMax} from "./functions/gameFunctions.mjs";


// Constants for stake percentages
export const percent = [0.05, 0.1, 0.3, 0.4, 0.5];

// initialize the game
gameInit()
// Initialize the game
gameInit();

// Start the game sequence
initiateGameStartSequence();

// Restart the game
restartGame();

restartGame()

// Play event listener
playBtn()
// Play button event listener
playBtn();

newGame()
// New game event listener
newGame();

clearStakeButtonClick()
// Clear stake button click event
clearStakeButtonClick();

removePopup()
// Remove popup event
removePopup();

// Show popup if balance is insufficient
if (balance < betMinMax(balance).minBet) {
showPopup("You are out of credits.")

removePopup()
showPopup("You are out of credits.");
removePopup();
}

// hit btn event listener
hitBtn()
// Hit button event listener
hitBtn();

standBtn()
// Stand button event listener
standBtn();

doubleBtn()

0 comments on commit 2246633

Please sign in to comment.