1 Commits
Author SHA1 Message Date
Mobina cdc7df6980 HW-04 2026-05-16 21:17:27 +03:30
61 changed files with 892 additions and 123 deletions
BIN
View File
Binary file not shown.
+10
View File
@@ -0,0 +1,10 @@
# Default ignored files
/shelf/
/workspace.xml
# Ignored default folder with query files
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
+13
View File
@@ -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>
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
+25
View File
@@ -0,0 +1,25 @@
<?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://repo.maven.apache.org/maven2" />
</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>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://mirror-maven.runflare.com/maven2" />
</remote-repository>
</component>
</project>
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="25" project-jdk-type="JavaSDK" />
</project>
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/src" vcs="Git" />
</component>
</project>
+10
View File
@@ -0,0 +1,10 @@
# Default ignored files
/shelf/
/workspace.xml
# Ignored default folder with query files
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="25" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Java-Knight.iml" filepath="$PROJECT_DIR$/Java-Knight.iml" />
</modules>
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/main/java/org/project" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/main.iml" filepath="$PROJECT_DIR$/.idea/main.iml" />
</modules>
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
+51
View File
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="bcc71b41-7439-4f39-b474-ea0116df97fd" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/java/org/project/Main.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/entity/Entity.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/entity/enemies/Enemy.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/entity/enemies/Skeleton.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/entity/players/Knight.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/entity/players/Player.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/item/Item.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/item/armors/Armor.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/item/armors/KnightArmor.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/item/consumables/Consumable.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/item/consumables/Flask.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/item/weapons/Sword.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/item/weapons/Weapon.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/java/org/project/location/Location.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="ProjectId" id="3DmEvFXOz7y3rSShamzpMEiae83" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="bcc71b41-7439-4f39-b474-ea0116df97fd" name="Changes" comment="" />
<created>1778879078762</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1778879078762</updated>
<workItem from="1778879086494" duration="18000" />
</task>
<servers />
</component>
</project>
@@ -0,0 +1,12 @@
package org.project;
public class Colors {
public static final String RESET = "\u001B[0m";
public static final String RED = "\u001B[31m";
public static final String GREEN = "\u001B[32m";
public static final String YELLOW = "\u001B[33m";
public static final String BLUE = "\u001B[34m";
public static final String PURPLE = "\u001B[35m";
public static final String CYAN = "\u001B[36m";
}
+302 -6
View File
@@ -1,15 +1,311 @@
package org.project;
import org.project.entity.enemies.*;
import org.project.entity.players.*;
import org.project.item.armors.*;
import org.project.item.weapons.*;
import org.project.location.Location;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Random;
public class Main {
public static void main(String[] args) {
// TODO: ADD LOCATIONS TO YOUR GAME
List<Location> locations = new ArrayList<>();
private static Scanner in = new Scanner(System.in);
private static Random random = new Random();
private static String playerClass = "";
private static int totalKeys = 0;
// TODO: IMPLEMENT GAMEPLAY
public static void main(String[] args) {
System.out.println("Enter your name:");
String name = in.next();
System.out.println("choose your character:\n1.Knight 2.Wizard 3.Assassin");
int choice = in.nextInt();
Player player = null;
switch (choice) {
case 1:
player = new Knight(name);
playerClass = "knight";
break;
case 2:
player = new Wizard(name);
playerClass = "wizard";
break;
case 3:
player = new Assassin(name);
playerClass = "assassin";
break;
default:
player = new Knight(name);
playerClass = "knight";
}
final Player finalPlayer = player;
int menuChoice = 0;
while (menuChoice != 3) {
clearScreen();
displayMenu();
menuChoice = in.nextInt();
switch (menuChoice) {
case 1:
newGame(1, finalPlayer);
break;
case 2:
newGame(2, finalPlayer);
break;
case 3:
System.out.println("\n👋 GOODBYE!");
break;
}
}
}
public static void displayMenu() {
System.out.println("╔══════════════════════════════════════════════════════╗");
System.out.println("║ 🗝️ KEYS: " + totalKeys + " 🗝️ ║");
System.out.println("╠══════════════════════════════════════════════════════╣");
System.out.println("║ ║");
System.out.println("║ ⚔️ [1] NEW GAME ⚔️ ║");
System.out.println("║ 🐉 [2] VS DRAGON 🐉 ║");
System.out.println("║ ❌ [3] EXIT ❌ ║");
System.out.println("║ ║");
System.out.println("╚══════════════════════════════════════════════════════╝");
System.out.print("➡️ CHOOSE: ");
}
public static void newGame(int model, Player player) {
Enemy enemy = null;
//جنگ با دشمن رندوم
if (model == 1) {
Location loc=new Location();
String location = loc.chooseLocation();
System.out.println("📍 You are in " + location);
if (loc.thereIsKey()) {
System.out.println("🔑 There is a Key here!");
}
delay(2500);
int chooseEnemy = random.nextInt(3);
switch (chooseEnemy) {
case 0:
enemy = new Skeleton();
System.out.println("You're fighting with skeleton \uD83D\uDC80");
break;
case 1:
enemy = new Vampier();
System.out.println("You're fighting with Vampire \uD83E\uDDDB");
break;
case 2:
enemy = new Orc();
System.out.println("You're fighting with Orc \uD83D\uDC79");
break;
}
delay(3000);
startBattle(player, enemy,loc);
//جنگ با اژدها
} else {
if (totalKeys >= 3) {
enemy = new Dragon();
System.out.println("🐉 YOU ARE IN DRAGON'S HOUSE! 🐉");
System.out.println(" You used 3 keys!");
totalKeys -= 3;
Location loc=new Location(1);// تابع سازنده اژدها یک عدد ورودی دریافت میکنه
delay(2000);
startBattle(player, enemy, loc);
if (enemy.getHp() <= 0) {
System.out.println("🏆 LEGEND! YOU DEFEATED THE DRAGON! 🏆");
}
//اگر 3 کلید نداشت
} else {
System.out.println("╔══════════════════════════════════════════════════════╗");
System.out.println("║ ❌ YOU NEED 3 KEYS TO FIGHT THE DRAGON! ❌ ║");
System.out.printf("║ 🔑 YOUR KEYS: %d / 3 ║\n", totalKeys);
System.out.println("║ ⚔️ Defeat enemies in NEW GAME to get keys! ║");
System.out.println("╚══════════════════════════════════════════════════════╝");
delay(2000);
}
}
}
public static void startBattle(Player player, Enemy enemy, Location loc) {
while (player.getHp() > 0 && enemy.getHp() > 0) {
clearScreen();
displayBattle(player.getHp(), player.getMaxHP(), player.getMp(), player.getMaxMP(),
enemy.getHp(), enemy.getMaxHP(), player.getArmor().getDurability(),
player.getArmor().getDefense(), playerClass);
int playerChoice = in.nextInt();
clearScreen();
System.out.println("You:");
switch (playerChoice) {
case 1:
player.LightAttack(enemy);
break;
case 2:
if (player.getMp() > 0) {
player.HeavyAttack(enemy);
} else
{
System.out.println("Your MP is out.");
player.LightAttack(enemy);
}
break;
case 3:
if(player.getMp()>0)
player.defend();
else
{
System.out.println("Your MP is out.");
player.LightAttack(enemy);
}
break;
case 4:
if(player.getMp()>0)
player.SpecialAttack(enemy,1);
else
{
System.out.println("Your MP is out.");
player.LightAttack(enemy);
}
break;
case 5:
if(player.getMp()>0)
player.heal();
else
{
System.out.println("Your MP is out.");
player.LightAttack(enemy);
}
break;
}
delay(2500);
if (enemy.getHp() > 0) {
clearScreen();
System.out.println("Enemy: ");
int enemyMove = random.nextInt(3);
switch (enemyMove) {
case 0:
if(!player.getIsDefending()) {
enemy.LightAttack(player);
System.out.println("The enemy made a light attack \uD83D\uDC4A");
}
else {
player.defend();
System.out.println("The enemy attacked, but you defended.\uD83D\uDCAF");
}
break;
case 1:
enemy.heal();
System.out.println("The enemy healed. \uD83E\uDE84");
break;
case 2:
if(!player.getIsDefending())
{
if (enemy instanceof Vampier) {
enemy.HeavyAttack(player);
System.out.println("The Vampire made a heavy attack \uD83E\uDE78");
} else if (enemy instanceof Dragon) {
((Dragon) enemy).burn(player);
System.out.println("The dragon breathed fire \uD83D\uDD25\uD83D\uDD25");
} else {
enemy.LightAttack(player);
System.out.println("The enemy made a light attack \uD83D\uDC4A");
}
}
else
{
player.defend();
System.out.println("The enemy attacked, but you defended.\uD83D\uDCAF");
}
break;
}
delay(2500);
}
}
clearScreen();
if (enemy.getHp() <= 0) {
System.out.println("╔══════════════════════════════════════════════════════╗");
System.out.println("║ 🎉 YOU WON! 🎉 ║");
System.out.println("╚══════════════════════════════════════════════════════╝");
if (loc.thereIsKey()) {
totalKeys++;
System.out.println("🔑 You found a KEY on the enemy!");
System.out.println("🗝️ Total keys: " + totalKeys);
}
} else {
System.out.println("╔══════════════════════════════════════════════════════╗");
System.out.println("║ 💀 YOU LOST! 💀 ║");
System.out.println("╚══════════════════════════════════════════════════════╝");
}
delay(2500);
player.fillHP();
player.fillHP();
player.filldurability();
}
public static void displayBattle(int playerHP, int playerMaxHP, int playerMP, int playerMaxMP,
int enemyHP, int enemyMaxHP, int ArmorDurability, int ArmorDefense, String playerClass) {
String playerEmoji = "";
if (playerClass.equals("wizard")) {
playerEmoji = "🧙";
} else if (playerClass.equals("knight")) {
playerEmoji = "⚔️";
} else if (playerClass.equals("assassin")) {
playerEmoji = "🗡️";
} else {
playerEmoji = "🧝";
}
System.out.println("╔══════════════════════════════════════════════════════════════════════╗");
System.out.println("║ ⚔️ BATTLE START! ⚔️ ║");
System.out.println("╠═══════════════════════╦══════════════════════════════════════════════╣");
System.out.printf("║ %s %-18s║ 👾 %-30s║\n", playerEmoji, playerClass.toUpperCase(), "ENEMY");
System.out.println("╠═══════════════════════╬══════════════════════════════════════════════╣");
System.out.printf("║ ❤️ HP: %3d/%-3d ║ ❤️ HP: %3d/%-3d ║\n",
playerHP, playerMaxHP, enemyHP, enemyMaxHP);
System.out.printf("║ 💙 MP: %3d/%-3d ║ ⚔️ %-40s║\n",
playerMP, playerMaxMP, "");
System.out.printf("║ 🛡️ Armor: Durability: %3d Defense: %3d ║\n",
ArmorDurability,
ArmorDefense);
System.out.println("╚═══════════════════════╩══════════════════════════════════════════════╝");
System.out.println("\n📍 ACTIONS:");
System.out.println("╔══════════════════════════════════════════════════════════════════════╗");
System.out.println("║ [1] ⚡ Light Attack [2] 💥 Heavy Attack [3] 🛡️ Defend ║");
System.out.println("║ [4] ✨ Special Attack [5] 💊 Heal ║");
System.out.println("╚══════════════════════════════════════════════════════════════════════╝");
System.out.print("\n➡️ Choose: ");
}
public static void clearScreen() {
System.out.print("\033[H\033[2J");
System.out.flush();
}
public static void delay(int ms) {
try {
Thread.sleep(ms);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
@@ -1,21 +1,13 @@
package org.project.entity;
public interface Entity {
void attack(Entity target);
void defend();
void LightAttack(Entity target);
void heal(int health);
void fillMana(int mana);
void heal();
void takeDamage(int damage);
int getMaxHP();
int getMaxMP();
/*
TODO: ADD OTHER REQUIRED AND BONUS METHODS
*/
}
@@ -0,0 +1,15 @@
package org.project.entity.enemies;
import org.project.entity.players.Player;
import org.project.item.weapons.wand;
public class Dragon extends Enemy{
public Dragon(){
super(400, 400, new wand());
}
public void burn(Player player)
{
player.takeDamage(70);
}
}
@@ -1,17 +1,18 @@
package org.project.entity.enemies;
import org.project.item.weapons.Weapon;
import org.project.entity.Entity;
import org.project.Colors;
// TODO: UPDATE IMPLEMENTATION
public abstract class Enemy {
public class Enemy implements Entity{
Weapon weapon;
private int hp;
private int mp;
private int maxHP;
public Enemy(int hp, int mp, Weapon weapon) {
public Enemy(int hp, int maxHP, Weapon weapon) {
this.hp = hp;
this.mp = mp;
this.maxHP = maxHP;
this.weapon = weapon;
}
@@ -20,12 +21,33 @@ public abstract class Enemy {
hp -= damage;
}
@Override
public void LightAttack(Entity target) {
target.takeDamage(weapon.getLightDamage());
}
public void HeavyAttack(Entity target)
{
System.out.println("poof");
}
@Override
public void heal() {
hp += 20;
if (hp > maxHP) {
hp = maxHP;
}
hp -= 20;
}
public int getHp() {
return hp;
}
public int getMp() {
return mp;
@Override
public int getMaxHP() {
return maxHP;
}
public Weapon getWeapon() {
@@ -0,0 +1,14 @@
package org.project.entity.enemies;
import org.project.item.weapons.Sword;
public class Orc extends Enemy{
public Orc()
{
super(200, 200, new Sword());
}
}
@@ -1,6 +1,12 @@
package org.project.entity.enemies;
import org.project.item.weapons.machete;
// TODO: UPDATE IMPLEMENTATION
public class Skeleton {
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
public class Skeleton extends Enemy{
public Skeleton()
{
super(50,50, new machete());
}
}
@@ -0,0 +1,17 @@
package org.project.entity.enemies;
import org.project.entity.Entity;
import org.project.item.weapons.Sword;
public class Vampier extends Enemy{
public Vampier()
{
super(200, 200, new Sword());
}
@Override
public void HeavyAttack(Entity target) {
target.takeDamage(((Sword) getWeapon()).getHeavyDamage());
}
}
@@ -0,0 +1,42 @@
package org.project.entity.players;
import org.project.entity.Entity;
import org.project.Colors;
import org.project.item.armors.AssassinArmor;
import org.project.item.weapons.machete;
public class Assassin extends Player{
public Assassin(String name)
{
super(name, new machete(), new AssassinArmor());
}
@Override
public void SpecialAttack(Entity target, int time)
{
if (time>0){
time--;
mp=100;
System.out.println(Colors.PURPLE + "✨ SPECIAL ATTACK! ✨" + Colors.RESET);
System.out.println(Colors.PURPLE + "WHOOSH!" + Colors.RESET);
System.out.println("🔥 Recovery completed ");
}
}
@Override
public void heal() {
hp += 15;
if (hp > 100) {
hp = 100;
}
mp-=10;
System.out.println(Colors.GREEN + "💊 HEAL! 💊" + Colors.RESET);
System.out.println(Colors.GREEN + " WHOOSH!" + Colors.RESET);
System.out.println(Colors.RED + " HP restored: + 15" + Colors.RESET);
}
}
@@ -1,6 +1,35 @@
package org.project.entity.players;
import org.project.entity.Entity;
import org.project.item.armors.KnightArmor;
import org.project.item.weapons.Sword;
import org.project.Colors;
// TODO: UPDATE IMPLEMENTATION
public class Knight {
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
public class Knight extends Player {
Sword sward=new Sword();
public Knight(String name) {
super(name, new Sword(), new KnightArmor());
}
@Override
public void SpecialAttack(Entity target, int time) {
if (time > 0) {
time--;
int index = hp;
HeavyAttack(target);
HeavyAttack(target);
hp = index;
mp -= 20;
System.out.println(Colors.PURPLE + "✨ SPECIAL ATTACK! ✨" + Colors.RESET);
System.out.println(Colors.PURPLE + "KABOOM!" + Colors.RESET);
System.out.println("🔥 Damage: " + 2 * sward.getHeavyDamage());
}
}
}
@@ -3,58 +3,88 @@ package org.project.entity.players;
import org.project.entity.Entity;
import org.project.item.armors.Armor;
import org.project.item.weapons.Weapon;
import org.project.Colors;
// TODO: UPDATE IMPLEMENTATION
public abstract class Player {
public class Player implements Entity{
protected String name;
Weapon weapon;
Armor armor;
private int hp;
private int maxHP;
private int mp;
private int maxMP;
protected int hp = 100;
private int maxHP = 100;
protected int mp = 100;
private int maxMP = 100;
private boolean isDefending = false;
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
public Player(String name, 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());
public void SpecialAttack(Entity target, int time) {
System.out.println("poof");
}
public void HeavyAttack(Entity target) {
target.takeDamage(weapon.getHeavyDamage());
mp -= weapon.getManaCost();
System.out.println(Colors.CYAN + "⚡ HEAVY ATTACK! ⚡" + Colors.RESET);
System.out.println(Colors.GREEN + "BOOM!" + Colors.RESET);
System.out.println(Colors.YELLOW + " 🗡️ Damage: " + weapon.getHeavyDamage() + Colors.RESET);
}
@Override
public void LightAttack(Entity target) {
target.takeDamage(weapon.getLightDamage());
System.out.println(Colors.CYAN + "⚡ LIGHT ATTACK! ⚡" + Colors.RESET);
System.out.println(Colors.GREEN + " SMASH!" + Colors.RESET);
System.out.println(Colors.YELLOW + " 🗡️ Damage: " + weapon.getLightDamage() + Colors.RESET);
}
public void defend() {
// TODO
if (!isDefending) {
mp -= 10;
}
isDefending = !isDefending;
System.out.println("🛡️ Defend! 🛡️");
System.out.println(Colors.BLUE + "THWACK!" + Colors.RESET);
System.out.println(" Damage reduced!");
}
@Override
public void takeDamage(int damage) {
hp -= damage - armor.getDefense();
armor.decreacDurability();
}
@Override
public void heal(int health) {
hp += health;
public void heal() {
hp += 10;
if (hp > maxHP) {
hp = maxHP;
}
mp -= 10;
System.out.println(Colors.GREEN + "💊 HEAL! 💊" + Colors.RESET);
System.out.println(Colors.GREEN + "WHOOSH!" + Colors.RESET);
System.out.println(Colors.RED + " HP restored: +10" + Colors.RESET);
}
@Override
public void fillMana(int mana) {
mp += mana;
if (mp > maxMP) {
public void fillMana() {
mp = maxMP;
}
}
public void fillHP() {hp=maxHP; }
public void filldurability()
{
armor.filldur();
}
public String getName() {
return name;
@@ -64,7 +94,6 @@ public abstract class Player {
return hp;
}
@Override
public int getMaxHP() {
return maxHP;
}
@@ -73,7 +102,6 @@ public abstract class Player {
return mp;
}
@Override
public int getMaxMP() {
return maxMP;
}
@@ -86,4 +114,8 @@ public abstract class Player {
return armor;
}
public boolean getIsDefending() {
return isDefending;
}
}
@@ -0,0 +1,43 @@
package org.project.entity.players;
import org.project.entity.Entity;
import org.project.Colors;
import org.project.item.armors.WizardArmor;
import org.project.item.weapons.wand;
import org.project.item.armors.WizardArmor;
import org.project.item.weapons.Weapon;
public class Wizard extends Player {
public Wizard(String name) {
super(name, new wand(), new WizardArmor());
}
@Override
public void SpecialAttack(Entity target, int time) {
if (time > 0) {
time--;
hp = 100;
mp -= 20;
System.out.println(Colors.PURPLE + "✨ SPECIAL ATTACK! ✨" + Colors.RESET);
System.out.println(Colors.PURPLE + "WHOOSH!" + Colors.RESET);
System.out.println("🔥 Recovery completed ");
}
}
@Override
public void heal() {
hp += 30;
if (hp > 100) {
hp = 100;
}
mp -= 10;
System.out.println(Colors.GREEN + "💊 HEAL! 💊" + Colors.RESET);
System.out.println(Colors.GREEN + " WHOOSH!" + Colors.RESET);
System.out.println(Colors.RED + " HP restored: + 30" + Colors.RESET);
}
}
@@ -1,11 +0,0 @@
package org.project.item;
import org.project.entity.Entity;
public interface Item {
void use(Entity target);
/*
TODO: ADD OTHER REQUIRED AND BONUS METHODS
*/
}
@@ -4,8 +4,8 @@ package org.project.item.armors;
public abstract class Armor {
private int defense;
private int maxDefense;
private int durability;
private int maxDurability;
protected int durability;
private final int maxDurability=100;
private boolean isBroke;
@@ -21,6 +21,22 @@ public abstract class Armor {
}
}
public void decreacDurability()
{
if(durability>30)
durability-=30;
else
{
durability=0;
checkBreak();
}
}
public void filldur()
{
durability=maxDurability;
}
// TODO: (BONUS) UPDATE THE REPAIR METHOD
public void repair() {
isBroke = false;
@@ -0,0 +1,9 @@
package org.project.item.armors;
public class AssassinArmor extends Armor {
public AssassinArmor()
{
super(10 , 100);
}
}
@@ -1,6 +1,21 @@
package org.project.item.armors;
// TODO: UPDATE IMPLEMENTATION
public class KnightArmor {
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
public class KnightArmor extends Armor{
public KnightArmor ()
{
super(15, 100);
}
@Override
public void decreacDurability()
{
if(durability>10)
durability-=10;
else
{
durability=0;
checkBreak();
}
}
}
@@ -0,0 +1,21 @@
package org.project.item.armors;
public class WizardArmor extends Armor{
public WizardArmor()
{
super(10 , 100);
}
@Override
public void decreacDurability()
{
if(durability>20)
durability-=20;
else
{
durability=0;
checkBreak();
}
}
}
@@ -1,16 +0,0 @@
package org.project.item.consumables;
import org.project.entity.Entity;
// TODO: UPDATE IMPLEMENTATION
public class Flask {
/*
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
*/
// TODO: UPDATE USE METHOD
@Override
public void use(Entity target) {
target.heal(target.getMaxHP() / 10);
}
}
@@ -4,23 +4,13 @@ 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 class Sword extends Weapon{
public Sword() {
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
super(30,50,10);
}
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
public void uniqueAbility(ArrayList<Entity> targets) {
abilityCharge += 2;
for (Entity target : targets) {
target.takeDamage(getDamage());
}
}
}
@@ -3,26 +3,29 @@ package org.project.item.weapons;
import org.project.entity.Entity;
// TODO: UPDATE IMPLEMENTATION
public abstract class Weapon {
private int damage;
public class Weapon {
private int LightDamage;
private int HeavyDamage;
private int manaCost;
/*
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
*/
public Weapon(int damage, int manaCost) {
this.damage = damage;
public Weapon(int LightDamage,int HeavyDamage, int manaCost) {
this.LightDamage = LightDamage;
this.HeavyDamage=HeavyDamage;
this.manaCost = manaCost;
}
@Override
public void use(Entity target) {
target.takeDamage(damage);
public int getLightDamage() {
return LightDamage;
}
public int getDamage() {
return damage;
public int getHeavyDamage()
{
return HeavyDamage;
}
public int getManaCost() {
@@ -0,0 +1,8 @@
package org.project.item.weapons;
public class machete extends Weapon{
public machete()
{
super(20,30,5);
}
}
@@ -0,0 +1,9 @@
package org.project.item.weapons;
public class wand extends Weapon{
public wand()
{
super(10,75,30);
}
}
@@ -1,28 +1,44 @@
package org.project.location;
import org.project.entity.enemies.Enemy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
public class Location {
private String name;
private ArrayList<String> locations;
private Random random;
ArrayList<Integer> key=new ArrayList<>();
private ArrayList<Enemy> enemies;
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
this.locations = locations;
this.enemies = enemies;
public Location() {
random = new Random();
locations = new ArrayList<>(Arrays.asList(
" Shire", " Rivendell", " Lothlórien",
" Gondor", " Mordor", " Isengard",
" Moria", " Minas Morgul", " Paths of the Dead"
));
for(int i=0; i<9; i++)
{
key.add(1);
}
}
public String getName() {
return name;
public Location(int i)
{
key.add(0);
}
public ArrayList<Location> getLocations() {
return locations;
public String chooseLocation() {
return locations.get(random.nextInt(locations.size()));
}
public ArrayList<Enemy> getEnemies() {
return enemies;
public boolean thereIsKey()
{
int i= random.nextInt(key.size()*2);
if (i<key.size() && key.get(i)==1) {
key.set(i,0);
return true;
}
else
return false;
}
}
Binary file not shown.
Binary file not shown.