EXTREME Poker is a Card Game based on Texas Holdem that you will create the UI for.
The creators of Poker are long gone and the game’s rules are now a mystery. Passed down through the years by word of mouth; the game has had many different versions pop up. Your mission if you choose to accept it (which you must unless you want a 0) is to create an implementation of Poker to rule them all called EXTREME Poker.
The logic of EXTREME Poker has already been coded and provided for you. So you don’t have to worry about the logic behind the game!! Although knowing it might help with testing. You only need to write the code that creates the UI. Note that there are up to 100 possible bonus points on this assignment.
The rules for EXTREME Poker are very similar to Texas Holdem and are as follows:
The winner(s) is/are the player(s) with the best poker hand. A poker hand is made by combining 5 cards. These cards can come from the Player’s two cards or from the Cards on the board. Not from other Player’s cards. If two players have the same poker hand, then they tie.
The types of poker hands are (in order from best to worst):
MVC stands for model, view, and controller (or view controller).
This style of programming is very powerful and is used widely. If you want to learn more you can read this article or google it.
JavaFx is a massive Library that contains everything you might need for this assignment. Please look for a solution to any problem using JavaDocs before you ask on Piazza.
If you ever get stuck, try looking at these classes in JavaDocs they are very useful!
Make sure you read the entire document before starting. Feel free to change any provided files even in the model or viewcontroller. Just realize that major changes in provided files will make it harder to give partial credit.
Everything in the viewcontroller package is provided! But you do need to know about some of the classes.
GameState is an enum that represents the different states the game can be in
HUMAN_BET
is when the user is bettingAI_BET
is when the AI is bettingDEALING
is when cards are being dealtDONE
is when a round is done and a new one is ready to be startedPokerGameController has a lot of methods but here are the ones you need to know about:
the constructor takes in a PokerGame gameView
and a String name
which is the name of the user.
void start()
should be called when the PokerGameController and all Game related UI have been initialized and displayed. This will start the first round of poker. It should only be called once.
boolean startNewPokerHand()
should be called every time a new hand is ready to be started. It is also called by start(). It returns true if a new game was successfully started.
boolean humanBet(int bet)
is called when the user wants to raise. It takes an int parameter and raises by that much. It returns whether or not the raise was successful.
boolean humanCall()
is used when the user wants to call. It returns whether or not the call was successful.
boolean humanFold()
is used when the user wants to fold. It returns whether or not the fold was successful.
Player getLeftPlayer()
is a getter for the Player object that should be displayed on the left.
Player getTopPlayer()
is a getter for the Player object that should be displayed on the top.
Player getRightPlayer()
is a getter for the Player object that should be displayed on the right
Player getbottomPlayer()
is a getter for the Player object that should be displayed on the bottom.
Board getBoard()
is a getter for the Board object.
GameState getState()
is a getter for the GameState.
setShouldThink(boolean think)
is also useful for testing but not necessary. Only use it for testing though and DO NOT leave it in the version you turn in.
Everything in the model package is provided! But you do need to know about some of the classes.
Suit is an enum that represents the suit of a Card.
The possible Suits are: HEART
, DIAMOND
, CLUB
, SPADE
Suit has one important method:
String getStr()
which returns the String representation of the Suit.CardValue is an enum that represents the rank of a Card.
The possible CardValues are: ACE
, KING
, QUEEN
, JACK
, TEN
, NINE
, EIGHT
, SEVEN
, SIX
, FIVE
, FOUR
, THREE
, TWO
CardValue has one important method:
String getStr()
which returns the String representation of the CardValue.Card has the following methods that you need to use:
Suit getSuit()
returns the Suit of the Card.
CardValue getCardValue()
returns the CardValue of a Card.
Player has the following methods that you need to use:
int getMoney()
which returns how many chips a Player has remaining.
Card getCard(int c)
which returns the cth Card that the player has. So getCard(0)
and getCard(1)
would return the two cards that a Player can have.
Board has the following important methods:
int getNumCards()
which returns the number of cards on the board at the moment.Card getTableCard(int i)
which returns the ith Card on the board.Card[] getCards()
which returns an array of the cards on the board.int getPot()
which return the amount of chips in the pot.This is what you have to write.
PokerGame is an Application and is the class where your main method will reside. PokerGame has four methods: main(), start(), startGame(), and updatesMade().
void main(String[] args)
is provided and you don’t need to edit it.void start(Stage ps)
is called automatically once you launch the JavaFx application. You should display the StartScreen here.void startGame(String name)
is called by StartScreen once StartScreen is finished and should change the Scene to display the GameScreen, ControlPane, and Console. It takes in a String parameter which is the name of the user.void updatesMade()
is called by your PokerGameController whenever updates to the UI need to be made. This should update the GameScreen and ControlPane.
StartScreen is a StackPane that is displayed first when the program is run.
When displayed StartScreen should look similar to this:
GameScreen is a BorderPane and contains all of the UI related to playing the Game.
It will own four PlayerAreas and a BoardArea.
At the start of each round the GameScreen should look similar to this:
Note also that AI_3 has folded and is therefore out of play so its cards were hidden.
GameScreen has a constructor and two methods, updatesMade() and endOfRound()
void updatesMade()
is called whenever normal updates to the GameScreen need to be made (e.g. updating the pot or PlayerAreas).void endOfRound()
is called whenever end of round updates need to be made (e.g. showing the front of all of the cards)PlayerArea owns a Pane where all of its contents will be added and contains all of the UI related to any individual Player.
Above are two highlighted PlayerAreas. The PlayerArea where the user’s cards are is in blue. Only the user’s cards should be shown until the end of the round when all cards are shown.
Above is highlighted a PlayerArea whose Player is out of play. Its cards have been hidden and the out of play indicator has been shown. All the other PlayerAreas’ cards have been shown because it is the end of a round.
PlayerArea has a constructor and two methods, playerPane() and update()
Pane playerPane()
is written for you and doesn’t need to be changed. It returns the pane where all UI elements for a PlayerArea are added.void update(boolean showDetails)
takes in a boolean showDetails which is true whenever the details of the front of the cards are supposed to be shown false otherwise. It should update the UI of the PlayerArea.These two classes are both PlayerAreas and are both very simple. They have been written for you and don’t need to be edited. They both have constructors that take in the Player to display.
IMPORTANT: The PlayerAreas on the left and right of your GameScreen should be instantiated as VerticalPlayers and the PlayerAreas on the top and bottom of your GameScreen should be instantiated as HorizontalPlayers.
CardView is mostly written for you. It has a constructor and four methods: setCard(), show(), hide(), and hideDetails().
void setCard(Card c)
changes which card is displayed in this CardView and is provided. It takes a Card as an argument.void show()
shows the front of the CardView and its details.void hide()
hides the card totally.void hideDetails()
hides the front of the card and shows the back.BoardArea owns an HBox that contains all of the UI elements that have to do with the Board.
Above is highlighted the BoardArea. At this point in the game only four cards are shown and the fifth is hidden. Also, the pot is shown with room for the fifth card to be shown.
BoardArea has a constructor and two methods, getPane() and update().
HBox getPane()
is written for you and doesn’t need to be changed. It returns the pane where all UI elements for a BoardArea are added.void update()
should update the UI of the BoardArea.ControlPane is an HBox that contains all of the UI for controlling the game.
Above is highlighted the ControlPane. It is not the end of a round so the start new round button is hidden and it is the User’s turn so the other buttons are not disabled.
ConrtolPane has a constructor and two methods, playerTurn() and endOfRound().
void playerTurn()
is called when it is the user’s turn again and the buttons should no longer be disabled.void endOfRound()
is called when it is the end of a round and the start new round button should be shown.Console is a ScrollPane and contains all of the UI elements for the Console at the bottom of the Stage.
setVvalue()
in ScrollPane to automatically scroll to the topAbove is highlighted the Console.
Console has a constructor and four methods: addText(), clear(), putMessage(), and clearLog(). It also has a static variable of type Console which should be set to the current Console.
void addText(String newText)
takes in a String and adds it to the top of the Console.void clear()
removes all text from the Console.static void putMessage(String message)
and static void clearLog()
are two static methods and are provided so you don’t need to change them.To compile the homework you can use:
javac src/main/java/model/*.java src/main/java/viewcontroller/*.java src/main/java/view/*.java
And to run the homework you can use:
java -cp src/main/java view.PokerGame
Run these commands from outside the src directory.
JavaDocs will be the same as last homework. Do not forget them!!
For this homework, the checkstyle cap is 100, meaning you can lose up to 100 points on this assignment due to style errors. Run checkstyle early, and get in the habit of writing style compliant code the first time. Don’t wait until 5 minutes before the deadline to find out that you have 100+ violations. You don’t want to get a 0 because you forget to do Checkstyle.
If you encounter trouble running checkstyle, check Piazza for a solution and/or ask a TA as soon as you can!
You can run checkstyle on your code by using the jar file found on the course website like so:
java -jar checkstyle-6.2.2.jar -a src/main/java/model/*.java src/main/java/view/*.java src/main/java/viewcontroller/*.java
.
Javadoc errors are the same as checkstyle errors, as in each one is worth a single point and they are counted towards the checkstyle cap.
You will be responsible for running checkstyle on ALL of your code.
You need not worry about style issues in any of the provided files.
Depending on your editor, you might be able to change some settings to make it easier to write style-compliant code. See the customization tips page (at the bottom) for more information.
You should not import any libraries or packages that trivialize the assignment. Unlike previous homework this doesn’t include List
, Map
, Set
. If you are unsure of whether something is allowed, ask on Piazza. In general, if something does a large part of the assignment for you, it is probably not allowed.
The submission tool is included with the HW files. Run it by typing java -jar hw6-submit.jar
. You can submit as many times as you want so feel free to submit as you make substantial progress on the homework.
As always, late submissions will not be accepted and non-compiling code will be given a score of 0. For this reason, we recommend submitting early and then confirming that you submitted ALL of the necessary files by navigating to the link that the submission tool gives you.