Simple Jack is similar to blackjack.
In this game there are a minimum of 2 and a maximum of 6 players, with one human player and the rest being computer-controlled players (including a dealer).
The deck of cards is going to be digital and consists of 52 unique cards.
There are 4 Suits of cards: Spades, Hearts, Clubs, Diamonds.
Each suit consists of the following:
- 3 Face Cards: Jack, Queen, and King.
- 1 Ace.
- 9 Regular cards, which are numbered 2 through 10.
The value of each Face Card is 10. The value of the Ace is either 1 or 11. The values of the Regular cards are the same as their number.
Each card is represented by a string containing first the Suit followed by a dash '-' and the name or value of the card.
For example "Spades-King" would represent the King of Spades with a value of 10, "Hearts-9" would represent the 9 of Hearts with a value of 9, and "Diamonds-Ace" would represent the Ace of Diamonds with a value of either 1 or 11 (depending on the context of the hand).
The object of the game is to get the highest valued hand without exceeding 21.
Cards are dealt sequentially to each player one at a time.
As soon as a hand with a value of 21 is dealt, the player holding that hand is immediately declared the winner and the game ends.
This would occur if the player has any card valued at 10 and an Ace. For example if the player's hand is ["Clubs-King", "Spades-Ace"] the total would be 21 with the Ace assigned the value of 11.
The value of the Ace is determined by the context of the hand the player holds and is evaluated to give the player the best chance to win. For example, if the player has the hand ["Spades-10", "Hearts-Queen", "Hearts-Ace"], "Hearts-Ace" would be evaluated as 1, giving the player a winning hand of 21.
The first player dealt a hand of 21 is declared the winner, there is no further dealing, and the game is finished.
If there is no winner, additional cards are dealt using the following rules:
For the human player: After receiving their initial cards, they can choose to "Hit me" (receive another card) or "Stand" (keep their current hand). The human player can continue to hit until they choose to stand, reach 21, or exceed 21 (bust).
For computer-controlled players: If the value of the player's hand is 16 or less they must be dealt the next card in the deck. If the value of the player's hand is 17 or greater they must not be dealt another card.
If the value of a player's hand exceeds 21 they are eliminated from the game.
Continue dealing cards until a player is dealt a winning hand of 21, all players are eliminated, or players can no longer draw cards.
If players can no longer draw cards, the player holding the highest hand which does not exceed 21 is the winner.
If the deck has been exhausted, the player holding the highest hand which does not exceed 21 is the winner.
If there is a tie in the value of the hands there is no winner.
Install the dependencies:
npm install
Run the development server:
npm run devThen navigate to http://localhost:3000/ to use the application.
To run tests:
npm run test
To run tests with watcher:
npm run test:watch
The application has been dockerized. It may optionally be built and tested in a docker container as follows:
./build_docker.sh simple_jack
docker run -t simple_jack ./run_tests.sh
This is a Next.js project bootstrapped with create-next-app.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.