This project is a Java-based card game where two players take turns in a battle on a 4x5 board. The game is designed to be well-organized and easy to maintain using object-oriented programming principles. Players place cards on the board, representing minions with special abilities, and try to win by bringing down their opponent's hero.
The project is divided into the following main components:
The actions package is where all the main moves and commands in the game are handled. It includes everything the
players or cards can do during the game, like attacking, using abilities, or placing cards on the board.
This package makes sure that all actions follow the rules of the game and are executed properly.
The cards package is the foundation of the game, as it contains all the card-related components. Cards are split into
two main categories: heroes and minions. The main class is the Card class. It is extended by the Minion and Hero
classes. These classes are further specialised into various subclasses which have special abilities needed for the game
interaction.
The game package forms the core of the application, managing players, the board, and game flow. The Game class
orchestrates the turn-based gameplay, handling the board's 4x5 grid, turn logic, and win conditions. Each Player has a
Deck for drawing cards, a Hand for playing them, and a Hero with unique abilities. The Row enum distinguishes between
front and back rows on the board, as needed for placing the different types of minions.
The setup and initialization of the game are managed by the following classes:
- StartGame.java: Handles the setup logic for starting a new game, including shuffling decks and assigning starting turns.
- Main.java: Entry point for the game. It orchestrates the initialization, execution, and management of game commands.
- Encapsulation:
- Each class manages its own state and behavior through private fields and public methods.
- Inheritance:
- The
Cardclass serves as a base for specialized cards likeHeroandMinion, sharing common attributes likemanaanddescription. Heroes and minions extend this base, adding unique behaviors such as special abilities.
- Polymorphism:
- Hero abilities are implemented as abstract methods in the
Heroclass, allowing each subclass to define its specific behavior while maintaining a consistent interface.
- Abstraction:
- The use of abstract classes like
HeroandMinion.
The game begins with two players selecting a hero and deck, initialized in the Game class. Players alternate turns,
drawing cards, placing them on the 4x5 board, and activating abilities. Turn logic and actions like attacking or using
abilities are managed by dedicated classes in the actions package. Heroes contribute unique abilities, while the
dynamic interactions between cards, players, and the board create strategic depth and variability in gameplay.