Skip to content
Snippets Groups Projects
README.md 7.22 KiB
Newer Older
LeoKerschbaumer's avatar
LeoKerschbaumer committed
Marco Sciacovelli, Lisa Mussner and Leo Kerschbaumer
## What is the project about?
LeoKerschbaumer's avatar
LeoKerschbaumer committed
For reference please refer to https://en.wikipedia.org/wiki/Blackjack.
LeoKerschbaumer's avatar
LeoKerschbaumer committed
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.
LeoKerschbaumer's avatar
LeoKerschbaumer committed
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.
LeoKerschbaumer's avatar
LeoKerschbaumer committed
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.
LeoKerschbaumer's avatar
LeoKerschbaumer committed
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.
LeoKerschbaumer's avatar
LeoKerschbaumer committed
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”.
LeoKerschbaumer's avatar
LeoKerschbaumer committed

LeoKerschbaumer's avatar
LeoKerschbaumer committed
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.
LeoKerschbaumer's avatar
LeoKerschbaumer committed

LeoKerschbaumer's avatar
LeoKerschbaumer committed
We wish you a lot of fun!
LeoKerschbaumer's avatar
LeoKerschbaumer committed

LeoKerschbaumer's avatar
LeoKerschbaumer committed
*you might need electricity
LeoKerschbaumer's avatar
LeoKerschbaumer committed

LeoKerschbaumer's avatar
LeoKerschbaumer committed
these might change when using an IDE (eg. IntelliJ or Eclipse), where you can run the maven goals from the IDE directly.
### download or clone the project
LeoKerschbaumer's avatar
LeoKerschbaumer committed
1. Download the project from gitlab or clone it using ssl or https.
LeoKerschbaumer's avatar
LeoKerschbaumer committed
### Command Line
LeoKerschbaumer's avatar
LeoKerschbaumer committed
2. `cd` into the project's root directory
LeoKerschbaumer's avatar
LeoKerschbaumer committed
   
### compile the project
LeoKerschbaumer's avatar
LeoKerschbaumer committed
3. Run `mvn clean compile` to compile the project   
LeoKerschbaumer's avatar
LeoKerschbaumer committed
### test the project
LeoKerschbaumer's avatar
LeoKerschbaumer committed
4. Run `mvn test` to run the tests.
LeoKerschbaumer's avatar
LeoKerschbaumer committed
### run the project
LeoKerschbaumer's avatar
LeoKerschbaumer committed
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)
LeoKerschbaumer's avatar
LeoKerschbaumer committed
## Problems running the application ?
please message us on LeKerschbaumer@unibz.it
LeoKerschbaumer's avatar
LeoKerschbaumer committed

- 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
LeoKerschbaumer's avatar
LeoKerschbaumer committed

## 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
LeoKerschbaumer's avatar
LeoKerschbaumer committed
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
LeoKerschbaumer's avatar
LeoKerschbaumer committed
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
LeoKerschbaumer's avatar
LeoKerschbaumer committed
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
LeoKerschbaumer's avatar
LeoKerschbaumer committed
two options are presented:
- continue
- exit the game

## Implementation
LeoKerschbaumer's avatar
LeoKerschbaumer committed
To implement this project we use the `org.openjfx` plugin. It can be used to design user interfaces for Java.
Leo Kerschbaumer's avatar
Leo Kerschbaumer committed
We use some basic classes as logic (Hands, Player, Deck, Card). The GUI uses JavaFX
LeoKerschbaumer's avatar
LeoKerschbaumer committed
while the logic for the GUI resides in the controller.
Multiplayer is still in development (see Multiplayer branch).
LeoKerschbaumer's avatar
LeoKerschbaumer committed

LeoKerschbaumer's avatar
LeoKerschbaumer committed
### 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
LeoKerschbaumer's avatar
LeoKerschbaumer committed

Leo Kerschbaumer's avatar
Leo Kerschbaumer committed
## 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 
LeoKerschbaumer's avatar
LeoKerschbaumer committed
a mind map and other functionality which helped us keep track of what needed to be done.
LeoKerschbaumer's avatar
LeoKerschbaumer committed

Leo Kerschbaumer's avatar
Leo Kerschbaumer committed
Git helped us share our code. We used feature branches to develop different parts of the
project for example the logic or the gui. 
LeoKerschbaumer's avatar
LeoKerschbaumer committed

### challenges
LeoKerschbaumer's avatar
LeoKerschbaumer committed

Marco Sciacovelli's avatar
Marco Sciacovelli committed
- Marco: I have some experience in working with Java and also in organizing and working on smaller projects, but to
LeoKerschbaumer's avatar
LeoKerschbaumer committed
  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
Marco Sciacovelli's avatar
Marco Sciacovelli committed
  packaging with maven, and so we had to reroute all the resources to the class reference. Another challenge I faced,
LeoKerschbaumer's avatar
LeoKerschbaumer committed
  where the transitions, since I had used them before. But anything can be fixed with a good dose of Stackoverflow and a
Marco Sciacovelli's avatar
Marco Sciacovelli committed
  good cup of coffee.
Leo Kerschbaumer's avatar
Leo Kerschbaumer committed
  
Marco Sciacovelli's avatar
Marco Sciacovelli committed
- 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 Kerschbaumer's avatar
Leo Kerschbaumer committed
  
LeoKerschbaumer's avatar
LeoKerschbaumer committed
- 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.
  
Copyright 2021 twentyonecoders