Simple Blackjack is a variant of blackjack. It is a game played by a single player against a dealer. The objective of the game is to draw cards whose total is as close as possible to 21, without exceeding it (AKA "busting").
The value of a hand of Simple Blackjack is the sum of the card values where
- The value of an Ace is 11
- Jacks, Queens, and Kings are worth 10
- All other cards (2-10) have their face value
A hand of Simple Blackjack is played as follows
- A standard 52-card deck is shuffled before each hand
- The player is initially dealt two cards
- The player must then decide whether to receive a further card ("hit") or stick with his current hand ("stand")
- The player can repeatedly hit until they either exceed 21 ("bust") or decide to stand
If the player busts before deciding to stand, they lose the hand, otherwise the dealer's cards are dealt according to the following rules
- If the total of the dealer's cards is below 17, they must hit
- If the total of the dealer's cards is 17 or above, they must stand
If either the player or the dealer bust during the course of the hand, they lose. Otherwise, the person whose hand value is closest to 21 is the winner. If both hands have the same value, the result is a draw.
Implement a game of Simple Blackjack. Each game proceeds as follows
- The deck is shuffled
- The cards are dealt according to the rules above
- At the end of the hand, the outcome is displayed, i.e. player wins/dealer wins/draw
- The game ends and the player is asked whether they wish to play again
The game should be implemented as a browser-based application, ideally using Vue.js. The user interface should be functional, but does not need to doesn't need to be visually impressive, e.g. it's perfectly acceptable to use "10 D" to represent the ten of diamonds.
You are free to use any libraries, frameworks, generators, components, etc.
In addition to the game itself, your solution should include a suite of tests. You may use any testing framework or none at all. A production standard of test coverage is not expected, but at a minimum you should test the most common scenarios, e.g.
- player busts
- dealer busts
- player wins
- dealer wins
- draw
You must include clear instructions for how to run the tests and how to build/run the application e.g.
execute
npm install
followed bynpm run serve
in the project root then open http://localhost:8888 in a web browser
You should clearly document any dependencies required to build/run the project, e.g.
Node 12 or later is installed and npm is on the PATH
- Push your solution to a private GitHub repo in your account
- When your solution is complete, add your ClarusONE contact as a collaborator to this repo, so we can access it
While we would ideally like to receive a complete solution, we're more interested in the quality of the solution than completeness. In other words, a high quality solution which omits a few edge cases and has good test coverage will receive more credit than a complete, but low-quality solution.