A robust, object-oriented Java battle simulator featuring dynamic combat mechanics, an integrated merchant system, and a modular package architecture.
This project was developed with a focus on Clean Code and Scalable Architecture. As a developer with a background in graphic design, I prioritized a clear user interface within the console environment, utilizing ANSI color coding to enhance the player experience and logical flow.
- Modular OOP Structure: Organized into distinct packages (
warrior,armour,weapon,item,util) to ensure high maintainability and separation of concerns. - Dynamic Combat Logic: Implements damage mitigation formulas and dexterity-based dodge mechanics.
- Merchant & Inventory System: A fully functional in-game economy where players can manage gold and utilize strategic items.
- Cryptographically Secure Randomness: Uses
java.security.SecureRandomfor critical game rolls (loot, damage, and enemy AI decision-making).
The source code follows standard Java package conventions:
BattleGame/
├── src/
│ ├── Battle.java # Main Game Loop & Logic
│ ├── util/ # Ink, Color, and Sound utilities
│ ├── warrior/ # Warrior base class and subclasses (Human, Elf, Orc)
│ ├── armour/ # Defense logic and equipment types
│ ├── weapon/ # Offensive logic and weapon types
│ └── item/ # Consumable items and effect logic
└── README.md
Prerequisites
- Java Development Kit (JDK) 11 or higher. Installation & Execution
- Clone the repository: git clone https://github.com/vibrant-impact/java-battle-sim.git
- Navigate to the source directory:
cd java-battle-sim/src - Compile the project:
javac Battle.java - Run the game:
java Battle
- Naming Conventions: Strictly adheres to camelCase for all variables and method names to ensure consistency across the codebase.
- Scalability: The item and warrior systems are designed using inheritance, making it easy to add new classes or equipment without modifying core battle logic.
Created as part of my journey in Web and Mobile Development with AI.
