This codebase is designed to implement a card game called "ThreeTrioGame". The game involves creating a board and a deck of cards from configuration files, and players take turns to play the game until a winner is determined. The codebase assumes that users have a basic understanding of Java programming and familiarity with concepts like file I/O, collections, and object-oriented programming. The codebase is designed to be extensible, allowing for modifications to the game rules, card properties, and board configurations.
- Hints: If you're struggling to beat our AI, you can now start your game in easy mode to get hints on what moves to make.
- New modes: You can now play the game in reverse mode, fallen angel mode, or both!
- New rules: You can add one rule to the game such as the Same and Plus rules.
- Added decorator classes for ThreeTrioModel to add new rules and modes to the game.
- Changed the main function to take in more arguments to allow for new modes, rules, and hints to be added to the game.
- Moved some functions from the ThreeTrioGame class to the ThreeTrioModel class to streamline developer experience for decorators.
cd
into the directory containing the jar file- run
java -jar three-trios.jar human human
to start the game with two human players (player 1 will have our view implementation, player 2 will have the provider's view implementation)
- There were no changes to the command line interface (see above for quick start). The provider view is hard coded in for player 2 as per assignment instructions
- We were able to get all view functions working. It is able to display the game state and interact with the model the same way our original view is able to
- Some difficulties we ran into with our provider is that some classes that should be interfaces were concrete classes. Our providers were kind enough to gut and refactor their code to turn them into interfaces.
- Turned Move class intro an interface
- Player getMove should return the Move interface
- ThreeTrioCard interface deepCopy() returns type ThreeTrioCard instead of concrete class PlayingCard
- Created interface
ThreeTrioGuiFeatures
for player actions - Created interface
ControllerFeatures
for model updates / status - Both interfaces are implemented in the controller.
- Models can add controllers as subscribers to listen for updates.
- Controller is able to tell view to notify players and let them know if its their turn.
- Controller is able to listen to view for player actions and update the model and view accordingly.
- Game can now be played in two windows in various settings: (AI is powered by our strategy classes)
- Player vs Player
- Player vs AI
- AI vs AI
- Updated main function to take in command line args for the two players playing the game.
- No Major design changes were needed to be made.
- Added public helper function getOtherPlayerHand(), isLegalMove(), getCard() in our model to make it easier for strategies to interact with the game
- Created a ReadOnly interface to ensure no unnecessary classes can modify the game state
- Created
LeastLikelyToFlipStrategy.java
(strategy #3),MinimaxStrategy.java
(strategy #4), andComplexPlayerStrategy.java
to chain together strategies - Tests for the LeastLikelyToFlip, MinMax, and Complex Strategy can be found
in
test/StrategyTests.java
- Direct yourself to the test directory to run the program.
- Setup the model and view
- game = new ThreeTrioGame("board.config", "deck.config");
- this.deck = game.createDeck();
- this.board = game.createBoard();
- game.setBoard(this.board);
- game.setDeck(this.deck);
- view = new GameView(game);
- Play the game to your liking
- try {
game.startGame(game.createDeck(), game.createBoard());
} catch (FileNotFoundException e) {
e.printStackTrace();
} - game.playToBoard(0,0,0);
game.playToBoard(0,1,0);
whatever other commands you want... - game.isGameOver();
game.getWinner();
whatever else you would want to see
- try {
- ThreeTrioGame: This is the main class that drives the control flow of the game. It handles the creation of the deck and board, manages the game state, and determines the winner.
- ThreeTrioCard: Represents a card in the game. Each card has a name, attack values for four directions, and a color.
- ConfigReader: Responsible for reading the configuration files (
deck.config
andboard.config
) and creating the deck and board based on the configurations.
createDeck()
: Reads thedeck.config
file and creates a list ofThreeTrioCard
objects.createBoard()
: Reads theboard.config
file and creates a 2D array ofThreeTrioCard
objects.isGameOver()
: Checks if the game is over by verifying if all cards have been played.getWinner()
: Determines the winner based on the scores of the players.boardToString()
,deckToString()
,handToString()
: Utility methods to convert the board, deck, and hand to string representations.
ThreeTrioCard(String name, Attack north, Attack south, Attack east, Attack west)
: Constructor to initialize a card with a name and attack values.isHole()
: Checks if the card is a hole.getColor()
: Returns the color of the card.shortString()
,toString()
: Utility methods to convert the card to string representations.
createDeck()
: Reads thedeck.config
file and creates a list ofThreeTrioCard
objects.createBoard()
: Reads theboard.config
file and creates a 2D array ofThreeTrioCard
objects.
-
src/model: Contains the core game logic and data structures.
ThreeTrioGame.java
: Main class that drives the control flow of the game.ThreeTrioCard.java
: Represents a card in the game.ConfigReader.java
: Responsible for reading the configuration files and creating the deck and board.
-
src/playerstrategy: Contains the core game logic and data structures.
playerstrategy.java
: Strategy interface that all other strategies implement.StrategyType.java
: Enum for all the types of strategies. Used in the minmax strategy.TieBreaker.java
: Helper class to break ties between Moves in a strategy.Move.java
: Represents a move for a ThreeTrios game.
-
src/view: Contains the classes related to the game's user interface.
ThreeTrioGuiView.java
: View interface to list out functionality of the GUI.ThreeTrioGuiFeatures.java
: Features interface to allow for easy implementation of new features in the GUI.GameView.java
: Manages the overall display of the game state and integrates the ThreeTrioPanel for rendering the game.ThreeTrioPanel.java
: Handles the graphical representation of the game board and player hands, and manages user interactions with the game.GuiGameView.java
: Class that extends JFrame. Takes in a model to render using JPanel and provides functionality for panel.
-
/test/: Contains the test cases for the game. Including a folder specifically for model tests.
ModelTests.java
: Tests for the core game logic inThreeTrioGame
.PlayingCardTests.java
: Tests for the cards used inThreeTrioGame
.Gameplay.java
: Tests for more complex game logic, including full games.ModelTests.java
: Tests for the core game logic inThreeTrioGame
.