The Magical Arena project is a simple Java application that simulates a battle between two players in a magical arena. Each player has attributes like health, strength, and attack power. The game is turn-based, where players take turns attacking each other using dice rolls to determine the effectiveness of their attacks and defenses. The game continues until one player's health reaches zero.
The project is structured as a Maven project, making it easy to manage dependencies and build the project. The directory structure is organized to separate the main application code from the test code.
Entry point of the application that initializes the players and starts the battle in the arena. Arena Package
Manages the overall battle between two players. It sets up the players and starts the battle sequence. Game Package
Represents a dice with a specified number of sides. Contains a method to roll the dice and return a random value.
Represents a player in the game, with attributes for name, health, strength, and attack power. Contains methods to take damage and check if the player is alive.
Manages the battle logic between two players, including dice rolls for attacks and defenses, calculating damage, and determining the outcome of the battle.
Utility class for generating random numbers within a specified range. Used for dice rolls.
The project includes comprehensive unit tests to ensure the functionality of each component. The tests are written using JUnit 5 and cover the following:
Tests the creation of the arena and initialization of players.
Tests the dice roll functionality to ensure it returns values within the expected range.
Tests player creation, taking damage, and checking if the player is alive.
Tests the battle logic between two players to ensure the correct calculation of damage and the determination of the battle outcome.
Tests the random number generation to ensure it falls within the specified range.
------------------------------ Build and Run Instructions -------------------------------------------
git clone <repository_url>
cd MagicalArena
mvn clean package
java -cp target/MagicalArena-1.0-SNAPSHOT.jar com.magicalarena.Main
mvn test
The code has a clear and simple design, making it easy to understand and modify.
The code is well-organized with clear and consistent naming conventions.
The objects and classes are well-designed and appropriate for the problem at hand.
The code is easy to maintain and modify, with a clean separation of concerns.
The code has comprehensive unit tests, providing a high degree of test coverage.
This project serves as a good example of applying object-oriented principles and writing clean, maintainable code in Java. The use of Maven ensures that dependencies are managed effectively, and the project structure follows best practices for Java development.