Newer
Older
## By twentyonecoders :
## What is the project about?
For reference please refer to https://en.wikipedia.org/wiki/Blackjack.
BackJack, a game that keeps you entertained during the hardest times. Even if you have no friends or your internet
connection is lost, this game is always playable* and you are in safe hands, since you are not playing with real money.
The player starts with an initial amount of 2000 virtual coins and the game follows the basic blackjack rules,
where the user plays against the dealer. The main goal of the game is to beat the dealer's hand without going over the value of 21.
The landing page is first to appear when opening the application. The user can choose his name and join a game.
Before each round he can bet whatever amount of owned money he wants. When te round starts he gets assigned different cards.
There is the possibility to “hit”, which means to ask for another card, or to “stand” if the player is happy with
the final value and thinks he can outplay the dealer. If the player wins, he gets double the amount of money he bet,
otherwise he will lose the amount of money he bet.
But what happens if you have an unlucky hand and go bankrupt? Don’t worry! The game is not over yet, since there
is no game over. You get another 2000 virtual coins and can go on playing.
If you think the game keeps you prisoner, that is not the case. It might be that you become a little obsessed with it,
just like we did, but after each round the game gives you the possibility to leave it.
And obviously you know the simple keybinding “Alt + F4”.
Our main goal was to create a friendly environment where the player can forget about the world for a few moments and
enjoy gambling at its best. Music will play in the background and the user interface is colorful and easy to use.
these might change when using an IDE (eg. IntelliJ or Eclipse), where you can run the maven goals from the IDE directly.
1. Download the project from gitlab or clone it using ssl or https.
5. Run `mvn javafx:run` to run the app.
### to package the project and obtain a runnable jar file
Run `mvn clean package`. It creates 2 jar files, where blackjack-BLACKJACK.jar is the runnable jar file.
### execute the jar file
to execute the jar file run `java -jar blackjack-BLACKJACK.jar` (when executing you must be in the same
folder as the jar file)
## Problems running the application ?
please message us on LeKerschbaumer@unibz.it
- Java 15 or above https://www.oracle.com/java/technologies/javase-downloads.html
- maven download: https://maven.apache.org/download.cgi; installation guide: https://maven.apache.org/install.html
## Usage
This application is an implementation of the popular card game Blackjack.
The user enters a username and clicks on `start`. The application then proceeds to the
main scene. If the player is unsure about the rules the info button in the top left corner
may be clicked to show the game's rules. The chips at the top of the screen are clickable buttons with which the user can
bet virtual money. In the top right corner, the player's money can be seen. Bets and wins
are subtracted and added to the player's money accordingly. When the player has carried out
the bets, he can press the `ready` button, and the initial card will be dealt. The player
may press `hit` or `stand` now. By pressing hit another card will be dealt. By pressing stand, on the other hand,
the player's turn ends, and the dealer may request further cards.
At the end of the wound, a pop up appears and informs the player about the result. Afterwards
two options are presented:
- continue
- exit the game
## Implementation
To implement this project we use the `org.openjfx` plugin. It can be used to design user interfaces for Java.
We use some basic classes as logic (Hands, Player, Deck, Card). The GUI uses JavaFX
while the logic for the GUI resides in the controller.
Multiplayer is still in development (see Multiplayer branch).
### programming techniques used
1. Collections
- to save the cards in the hands and deck
2. Custom Exception
- for when the player has lost all of his money and is bankrupt
3. Exception handling
- for example when working with I/O
4. Method overriding
- inherited methods for example start in the controller(inherited from Application)
5. Lambdas
- among other things for event listeners
6. Streams
- ex. as foreach loops
7. File I/O
- to obtain the cards and music/sound effects
8. Regex
- to check the username
9. Observer pattern
- when using event listeners
10. Test hooks
- for setting the testing environment
11. serialization
- for logging the events
## Our experience in this project
We organized ourselves using an application called Clickup. It allows us to create
tasks and notes as well as assign those tasks to a team member. It also features
a mind map and other functionality which helped us keep track of what needed to be done.
Git helped us share our code. We used feature branches to develop different parts of the
project for example the logic or the gui.
- Marco: I have some experience in working with Java and also in organizing and working on smaller projects, but to
design a UI using JavaFX is a challenge every time. Especially something like this that should responsively display
the content in order to fit the screen. Then when we thought the project was done we encountered problems when
packaging with maven, and so we had to reroute all the resources to the class reference. Another challenge I faced,
where the transitions, since I had used them before. But anything can be fixed with a good dose of Stackoverflow and a
- Lisa: Since I am new to programming, implementing an own project from the beginning to the end was a challenge, since
we did not only have to work with Java but also with Maven, which was a first timer for me. Some difficulties I
encountered while programming includes the use of animations, as we never properly learned how to implement them, and I
had to look them up on my own. I still wanted to include them since they made the general look of the game more
professional. Therefore, I watched YouTube videos, went on Stackoverflow and looked up solutions on different other
webpages. Marco gave also some good inputs.
- Leo: I have worked with Java before but have never used Maven to generate a runnable JAR file. It turned out to be
quite problematic. I used the maven-assembly plugin, but the jar file would not execute from the terminal.
No error messages, no warnings, no application started. I then tried the maven-shade plugin. However, this time
it would not recognize the resources (sound files and images). The internet led to nothing and colleagues used
the same exact packaging method with success. It turned(thanks Roland for that) out we had to use getResource instead
of the paths directly.