Implementation of traditional card game Twenty-One (Vingt-Un). Game logic is based on the following rules:
- Number of players is 2 (dealer and player/punter).
- Dealer should shuffle the deck of cards at the beginning of the game
- Both players receive 2 cards at the start of the game (in specific order: punter-dealer-punter-dealer)
- Game ends with original cards if:
- punter or dealer has 21 (BlackJack)
- if both of them have 21, the winner is punter
- if both of them have 22, the winner is dealer
- If game continues, punter receives additional cards until the score is equal or greater than 17:
- if punter's score is greater than 21, dealer wins the game
- If game continues, dealer receives additional cards until the score is greater than punter's score:
- if dealer's score is greater than 21, punter wins the game
- The winner is the one with higher score (practically it could be only dealer, otherwise dealer should lose the game in the previous step)
Deck of cards can be loaded from a file or initiated dynamically. A new deck is shuffled before a game. A deck loaded from a file is used in a game without shuffling.
You can build the game app by running:
mvn clean intallTo run the game just execute:
cd target && java -jar vingtun-1.0-SNAPSHOT-jar-with-dependencies.jarNotice: it's necessary to run "fat" jar because the application has external dependencies, and it's more convenient than to add all external libs to class path as cli arguments.
You can run the game app with following flags:
NB! If you run the game app without -f flag, new deck of cards would be generated dynamically.
You can find test coverage report, when the game app is built, in target/site/jacoco/index.html
You can find documentation after you run:
mvn javadoc:javadocin target/site/apidocs/index.html