This project simulates a turn-based card game combining elements from HearthStone and Gwent. Two players compete using custom decks of cards, taking turns to play cards, attack, or use special abilities. The game ends when one player's hero is defeated.
The gameutils package contains core game classes, while related classes are grouped into sub-packages like cardsinfo:
-
heroes package: Implements the heroes (e.g., General Kocioraw, Empress Thorina) using a Factory Design Pattern and Singleton for unique hero instances.
-
minions package: Implements the minions (e.g. Disciple, The Ripper). The Factory Pattern is used for special minions, while others are handled by the Minion class.
-
StartGame: Handles game initialization and game loop logic, executing commands from ActionsInput.
-
CommandHandler: Processes commands and writes game output to JSON. Handles methods like
getPlayerDeck,placeCard, anduseHeroAbility. -
GameStats: Tracks game statistics, including player turns, round count, and turn cycle, which are essential for multiple games.
-
GameConstants: Defines constants like
MAX_HEALTH,START_MANA,NUM_ROWS, andNUM_CARDS. -
Hand: Represents a player's hand, holding cards available to play. It has methods like
addCard,removeCard, andgetHand. AnArrayListis used to allow easy shifting of elements when cards are added or removed. -
Table: Manages minions on the board using an
ArrayListofLinkedListsfor easy card placement/removal. This structure allows automatic shifting of elements when minions are added or removed. Implements methods likeverifyTankOnRowto ensure tanks are attacked first. -
Player: Represents a player, containing mana, deck, hero, and wins. Includes methods like
updateMana(limits mana to 10 max) andincWinCnt. -
Minion: Represents a minion card, with fields for health, attack status, and frozen status. Includes
verifyIfTankto check for tank type and anabilitymethod for special minions.Special minions include:
- Disciple: Increases minion health.
- Miraj: Swaps its health with another minion.
- The Cursed One: Swaps attack and health of another minion.
- The Ripper: Decreases attack of other minions.
-
Cards: Represents a general card, using
CardInputto store attributes, inherited by Minion and Hero classes. -
Hero: Represents a hero, extending Cards. It tracks whether the hero has used its ability, and includes an overridden
abilitymethod for special heroes.Heroes include:
- General Kocioraw: Increases minion attack.
- Empress Thorina: Destroys the card with the highest health.
- King Mudface: Increases minion health.
- Lord Royce: Freezes opponent minions.
- Inheritance
- Polymorphism
- Encapsulation
- Interfaces
- Design Patterns: Factory, Singleton
- Wrapper Classes (e.g., Integer)
- Composition
- Aggregation
- Packages
- Exception Handling
- Method Overriding
- Final Classes/Methods/Variables