Base files added.
This commit is contained in:
Generated
+13
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="Java-Knight" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+7
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/Java-Knight/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/Java-Knight/src/main/resources" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+20
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://maven.devneeds.ir/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+8
@@ -1,5 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/Java-Knight/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="25" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" project-jdk-name="25" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.project</groupId>
|
||||||
|
<artifactId>Java-Knight</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>25</maven.compiler.source>
|
||||||
|
<maven.compiler.target>25</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package org.project;
|
||||||
|
|
||||||
|
import org.project.location.Location;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO: ADD SOME LOCATIONS TO YOUR GAME
|
||||||
|
List<Location> locations = new ArrayList<>();
|
||||||
|
|
||||||
|
// TODO: IMPLEMENT GAMEPLAY
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package org.project.entity;
|
||||||
|
|
||||||
|
public interface Entity {
|
||||||
|
void attack(Entity target);
|
||||||
|
|
||||||
|
void defend();
|
||||||
|
|
||||||
|
void heal(int health);
|
||||||
|
|
||||||
|
void fillMana(int mana);
|
||||||
|
|
||||||
|
void takeDamage(int damage);
|
||||||
|
|
||||||
|
int getMaxHP();
|
||||||
|
|
||||||
|
int getMaxMP();
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||||
|
*/
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.object.weapons.Weapon;
|
||||||
|
|
||||||
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
|
public abstract class Enemy {
|
||||||
|
Weapon weapon;
|
||||||
|
private int hp;
|
||||||
|
private int mp;
|
||||||
|
|
||||||
|
public Enemy(int hp, int mp, Weapon weapon) {
|
||||||
|
this.hp = hp;
|
||||||
|
this.mp = mp;
|
||||||
|
|
||||||
|
this.weapon = weapon;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: (BONUS) UPDATE THE FORMULA OF TAKING DAMAGE
|
||||||
|
@Override
|
||||||
|
public void takeDamage(int damage) {
|
||||||
|
hp -= damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHp() {
|
||||||
|
return hp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMp() {
|
||||||
|
return mp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Weapon getWeapon() {
|
||||||
|
return weapon;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
|
public class Skeleton {
|
||||||
|
// TODO: DESIGN ENEMY'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
|
public class Knight {
|
||||||
|
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import org.project.object.armors.Armor;
|
||||||
|
import org.project.object.weapons.Weapon;
|
||||||
|
|
||||||
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
|
public abstract class Player {
|
||||||
|
protected String name;
|
||||||
|
Weapon weapon;
|
||||||
|
Armor armor;
|
||||||
|
private int hp;
|
||||||
|
private int maxHP;
|
||||||
|
private int mp;
|
||||||
|
private int maxMP;
|
||||||
|
|
||||||
|
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||||
|
this.name = name;
|
||||||
|
this.hp = hp;
|
||||||
|
this.mp = mp;
|
||||||
|
|
||||||
|
this.weapon = weapon;
|
||||||
|
this.armor = armor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attack(Entity target) {
|
||||||
|
target.takeDamage(weapon.getDamage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void defend() {
|
||||||
|
// TODO: (BONUS) IMPLEMENT A DEFENSE METHOD FOR SHIELDS
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: (BONUS) UPDATE THE FORMULA OF TAKING DAMAGE
|
||||||
|
@Override
|
||||||
|
public void takeDamage(int damage) {
|
||||||
|
hp -= damage - armor.getDefense();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void heal(int health) {
|
||||||
|
hp += health;
|
||||||
|
if (hp > maxHP) {
|
||||||
|
hp = maxHP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillMana(int mana) {
|
||||||
|
mp += mana;
|
||||||
|
if (mp > maxMP) {
|
||||||
|
mp = maxMP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHp() {
|
||||||
|
return hp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHP() {
|
||||||
|
return maxHP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMp() {
|
||||||
|
return mp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxMP() {
|
||||||
|
return maxMP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Weapon getWeapon() {
|
||||||
|
return weapon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Armor getArmor() {
|
||||||
|
return armor;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package org.project.location;
|
||||||
|
|
||||||
|
import org.project.entity.enemies.Enemy;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Location {
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private ArrayList<Enemy> enemies;
|
||||||
|
|
||||||
|
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
||||||
|
this.locations = locations;
|
||||||
|
this.enemies = enemies;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO: (BONUS) RESET EACH LOCATION AFTER PLAYER LEAVES
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Location> getLocations() {
|
||||||
|
return locations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Enemy> getEnemies() {
|
||||||
|
return enemies;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package org.project.object;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public interface Object {
|
||||||
|
void use(Entity target);
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||||
|
*/
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package org.project.object.armors;
|
||||||
|
|
||||||
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
|
public abstract class Armor {
|
||||||
|
private int defense;
|
||||||
|
private int maxDefense;
|
||||||
|
private int durability;
|
||||||
|
private int maxDurability;
|
||||||
|
|
||||||
|
private boolean isBroke;
|
||||||
|
|
||||||
|
public Armor(int defense, int durability) {
|
||||||
|
this.defense = defense;
|
||||||
|
this.durability = durability;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkBreak() {
|
||||||
|
if (durability <= 0) {
|
||||||
|
isBroke = true;
|
||||||
|
defense = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: (BONUS) UPDATE THE REPAIR METHOD
|
||||||
|
public void repair() {
|
||||||
|
isBroke = false;
|
||||||
|
defense = maxDefense;
|
||||||
|
durability = maxDurability;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefense() {
|
||||||
|
return defense;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDurability() {
|
||||||
|
return durability;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBroke() {
|
||||||
|
return isBroke;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package org.project.object.armors;
|
||||||
|
|
||||||
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
|
public class KnightArmor {
|
||||||
|
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package org.project.object.consumables;
|
||||||
|
|
||||||
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
|
public abstract class Consumable {
|
||||||
|
/*
|
||||||
|
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||||
|
*/
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package org.project.object.consumables;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
|
public class Flask {
|
||||||
|
/*
|
||||||
|
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: (BONUS) UPDATE USE METHOD
|
||||||
|
@Override
|
||||||
|
public void use(Entity target) {
|
||||||
|
target.heal(target.getMaxHP() / 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package org.project.object.weapons;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
|
public class Sword {
|
||||||
|
/*
|
||||||
|
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int abilityCharge;
|
||||||
|
|
||||||
|
public Sword() {
|
||||||
|
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
||||||
|
public void uniqueAbility(ArrayList<Entity> targets) {
|
||||||
|
abilityCharge += 2;
|
||||||
|
for (Entity target : targets) {
|
||||||
|
target.takeDamage(getDamage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package org.project.object.weapons;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
|
public abstract class Weapon {
|
||||||
|
private int damage;
|
||||||
|
private int manaCost;
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Weapon(int damage, int manaCost) {
|
||||||
|
this.damage = damage;
|
||||||
|
this.manaCost = manaCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void use(Entity target) {
|
||||||
|
target.takeDamage(damage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDamage() {
|
||||||
|
return damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getManaCost() {
|
||||||
|
return manaCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||||
|
*/
|
||||||
|
}
|
||||||
@@ -39,7 +39,7 @@ git checkout -b develop
|
|||||||
|
|
||||||
A well-structured OOP hierarchy is crucial. Avoid duplicating code by placing shared logic in abstract classes.
|
A well-structured OOP hierarchy is crucial. Avoid duplicating code by placing shared logic in abstract classes.
|
||||||
|
|
||||||
- **Entities & Locations:** You have `Entity`, `Object`, and `Location`.
|
- **Entities & Locations:** You have `Entity`, `Object`(Bonus) , and `Location`.
|
||||||
- **Players:** `Player` is an abstract class implementing `Entity`. Subclasses: `Wizard`, `Knight`, `Assassin`.
|
- **Players:** `Player` is an abstract class implementing `Entity`. Subclasses: `Wizard`, `Knight`, `Assassin`.
|
||||||
- **Base Stat Differences:** Each class must have distinct starting stats. For example:
|
- **Base Stat Differences:** Each class must have distinct starting stats. For example:
|
||||||
- **Knight:** Highest Base Damage.
|
- **Knight:** Highest Base Damage.
|
||||||
@@ -47,7 +47,11 @@ A well-structured OOP hierarchy is crucial. Avoid duplicating code by placing sh
|
|||||||
- **Assassin:** Highest Max Stamina/Mana.
|
- **Assassin:** Highest Max Stamina/Mana.
|
||||||
- **Enemies:** `Enemy` is an abstract class implementing `Entity`. Subclasses: `Skeleton`, `Goblin`, `Vampire`, and **`Dragon`**.
|
- **Enemies:** `Enemy` is an abstract class implementing `Entity`. Subclasses: `Skeleton`, `Goblin`, `Vampire`, and **`Dragon`**.
|
||||||
- **The Boss:** Even though `Dragon` is the final boss, it **must** be a subclass of `Enemy` to inherit common combat properties, while possessing extremely high stats and unique mechanics.
|
- **The Boss:** Even though `Dragon` is the final boss, it **must** be a subclass of `Enemy` to inherit common combat properties, while possessing extremely high stats and unique mechanics.
|
||||||
- **Objects:** `Consumable`, `Armor`, `Weapon` are abstract classes implementing `Object`.
|
- **Objects (Bonus):** `Consumable`, `Armor`, `Weapon` are abstract classes implementing `Object`. example :
|
||||||
|
- KnightArmor extends Armor - you can add more subclasses of Armor for extra score
|
||||||
|
- Sword extends Weapon - you can add more subclasses of Weapon for extra score
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### 3️⃣ Step 3: Implement Player & Monster Methods 🏹
|
### 3️⃣ Step 3: Implement Player & Monster Methods 🏹
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
Reference in New Issue
Block a user