26 Commits
Author SHA1 Message Date
Ramtin Jafari 821d27098c apply the final debugging 2026-07-17 18:27:51 +03:30
Ramtin a8d1b1011f add main menu 2026-07-16 17:00:12 +03:30
Ramtin dc963742aa enhance display method 2026-07-16 16:59:56 +03:30
Ramtin 76baf0f2cf fix accessory's bugs 2026-07-16 16:59:45 +03:30
Ramtin 879655f62e fix Assassin bug 2026-07-16 16:59:19 +03:30
Ramtin 6f39911a34 fix engines bugs 2026-07-16 16:59:03 +03:30
Ramtin 71f1f272f2 fix stamina modification bug 2026-07-15 17:24:18 +03:30
Ramtin a0a8626436 add copy methods to entities 2026-07-15 17:11:27 +03:30
Ramtin 3af890f4b5 complete engines 2026-07-15 16:08:24 +03:30
Ramtin c1a4456328 add git ignore 2026-07-15 16:04:00 +03:30
Ramtin a29997e733 fix ANSI colors bug 2026-07-15 16:03:39 +03:30
Ramtin da218c1134 enhance engines 2026-07-11 15:26:55 +03:30
Ramtin 2e71767311 add player roles 2026-07-11 15:26:37 +03:30
Ramtin 940b160a4e add util for showing items 2026-07-11 15:26:23 +03:30
Ramtin 6567c1cbbe add details to random location generator 2026-07-11 15:25:59 +03:30
Ramtin 1c5d53afc1 add game accessories 2026-07-11 15:25:34 +03:30
Ramtin 380e5fbca0 enhance Leveling process 2026-07-11 15:25:13 +03:30
Ramtin Jafari 5f1ffd2520 add engines 2026-07-11 11:35:08 +03:30
Ramtin Jafari cd1e244201 add system constants 2026-07-11 11:34:58 +03:30
Ramtin Jafari bd81d42a3b add locations 2026-07-11 11:33:37 +03:30
Ramtin 0afe5c8c69 add skeleton as an enemy 2026-07-09 14:38:34 +03:30
Ramtin dc3f2f53ca enhance entity state modes 2026-07-09 14:38:18 +03:30
Ramtin 498d455277 add enemy and enemy roles 2026-07-09 14:37:30 +03:30
Ramtin ddc2b8df73 simplify Player and Enemy classes 2026-07-08 17:20:19 +03:30
Ramtin ef6c2d3dd0 add player and player roles 2026-07-08 17:19:38 +03:30
Ramtin 7a4421e722 add weapon util interface 2026-07-08 16:27:58 +03:30
45 changed files with 2013 additions and 138 deletions
+1
View File
@@ -0,0 +1 @@
/Java-Knight/target/
@@ -3,6 +3,6 @@ package org.project.Interface;
import org.project.entity.Entity;
public interface IAttachable {
public void AttachTo(Entity entity);
public void DeattachFrom(Entity entity);
public void AttachTo(Entity entity, boolean fromInventory);
public void DeattachFrom(Entity entity, boolean toInventory);
}
@@ -0,0 +1,5 @@
package org.project.Interface;
public interface IDamageUtil {
public int GetDamage();
}
@@ -1,7 +1,9 @@
package org.project.Interface;
import org.project.constants.gameConstant.AttackPowerUp;
public interface IDamager {
public void Damage(IDamageable target);
public IDamager[] GetUtils();
public void Damage(IDamageable target, int amount, AttackPowerUp[] powerUps);
public IDamageUtil[] GetDamageUtils();
public int GetDamage();
}
@@ -0,0 +1,19 @@
package org.project.Interface;
import org.project.constants.gameConstant.FightMoves;
import org.project.entity.Entity;
import java.util.ArrayList;
public interface IFighter {
public void LightAttack(IDamageable target);
public void HeavyAttack(IDamageable target);
public void defend();
public void HealMove();
public void SpecialAbility(Entity entity);
public ArrayList<FightMoves> GetAvailableMoves();
public String GetSpecialAbilityDescription(Entity entity);
public String GetSpecialAbilityResultDescription(Entity entity);
}
@@ -1,15 +1,49 @@
package org.project;
import org.project.location.Location;
import org.project.constants.appConstants.GameModes;
import org.project.constants.appConstants.TextColor;
import org.project.engine.MainEngine;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO: ADD LOCATIONS TO YOUR GAME
List<Location> locations = new ArrayList<>();
static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
boolean endGame = false;
// TODO: IMPLEMENT GAMEPLAY
while (true) {
System.out.println(TextColor.Cyan + "JAVA KNIGHT" + TextColor.Reset);
System.out.println(
"""
0 > Single Player
1 > Local Multiplayer
2 > Exit
"""
);
GameModes gameMode = null;
while (true){
int choice = scanner.nextInt();
if (choice == 0) {
gameMode = GameModes.SINGLE_PLAYER;
break;
} else if (choice == 1) {
gameMode = GameModes.MULTI_PLAYER_LOCAL;
break;
} else if (choice == 2) {
endGame = true;
break;
}
}
if (endGame) {
break;
}
MainEngine engine = MainEngine.CreateEngine(gameMode);
engine.run();
}
}
}
@@ -0,0 +1,5 @@
package org.project.common.models;
public record EntityDiff(int health, int stamina, boolean lostShield, boolean lostCostume, int shieldHealth, int costumeHealth) {
}
@@ -0,0 +1,5 @@
package org.project.constants.appConstants;
public class ConsoleColor {
public static final String Reset = "\u001B[0m";
}
@@ -0,0 +1,6 @@
package org.project.constants.appConstants;
public enum GameModes {
SINGLE_PLAYER,
MULTI_PLAYER_LOCAL
}
@@ -0,0 +1,12 @@
package org.project.constants.appConstants;
public class TextColor extends ConsoleColor{
public static String Black = "\u001B[30m";
public static String Red = "\u001B[31m";
public static String Green = "\u001B[32m";
public static String Yellow = "\u001B[33m";
public static String Blue = "\u001B[34m";
public static String Magenta = "\u001B[35m";
public static String Cyan = "\u001B[36m";
public static String White = "\u001B[37m";
}
@@ -2,5 +2,7 @@ package org.project.constants.gameConstant;
public enum AttackPowerUp {
ANTI_SHIELD,
ANTI_CUSTOM
ANTI_CUSTOM,
NO_DEFENSE,
INEVITABLE,
}
@@ -0,0 +1,14 @@
package org.project.constants.gameConstant;
import org.project.item.Accessory.Costume;
public final class Costumes {
public static Costume cheapCostume = new Costume("cheap costume", null, 40, 100, 100, 10);
public static Costume SteelCostume = new Costume("steel costume", null, 150, 300, 300, 30);
public static Costume GoldenCostume = new Costume("golden costume", null, 500, 500, 500, 100);
public static Costume MasterCostume = new Costume("master costume", null, 1500, 1000, 1000, 300);
public static Costume[] getCostumes() {
return new Costume[]{cheapCostume, SteelCostume, GoldenCostume, MasterCostume};
}
}
@@ -0,0 +1,5 @@
package org.project.constants.gameConstant;
public enum DefencePowerUp {
INVISIBLE,
}
@@ -2,6 +2,7 @@ package org.project.constants.gameConstant;
public enum EntityState {
ALIVE,
DOWNED,
DEAD,
FROZEN
}
@@ -0,0 +1,9 @@
package org.project.constants.gameConstant;
public enum FightMoves {
LIGHT_ATTACK,
HEAVY_ATTACK,
HEAL,
DEFEND,
SPECIAL
}
@@ -0,0 +1,7 @@
package org.project.constants.gameConstant;
public enum PlayerRoles {
KNIGHT,
WIZARD,
ASSASSIN
}
@@ -0,0 +1,26 @@
package org.project.constants.gameConstant;
import org.project.entity.players.Assassin;
import org.project.entity.players.Knight;
import org.project.entity.players.Player;
import org.project.entity.players.Wizard;
public final class PlayerRolesExt {
private PlayerRolesExt() {}
public static Player CreatePlayer(PlayerRoles role, String name, int level) {
return switch (role) {
case KNIGHT -> new Knight(name, level);
case ASSASSIN -> new Assassin(name, level);
case WIZARD -> new Wizard(name, level);
};
}
public static Player CreatePlayer(PlayerRoles role, String name) {
return switch (role) {
case KNIGHT -> new Knight(name);
case ASSASSIN -> new Assassin(name);
case WIZARD -> new Wizard(name);
};
}
}
@@ -0,0 +1,14 @@
package org.project.constants.gameConstant;
import org.project.item.Accessory.Shield;
public final class Shields {
public static Shield WoodenShield = new Shield("wooden shield", null, 40, 100, 100, 10);
public static Shield SteelShield = new Shield("steel shield", null, 150, 300, 300, 30);
public static Shield GoldenShield = new Shield("golden shield", null, 500, 500, 500, 100);
public static Shield MasterShield = new Shield("master shield", null, 1500, 1000, 1000, 300);
public static Shield[] getShields() {
return new Shield[]{WoodenShield, SteelShield, GoldenShield, MasterShield};
}
}
@@ -0,0 +1,14 @@
package org.project.constants.gameConstant;
import org.project.item.Accessory.Weapon;
public final class Weapons {
public static Weapon Dagger = new Weapon("dagger", null, 40, 100, 100, 10);
public static Weapon SteelSword = new Weapon("steel sword", null, 150, 100, 100, 30);
public static Weapon GoldenSword = new Weapon("golden sword", null, 500, 100, 100, 100);
public static Weapon MasterSword = new Weapon("master sword", null, 1500, 100, 100, 300);
public static Weapon[] getWeapons() {
return new Weapon[] {Dagger, SteelSword, GoldenSword, MasterSword};
}
}
@@ -0,0 +1,19 @@
package org.project.engine;
import org.project.entity.Entity;
public abstract class BattleEngine {
public Entity Player1;
public Entity Player2;
public BattleEngine(Entity player1, Entity player2) {
player1.ResetStamina();
player1.RestoreHealth();
player2.RestoreHealth();
player2.ResetStamina();
Player1 = player1;
Player2 = player2;
}
public abstract void StartBattle();
}
@@ -0,0 +1,55 @@
package org.project.engine;
import org.project.constants.appConstants.GameModes;
import org.project.constants.gameConstant.PlayerRoles;
import org.project.constants.gameConstant.PlayerRolesExt;
import org.project.entity.players.Player;
import java.util.Scanner;
public abstract class MainEngine {
protected MainEngine() {}
public abstract void run();
public static MainEngine CreateEngine(GameModes mode) {
return switch (mode) {
case GameModes.SINGLE_PLAYER -> new SinglePlayerEngine();
case GameModes.MULTI_PLAYER_LOCAL -> new MultiplayerEngine();
};
}
protected Player RoleMenu(String name, int level) {
Scanner scanner = new Scanner(System.in);
PlayerRoles[] roles = PlayerRoles.values();
int index = 0;
while (true) {
for (PlayerRoles role : roles) {
System.out.println(index + " > " + role.name().toLowerCase());
index++;
}
int choice = scanner.nextInt();
if (choice >= 0 && choice < roles.length) {
return PlayerRolesExt.CreatePlayer(roles[choice], name, level);
}
}
}
protected Player RoleMenu(String name) {
Scanner scanner = new Scanner(System.in);
PlayerRoles[] roles = PlayerRoles.values();
int index = 0;
while (true) {
for (PlayerRoles role : roles) {
System.out.println(index + " > " + role.name().toLowerCase());
index++;
}
int choice = scanner.nextInt();
if (choice >= 0 && choice < roles.length) {
return PlayerRolesExt.CreatePlayer(roles[choice], name);
}
}
}
}
@@ -0,0 +1,186 @@
package org.project.engine;
import org.project.common.models.EntityDiff;
import org.project.constants.appConstants.TextColor;
import org.project.constants.gameConstant.EntityState;
import org.project.constants.gameConstant.FightMoves;
import org.project.entity.Entity;
import org.project.entity.players.Player;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Scanner;
public class MultiPlayerBattleEngine extends BattleEngine {
private final Player player1;
private final Player player2;
private Player player1Past;
private Player player2Past;
public MultiPlayerBattleEngine(Player player1, Player player2) {
super(player1, player2);
this.player1 = (Player) Player1;
this.player2 = (Player) Player2;
player1Past = player1.copy();
player2Past = player2.copy();
}
@Override
public void StartBattle() {
EntityDiff playerDiff;
EntityDiff enemyDiff;
while (true) {
if (player1.GetState() != EntityState.FROZEN) {
FightMoves player1Move = PlayerMovesMenu(player1, player2);
showMoveExplanation(player1Move, player1, player2Past);
playerDiff = getPlayerDiff(player1Past, player1);
enemyDiff = getPlayerDiff(player2Past, player2);
System.out.println();
showFighter(playerDiff, player1);
showFighter(enemyDiff, player2);
System.out.println();
}
if (player1.GetState() == EntityState.DEAD) {
System.out.println(TextColor.Green + player2.Name + " WON!" + TextColor.Reset);
return;
}
if (player1Past.GetState() == EntityState.FROZEN) {
player1.SetState(EntityState.ALIVE);
}
player1Past = player1.copy();
player2Past = player2.copy();
if (player2.GetState() != EntityState.FROZEN)
{
FightMoves player2Move = PlayerMovesMenu(player2, player1);
showMoveExplanation(player2Move, player2, player1Past);
playerDiff = getPlayerDiff(player1Past, player1);
enemyDiff = getPlayerDiff(player2Past, player2);
System.out.println();
showFighter(playerDiff, player1);
showFighter(enemyDiff, player2);
System.out.println();
}
if (player2.GetState() == EntityState.DEAD) {
System.out.println(TextColor.Green + player1.Name + " WON!" + TextColor.Reset);
return;
}
if (player2Past.GetState() == EntityState.FROZEN) {
player2.SetState(EntityState.ALIVE);
}
player1Past = player1.copy();
player2Past = player2.copy();
}
}
private EntityDiff getPlayerDiff(Entity oldVersion, Entity newVersion) {
return new EntityDiff(
newVersion.Health - oldVersion.Health,
newVersion.GetStamina() - oldVersion.GetStamina(),
(newVersion.Shield == null && oldVersion.Shield != null),
(newVersion.Weapon == null && oldVersion.Weapon != null),
(newVersion.Shield != null ? newVersion.Shield.GetHealth() : 0) - (oldVersion.Shield != null ? oldVersion.Shield.GetHealth() : 0),
(newVersion.Costume != null ? newVersion.Costume.GetHealth() : 0) - (oldVersion.Costume != null ? oldVersion.Costume.GetHealth() : 0)
);
}
private void showFighter(EntityDiff diff, Entity entity) {
System.out.println(entity.Name + ":");
String color = diff.health() > 0 ? TextColor.Green : TextColor.Red;
String sign = diff.health() > 0 ? "+" : "-";
System.out.println(" Health: " + entity.Health + " " + color + sign + Math.abs(diff.health()) + TextColor.Reset);
color = diff.stamina() > 0 ? TextColor.Green : TextColor.Red;
sign = diff.stamina() > 0 ? "+" : "-";
System.out.println(" Stamina: " + entity.GetStamina() + " " + color + sign + Math.abs(diff.stamina()) + TextColor.Reset);
if (diff.lostShield()) {
System.out.println(" Shield: " + entity.Shield.getName() + " " + TextColor.Red + "LOST" + TextColor.Reset);
}
if (diff.lostCostume()) {
System.out.println(" Costume: " + entity.Costume.getName() + " " + TextColor.Red + "LOST" + TextColor.Reset);
}
if (entity.Shield != null) {
color = diff.shieldHealth() > 0 ? TextColor.Green : TextColor.Red;
sign = diff.shieldHealth() > 0 ? "+" : "-";
System.out.println(" Shield: " + entity.Shield.getName() + " " + color + sign + Math.abs(diff.shieldHealth()) + TextColor.Reset);
}
if (entity.Costume != null) {
color = diff.costumeHealth() > 0 ? TextColor.Green : TextColor.Red;
sign = diff.costumeHealth() > 0 ? "+" : "-";
System.out.println(" Costume: " + entity.Costume.getName() + " " + color + sign + Math.abs(diff.shieldHealth()) + TextColor.Reset);
}
}
private FightMoves PlayerMovesMenu(Player performer, Player receiver) {
Scanner scanner = new Scanner(System.in);
System.out.println(performer.Name + " it's your turn");
ArrayList<FightMoves> moves = performer.GetAvailableMoves();
int index = 0;
Dictionary<Integer, FightMoves> dictionary = new Hashtable<>();
for (FightMoves move : moves) {
String result = index + " > " + move.toString();
if (move == FightMoves.SPECIAL) {
result += " (" + performer.GetSpecialAbilityDescription(receiver) + ")";
}
dictionary.put(index, move);
index++;
System.out.println(result);
}
boolean continueLoop;
while (true){
continueLoop = false;
int choice = scanner.nextInt();
FightMoves move = moves.get(choice);
switch (move) {
case FightMoves.LIGHT_ATTACK -> performer.LightAttack(receiver);
case FightMoves.HEAVY_ATTACK -> performer.HeavyAttack(receiver);
case FightMoves.SPECIAL -> performer.SpecialAbility(receiver);
case FightMoves.HEAL -> performer.HealMove();
case FightMoves.DEFEND -> performer.defend();
default -> continueLoop = true;
}
if (!continueLoop) {
return move;
}
}
}
private void showMoveExplanation(FightMoves move, Entity performer, Entity receiver) {
System.out.print(TextColor.Cyan);
switch (move) {
case FightMoves.LIGHT_ATTACK -> System.out.println(performer.Name + " performs a light attack");
case FightMoves.HEAVY_ATTACK -> System.out.println(performer.Name + " performs a heavy attack");
case FightMoves.SPECIAL -> System.out.println(performer.GetSpecialAbilityResultDescription(receiver));
case FightMoves.HEAL -> System.out.println(performer.Name + " heals");
case FightMoves.DEFEND -> System.out.println(performer.Name + " get their guard up!");
}
System.out.print(TextColor.Reset);
}
}
@@ -0,0 +1,39 @@
package org.project.engine;
import org.project.constants.appConstants.TextColor;
import org.project.entity.players.Player;
import java.util.Scanner;
public class MultiplayerEngine extends MainEngine {
public MultiplayerEngine() {
super();
}
@Override
public void run() {
Scanner scanner = new Scanner(System.in);
System.out.println("Player 1, Set your name:");
String player1Name = scanner.nextLine();
System.out.println("Player 2, Set your name:");
String player2Name = scanner.nextLine();
System.out.println(player1Name + ", Set the level of your character:");
int player1Level = scanner.nextInt();
System.out.println(player2Name + ", Set the level of your character:");
int player2Level = scanner.nextInt();
System.out.println(player1Name + ", Set the role of your character:");
Player player1 = RoleMenu(player1Name, player1Level);
System.out.println(player2Name + ", Set the role of your character:");
Player player2 = RoleMenu(player2Name, player2Level);
System.out.println(TextColor.Red + "Now the battle begins" + TextColor.Reset);
BattleEngine engine = new MultiPlayerBattleEngine(player1, player2);
engine.StartBattle();
}
}
@@ -0,0 +1,185 @@
package org.project.engine;
import org.project.common.models.EntityDiff;
import org.project.constants.appConstants.TextColor;
import org.project.constants.gameConstant.EntityState;
import org.project.constants.gameConstant.FightMoves;
import org.project.entity.Entity;
import org.project.entity.enemies.Enemy;
import org.project.entity.players.Player;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Scanner;
public class SinglePlayerBattleEngine extends BattleEngine {
private final Player player;
private final Enemy enemy;
private Player playerPast;
private Enemy enemyPast;
public SinglePlayerBattleEngine(Player player, Enemy enemy) {
super(player, enemy);
this.player = (Player) Player1;
this.enemy = (Enemy) Player2;
playerPast = player.copy();
enemyPast = enemy.copy();
}
@Override
public void StartBattle() {
EntityDiff playerDiff;
EntityDiff enemyDiff;
while (true) {
if (player.GetState() != EntityState.FROZEN) {
FightMoves playerMove = PlayerMovesMenu();
showMoveExplanation(playerMove, player, enemyPast);
playerDiff = getPlayerDiff(playerPast, player);
enemyDiff = getPlayerDiff(enemyPast, enemy);
System.out.println();
showFighter(playerDiff, player);
showFighter(enemyDiff, enemy);
System.out.println();
}
if (playerPast.GetState() == EntityState.FROZEN) {
player.SetState(EntityState.ALIVE);
}
if (enemy.GetState() == EntityState.DEAD) {
enemy.DropLoot(player);
player.AddLevelProgress(enemy.LevelProgressAmount);
System.out.println(TextColor.Green + player.Name + " WON!" + TextColor.Reset);
return;
}
playerPast = player.copy();
enemyPast = enemy.copy();
if (enemy.GetState() != EntityState.FROZEN) {
FightMoves botMove = enemy.PlayRound(player);
showMoveExplanation(botMove, enemy, playerPast);
playerDiff = getPlayerDiff(playerPast, player);
enemyDiff = getPlayerDiff(enemyPast, enemy);
System.out.println();
showFighter(playerDiff, player);
showFighter(enemyDiff, enemy);
System.out.println();
}
if (player.GetState() == EntityState.DEAD) {
return;
}
if (enemyPast.GetState() == EntityState.FROZEN) {
enemy.SetState(EntityState.ALIVE);
}
playerPast = player.copy();
enemyPast = enemy.copy();
}
}
private EntityDiff getPlayerDiff(Entity oldVersion, Entity newVersion) {
return new EntityDiff(
newVersion.Health - oldVersion.Health,
newVersion.GetStamina() - oldVersion.GetStamina(),
(newVersion.Shield == null && oldVersion.Shield != null),
(newVersion.Weapon == null && oldVersion.Weapon != null),
(newVersion.Shield != null ? newVersion.Shield.GetHealth() : 0) - (oldVersion.Shield != null ? oldVersion.Shield.GetHealth() : 0),
(newVersion.Costume != null ? newVersion.Costume.GetHealth() : 0) - (oldVersion.Costume != null ? oldVersion.Costume.GetHealth() : 0)
);
}
private void showFighter(EntityDiff diff, Entity entity) {
System.out.println(entity.Name + ":");
String color = diff.health() > 0 ? TextColor.Green : TextColor.Red;
String sign = diff.health() > 0 ? "+" : "-";
System.out.println(" Health: " + entity.Health + " " + color + sign + Math.abs(diff.health()) + TextColor.Reset);
color = diff.stamina() > 0 ? TextColor.Green : TextColor.Red;
sign = diff.stamina() > 0 ? "+" : "-";
System.out.println(" Stamina: " + entity.GetStamina() + " " + color + sign + Math.abs(diff.stamina()) + TextColor.Reset);
if (diff.lostShield()) {
System.out.println(" Shield: " + entity.Shield.getName() + " " + TextColor.Red + "LOST" + TextColor.Reset);
}
if (diff.lostCostume()) {
System.out.println(" Costume: " + entity.Costume.getName() + " " + TextColor.Red + "LOST" + TextColor.Reset);
}
if (entity.Shield != null) {
color = diff.shieldHealth() > 0 ? TextColor.Green : TextColor.Red;
sign = diff.shieldHealth() > 0 ? "+" : "-";
System.out.println(" Shield: " + entity.Shield.getName() + " " + color + sign + Math.abs(diff.shieldHealth()) + TextColor.Reset);
}
if (entity.Costume != null) {
color = diff.costumeHealth() > 0 ? TextColor.Green : TextColor.Red;
sign = diff.costumeHealth() > 0 ? "+" : "-";
System.out.println(" Costume: " + entity.Costume.getName() + " " + color + sign + Math.abs(diff.shieldHealth()) + TextColor.Reset);
}
}
private FightMoves PlayerMovesMenu() {
Scanner scanner = new Scanner(System.in);
System.out.println(player.Name + " it's your turn");
ArrayList<FightMoves> moves = player.GetAvailableMoves();
int index = 0;
Dictionary<Integer, FightMoves> dictionary = new Hashtable<>();
for (FightMoves move : moves) {
String result = index + " > " + move.toString();
if (move == FightMoves.SPECIAL) {
result += " (" + player.GetSpecialAbilityDescription(enemy) + ")";
}
dictionary.put(index, move);
index++;
System.out.println(result);
}
boolean continueLoop;
while (true){
continueLoop = false;
int choice = scanner.nextInt();
FightMoves move = moves.get(choice);
switch (move) {
case FightMoves.LIGHT_ATTACK -> player.LightAttack(enemy);
case FightMoves.HEAVY_ATTACK -> player.HeavyAttack(enemy);
case FightMoves.SPECIAL -> player.SpecialAbility(enemy);
case FightMoves.HEAL -> player.HealMove();
case FightMoves.DEFEND -> player.defend();
default -> continueLoop = true;
}
if (!continueLoop) {
return move;
}
}
}
private void showMoveExplanation(FightMoves move, Entity performer, Entity receiver) {
System.out.print(TextColor.Cyan);
switch (move) {
case FightMoves.LIGHT_ATTACK -> System.out.println(performer.Name + " performs a light attack");
case FightMoves.HEAVY_ATTACK -> System.out.println(performer.Name + " performs a heavy attack");
case FightMoves.SPECIAL -> System.out.println(performer.GetSpecialAbilityResultDescription(receiver));
case FightMoves.HEAL -> System.out.println(performer.Name + " heals");
case FightMoves.DEFEND -> System.out.println(performer.Name + " get their guard up!");
}
System.out.print(TextColor.Reset);
}
}
@@ -0,0 +1,375 @@
package org.project.engine;
import org.project.constants.appConstants.ConsoleColor;
import org.project.constants.appConstants.TextColor;
import org.project.constants.gameConstant.*;
import org.project.entity.players.Player;
import org.project.item.Accessory.Accessory;
import org.project.item.Accessory.Shield;
import org.project.item.Item;
import org.project.location.*;
import org.project.util.DisplayItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Dictionary;
import java.util.Scanner;
public class SinglePlayerEngine extends MainEngine {
private Player player;
public SinglePlayerEngine() {
super();
}
@Override
public void run() {
Scanner scanner = new Scanner(System.in);
System.out.println(TextColor.Cyan + GetIntro() + ConsoleColor.Reset);
System.out.println();
System.out.println("How should we call you, hero? ");
String name = scanner.nextLine();
System.out.println("Greetings, " + TextColor.Cyan + name + TextColor.Reset +". May we know your role? \n");
player = RoleMenu(name);
System.out.println("Very well, " + TextColor.Cyan + player.Name + ConsoleColor.Reset + " your journey begins!");
System.out.println();
while (true) {
boolean canFightDragon = player.GetInventoryByClass(ItemClass.KEY).size() == 3;
Location location = Location.RandomLocation();
boolean continueLoop = false;
do {
System.out.println(TextColor.Cyan + GetLocationIntro(location) + TextColor.Reset);
System.out.println("What do you do, " + player.Name + "?");
System.out.println(
"""
0 > FIGHT!
1 > Go to the next location
2 > Visit the market place in the town
3 > Check inventory"""
);
if (canFightDragon) {
System.out.println("4 > Go to the castle to face the dragon");
}
int choice = scanner.nextInt();
switch (choice) {
case 0 -> {
System.out.println(TextColor.Red + "You choice to FIGHT!" + TextColor.Reset);
BattleEngine engine = new SinglePlayerBattleEngine(player, location.enemy);
engine.StartBattle();
continueLoop = false;
}
case 1 -> {
continueLoop = false;
}
case 2 -> {
MarketPlace();
continueLoop = false;
}
case 3 -> {
InventoryView();
continueLoop = true;
}
case 4 -> {
if (canFightDragon) {
location = new Castle();
continueLoop = false;
}
else {
continueLoop = true;
}
}
default -> continueLoop = true;
}
} while (continueLoop);
if (player.GetState() == EntityState.DEAD) {
System.out.println(TextColor.Red + "Game Over!" + TextColor.Reset);
break;
}
if (player.GetInventoryByClass(ItemClass.KEY).size() == 4) {
System.out.println(TextColor.Blue + "You WON! You saved Javanest!" + TextColor.Reset);
break;
}
}
}
public String GetIntro() {
return "For centuries, the land of Javanest lived in peace, until a magical Dragon attacked, plunging the realm into absolute darkness. With a wicked curse, the Dragon transformed the innocent people into horrific monsters: Goblins, Skeletons, and Vampires. Retreating to its impenetrable Castle, the Dragon divided the three keys to its lair and hid them among these cursed creatures. Now, it is your duty to step up and save the land. You must battle these monsters, recover the unique key from each monster type, and finally slay the Dragon to break the curse and restore peace to Javanest!";
}
public String GetLocationIntro(Location location) {
return switch (location) {
case Jungle jungle ->
player.Name + " enters the woods, after a few steps, they see a green goblin searching for food a few steps away";
case GraveYard graveYard ->
player.Name + " goes inside the grave ward, they cannot see further than 10 steps ahead because of the fog in the air. After lurking through out the graves, the shadow appears... It's a skeleton!";
case DarkCaves darkCaves ->
player.Name + " dives into the darkness. As our hero was going deeper, a black smoke appears, a vampire is nearby...";
case Castle castle ->
player.Name + " Goes through the gates, the dragon looks at " + player.Name + "... It knows that an epic battle awaits both it them";
case null, default -> "";
};
}
public void MarketPlace() {
Scanner scanner = new Scanner(System.in);
System.out.println(TextColor.Cyan + "You've entered the marketplace, what would you like to do?" + TextColor.Reset);
boolean wantsToStay = true;
while (wantsToStay) {
System.out.println("Money = " + player.GetMoney() + "\n");
System.out.println("""
0 > Show Inventory
1 > Sell Unnecessary goods
2 > Sell the accessories
3 > Sell the shields
4 > Sell the costumes
5 > Sell the Weapons
6 > Buy shields
7 > Buy weapon
8 > Buy costume
9 > Exit
""");
int choice = scanner.nextInt();
switch (choice) {
case 0 -> {
if (player.GetInventory().isEmpty()) {
System.out.println(TextColor.Red + "You do not have anything at the moment" + TextColor.Reset);
break;
}
DisplayItem.DisplayItems(player.GetInventory());
}
case 1 -> {
player.SellByClass(ItemClass.UNNECESSARY);
System.out.println(TextColor.Green + "Unnecessary goods sold" + TextColor.Reset);
}
case 2 -> {
player.SellByClass(ItemClass.ACCESSORY);
System.out.println(TextColor.Green + "accessories sold" + TextColor.Reset);
}
case 3 -> {
player.SellByClass(ItemClass.SHIELD);
System.out.println(TextColor.Green + "shields sold" + TextColor.Reset);
}
case 4 -> {
player.SellByClass(ItemClass.COSTUME);
System.out.println(TextColor.Green + "costumes sold" + TextColor.Reset);
}
case 5 -> {
player.SellByClass(ItemClass.WEAPON);
System.out.println(TextColor.Green + "weapons sold" + TextColor.Reset);
}
case 6 -> {
System.out.println("Money = " + player.GetMoney() + "\n");
System.out.println(TextColor.Blue + "Current shield: ");
ArrayList<Item> item = new ArrayList<>();
if (player.Shield == null) {
System.out.println(TextColor.Red + "You do not have a Shield" + TextColor.Reset);
}
else {
item.add(player.Shield);
DisplayItem.DisplayItems(item);
}
System.out.println(TextColor.Reset);
ArrayList<Item> items = new ArrayList<>(Arrays.asList(Shields.getShields()));
Dictionary<Integer, Item> dictionary = DisplayItem.MenuDisplay(items);
System.out.println("Please set the number of the accessory you want to buy, set any other number to abort:");
Integer index = scanner.nextInt();
Item shield = dictionary.get(index);
Accessory accessory = (Accessory) shield;
if (accessory != null) {
if (player.GetMoney() >= accessory.GetPrice()) {
if (player.Shield != null) player.Shield.DeattachFrom(player, true);
accessory.AttachTo(player, false);
player.ModifyMoney(accessory.GetPrice(), false);
}
else {
System.out.println(TextColor.Red + "You do not have enough money" + TextColor.Reset);
}
}
}
case 7 -> {
System.out.println("Money = " + player.GetMoney() + "\n");
System.out.println(TextColor.Blue + "Current weapon: ");
ArrayList<Item> item = new ArrayList<>();
if (player.Weapon == null) {
System.out.println(TextColor.Red + "You do not have a Weapon" + TextColor.Reset);
}
else {
item.add(player.Weapon);
DisplayItem.DisplayItems(item);
}
System.out.println(TextColor.Reset);
ArrayList<Item> items = new ArrayList<>(Arrays.asList(Weapons.getWeapons()));
Dictionary<Integer, Item> dictionary = DisplayItem.MenuDisplay(items);
System.out.println("Please set the number of the accessory you want to buy, set any other number to abort:");
Integer index = scanner.nextInt();
Item weapon = dictionary.get(index);
Accessory accessory = (Accessory) weapon;
if (accessory != null) {
if (player.GetMoney() >= accessory.GetPrice()) {
if (player.Weapon != null) player.Weapon.DeattachFrom(player, true);
accessory.AttachTo(player, false);
player.ModifyMoney(accessory.GetPrice(), false);
}
else {
System.out.println(TextColor.Red + "You do not have enough money" + TextColor.Reset);
}
}
}
case 8 -> {
System.out.println("Money = " + player.GetMoney() + "\n");
System.out.println(TextColor.Blue + "Current costume: ");
ArrayList<Item> item = new ArrayList<>();
if (player.Costume == null) {
System.out.println(TextColor.Red + "You do not have a Costume" + TextColor.Reset);
}
else {
item.add(player.Costume);
DisplayItem.DisplayItems(item);
}
System.out.println(TextColor.Reset);
ArrayList<Item> items = new ArrayList<>(Arrays.asList(Costumes.getCostumes()));
Dictionary<Integer, Item> dictionary = DisplayItem.MenuDisplay(items);
System.out.println("Please set the number of the accessory you want to buy, set any other number to abort:");
Integer index = scanner.nextInt();
Item costume = dictionary.get(index);
Accessory accessory = (Accessory) costume;
if (accessory != null) {
if (player.GetMoney() >= accessory.GetPrice()) {
if (player.Costume != null) player.Costume.DeattachFrom(player, true);
accessory.AttachTo(player, false);
player.ModifyMoney(accessory.GetPrice(), false);
}
else {
System.out.println(TextColor.Red + "You do not have enough money" + TextColor.Reset);
}
}
}
case 9 -> wantsToStay = false;
}
}
}
public void InventoryView() {
Scanner scanner = new Scanner(System.in);
System.out.println(TextColor.Cyan + "You open your inventory, what would you like to do?\n" + TextColor.Reset);
boolean wantsToStay = true;
while (wantsToStay) {
System.out.println("Money = " + player.GetMoney() + "\n");
System.out.println("""
0 > Show Inventory
1 > Show Shields
2 > Show Weapons
3 > Show Costumes
4 > Exit
""");
int choice = scanner.nextInt();
switch (choice) {
case 0 -> {
if (player.GetInventory().isEmpty()) {
System.out.println(TextColor.Red + "You do not have anything at the moment" + TextColor.Reset);
break;
}
DisplayItem.DisplayItems(player.GetInventory());
}
case 1 -> {
System.out.println(TextColor.Blue + "Current shield: ");
ArrayList<Item> item = new ArrayList<>();
if (player.Shield == null) {
System.out.println(TextColor.Red + "You do not have a Shield" + TextColor.Reset);
break;
}
item.add(player.Shield);
DisplayItem.DisplayItems(item);
System.out.println(TextColor.Reset);
Dictionary<Integer, Item> dictionary = DisplayItem.MenuDisplay(player.GetInventoryByClass(ItemClass.SHIELD));
System.out.println("Please set the number of the accessory you want to wear, set any other number to abort:");
Integer index = scanner.nextInt();
Item shield = dictionary.get(index);
if (shield != null) {
if (player.Shield != null) player.Shield.DeattachFrom(player, true);
((Accessory) shield).AttachTo(player, true);
}
}
case 2 -> {
System.out.println(TextColor.Blue + "Current weapon: ");
ArrayList<Item> item = new ArrayList<>();
if (player.Weapon == null) {
System.out.println(TextColor.Red + "You do not have a Weapon" + TextColor.Reset);
break;
}
item.add(player.Weapon);
DisplayItem.DisplayItems(item);
System.out.println(TextColor.Reset);
Dictionary<Integer, Item> dictionary = DisplayItem.MenuDisplay(player.GetInventoryByClass(ItemClass.WEAPON));
System.out.println("Please set the number of the accessory you want to wear, set any other number to abort:");
Integer index = scanner.nextInt();
Item weapon = dictionary.get(index);
if (weapon != null) {
if (player.Weapon != null) player.Weapon.DeattachFrom(player, true);
((Accessory) weapon).AttachTo(player, true);
}
}
case 3 -> {
System.out.println(TextColor.Blue + "Current costume: ");
ArrayList<Item> item = new ArrayList<>();
if (player.Costume == null) {
System.out.println(TextColor.Red + "You do not have a Costume" + TextColor.Reset);
break;
}
item.add(player.Costume);
DisplayItem.DisplayItems(item);
System.out.println(TextColor.Reset);
Dictionary<Integer, Item> dictionary = DisplayItem.MenuDisplay(player.GetInventoryByClass(ItemClass.COSTUME));
System.out.println("Please set the number of the accessory you want to wear, set any other number to abort:");
Integer index = scanner.nextInt();
Item costume = dictionary.get(index);
if (costume != null) {
if (player.Costume != null) player.Costume.DeattachFrom(player, true);
((Accessory) costume).AttachTo(player, true);
}
}
case 4 -> wantsToStay = false;
}
}
}
}
@@ -1,13 +1,7 @@
package org.project.entity;
import org.project.Interface.IDamageable;
import org.project.Interface.IDefendable;
import org.project.Interface.IDefender;
import org.project.Interface.IHealable;
import org.project.constants.gameConstant.AttackPowerUp;
import org.project.constants.gameConstant.EntityState;
import org.project.constants.gameConstant.ItemClass;
import org.project.constants.gameConstant.ItemClassExt;
import org.project.Interface.*;
import org.project.constants.gameConstant.*;
import org.project.item.Accessory.Costume;
import org.project.item.Accessory.Shield;
import org.project.item.Accessory.Weapon;
@@ -15,22 +9,124 @@ import org.project.item.Item;
import org.project.item.SellableItem;
import java.util.ArrayList;
import java.util.Arrays;
public abstract class Entity implements IDamageable, IHealable, IDefendable {
public abstract class Entity implements IDamageable, IHealable, IDefendable, IFighter, IDamager {
public String Name;
public int MaxHealth;
public int Health;
private int Stamina;
protected int MaxStamina;
private long Money;
private int BaseDamage;
protected int BaseDamage;
private EntityState State;
public Weapon Weapon;
public Shield Shield;
public Costume Costume;
public ArrayList<Item> Inventory;
protected int DefenseBonus;
public boolean IsDefending;
public ArrayList<DefencePowerUp> defencePowerUps;
protected int HealAmount;
protected int HeavyAttackStamina;
protected int SpecialAbilityStamina;
public Entity(String name, int maxHealth, int health, int stamina, int maxStamina, long money, int baseDamage, EntityState state, Weapon weapon,
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending, int healAmount) {
Name = name;
MaxHealth = maxHealth;
Health = health;
Stamina = stamina;
MaxStamina = maxStamina;
Money = money;
BaseDamage = baseDamage;
State = state;
Weapon = weapon;
Shield = shield;
Costume = costume;
Inventory = inventory;
DefenseBonus = defenseBonus;
IsDefending = isDefending;
HealAmount = healAmount;
HeavyAttackStamina = 50;
SpecialAbilityStamina = 100;
}
protected Entity() {}
public Entity(Entity other) {
this.Name = other.Name;
this.MaxHealth = other.MaxHealth;
this.Health = other.Health;
this.Stamina = other.Stamina;
this.MaxStamina = other.MaxStamina;
this.Money = other.Money;
this.BaseDamage = other.BaseDamage;
this.State = other.State;
this.Weapon = other.Weapon == null ? null : new Weapon(other.Weapon.getName(), this, other.Weapon.GetPrice(), other.Weapon.GetHealth(), other.Weapon.GetMaxHealth(), other.Weapon.GetDamage());
this.Shield = other.Shield == null ? null : new Shield(other.Shield.getName(), this, other.Shield.GetPrice(), other.Shield.GetHealth(), other.Shield.GetMaxHealth(), other.Shield.GetDefense());
this.Costume = other.Costume == null ? null : new Costume(other.Costume.getName(), this, other.Costume.GetPrice(), other.Costume.GetHealth(), other.Costume.GetMaxHealth(), other.Costume.GetDefense());
this.Inventory = other.Inventory == null ? null : new ArrayList<>(other.Inventory);
this.defencePowerUps = other.defencePowerUps == null ? null : new ArrayList<>(other.defencePowerUps);
this.DefenseBonus = other.DefenseBonus;
this.IsDefending = other.IsDefending;
this.HealAmount = other.HealAmount;
this.HeavyAttackStamina = other.HeavyAttackStamina;
this.SpecialAbilityStamina = other.SpecialAbilityStamina;
}
public abstract Entity copy();
public int GetStamina() { return Stamina; }
public void ResetStamina() { Stamina = MaxStamina; }
public void ModifyStamina(int amount, boolean dir) {
if (dir) {
Stamina += amount;
if (Stamina > MaxStamina) {
Stamina = MaxStamina;
}
}
else {
Stamina -= amount;
if (Stamina < 0) {
Stamina = 0;
}
}
}
public EntityState GetState() { return State; }
public int GetBaseDamage() { return BaseDamage; }
@Override
public int GetDamage() {
int damage = BaseDamage;
IDamageUtil[] utils = GetDamageUtils();
for (IDamageUtil util : utils) {
if (util != null) {
damage += util.GetDamage();
}
}
return damage;
}
@Override
public IDamageUtil[] GetDamageUtils() {
return new IDamageUtil[] {Weapon};
}
@Override
public void Damage(IDamageable target, int amount, AttackPowerUp[] powerUps) {
target.TakeDamage(amount, powerUps);
}
public long GetMoney() { return Money; }
@@ -48,6 +144,10 @@ public abstract class Entity implements IDamageable, IHealable, IDefendable {
return result;
}
public void SetState(EntityState state) {
State = state;
}
public void ModifyMoney(long amount, boolean dir) {
if (dir) {
Money += amount;
@@ -73,15 +173,28 @@ public abstract class Entity implements IDamageable, IHealable, IDefendable {
@Override
public void TakeDamage(int amount, AttackPowerUp[] powerUps) {
if (defencePowerUps != null && !defencePowerUps.contains(DefencePowerUp.INVISIBLE)) return;
IDefender[] defenders = GetDefenders();
for (IDefender defender : defenders) {
if (defender != null) {
amount = defender.Apply(amount, powerUps);
if (Arrays.binarySearch(powerUps, AttackPowerUp.INEVITABLE) < 0) {
for (IDefender defender : defenders) {
if (defender != null) {
amount = defender.Apply(amount, powerUps);
}
}
if (IsDefending) {
if (Arrays.binarySearch(powerUps, AttackPowerUp.INEVITABLE) < 0) {
amount -= DefenseBonus;
}
IsDefending = false;
}
}
Health -= amount;
if (amount > 0) {
Health -= amount;
}
if (IsDestroyed()) {
HandleZeroHealth();
@@ -120,4 +233,46 @@ public abstract class Entity implements IDamageable, IHealable, IDefendable {
public void RemoveFromInventory(Item item) {
Inventory.remove(item);
}
@Override
public abstract void LightAttack(IDamageable target);
@Override
public abstract void HeavyAttack(IDamageable target);
@Override
public void defend() {
IsDefending = true;
}
@Override
public void HealMove() {
Heal(HealAmount);
}
@Override
public abstract void SpecialAbility(Entity entity);
@Override
public abstract String GetSpecialAbilityDescription(Entity entity);
@Override
public abstract String GetSpecialAbilityResultDescription(Entity entity);
@Override
public ArrayList<FightMoves> GetAvailableMoves() {
if (GetState() == EntityState.FROZEN || GetState() == EntityState.DEAD) return new ArrayList<>(){};
ArrayList<FightMoves> result = new ArrayList<>();
result.add(FightMoves.DEFEND);
result.add(FightMoves.LIGHT_ATTACK);
if (Health < MaxHealth) {
result.add(FightMoves.HEAL);
}
if (Stamina > MaxStamina / 2) {
result.add(FightMoves.SPECIAL);
}
if (Stamina > MaxStamina / 4) {
result.add(FightMoves.HEAVY_ATTACK);
}
return result;
}
}
@@ -0,0 +1,62 @@
package org.project.entity.enemies;
import org.project.constants.gameConstant.AttackPowerUp;
import org.project.constants.gameConstant.EntityState;
import org.project.entity.Entity;
import org.project.entity.players.Player;
import org.project.item.Accessory.Costume;
import org.project.item.Accessory.Shield;
import org.project.item.Accessory.Weapon;
import org.project.item.Item;
import org.project.item.KeyItem;
import java.util.ArrayList;
public class Dragon extends Enemy {
public Dragon (String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
int healAmount, int stamina, int maxStamina, int levelProgressAmount) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina, levelProgressAmount);
this.Key = new KeyItem("Dragon Key", this);
}
public Dragon() {
this("Dragon", 5000, 5000, 0, 100, EntityState.ALIVE, null, null, null, new ArrayList<>(){}, 50, false, 50, 500, 500, 1000);
}
public Dragon (Dragon other) {
super(other);
}
@Override
public Dragon copy() {
return new Dragon(this);
}
@Override
public void DropLoot(Player player) {
Key.Owner = player;
player.AddToInventory(Key);
}
@Override
public void SpecialAbility(Entity entity) {
ModifyStamina(SpecialAbilityStamina, false);
Damage(entity, GetDamage() * 2, new AttackPowerUp[]{AttackPowerUp.INEVITABLE, AttackPowerUp.ANTI_SHIELD});
}
@Override
public String GetSpecialAbilityDescription(Entity entity) {
return "Dragon will throw its fiery breath towards " + entity.Name + ". No defense and shield will help";
}
@Override
public String GetSpecialAbilityResultDescription(Entity entity) {
if (entity.IsDefending) {
return "Dragon will threw its fiery breath towards " + entity.Name + ". " + entity.Name + " tries to defend against it, but there's no use";
}
return "Dragon will threw its fiery breath towards " + entity.Name + ". To " + entity.Name + " surprise, their shield had no use";
}
}
@@ -1,34 +1,129 @@
package org.project.entity.enemies;
import org.project.item.weapons.Weapon;
import org.project.Interface.IDamageable;
import org.project.constants.gameConstant.AttackPowerUp;
import org.project.constants.gameConstant.EntityState;
import org.project.constants.gameConstant.FightMoves;
import org.project.constants.gameConstant.ItemClass;
import org.project.entity.Entity;
import org.project.entity.players.Player;
import org.project.item.Accessory.Costume;
import org.project.item.Accessory.Shield;
import org.project.item.Accessory.Weapon;
import org.project.item.Item;
import org.project.item.KeyItem;
// TODO: UPDATE IMPLEMENTATION
public abstract class Enemy {
Weapon weapon;
private int hp;
private int mp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import java.util.Random;
public Enemy(int hp, int mp, Weapon weapon) {
this.hp = hp;
this.mp = mp;
public abstract class Enemy extends Entity {
protected KeyItem Key;
public int LevelProgressAmount;
this.weapon = weapon;
public Enemy (String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
int healAmount, int stamina, int maxStamina, int levelProgressAmount) {
super(name, maxHealth, health, stamina, maxStamina, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount);
Key = new KeyItem(null, this);
LevelProgressAmount = levelProgressAmount;
}
protected Enemy() {
super();
}
public Enemy(Enemy other) {
super(other);
this.Key = new KeyItem(other.Key.getName(), other.Key.Owner);
}
@Override
public void takeDamage(int damage) {
hp -= damage;
public abstract Enemy copy();
public void DropLoot(Player player) {
Random random = new Random();
for (Item item : Inventory) {
int change = random.nextInt(2);
if (change == 0) {
player.AddToInventory(item);
}
}
ArrayList<Item> keys = player.GetInventoryByClass(ItemClass.KEY);
if (keys.stream().noneMatch(obj -> Objects.equals(obj.getName(), Key.getName()))) {
int chance = random.nextInt(5);
if (chance == 0) {
Key.Owner = player;
player.AddToInventory(Key);
}
}
player.ModifyMoney(GetMoney(), true);
}
public int getHp() {
return hp;
public FightMoves PlayRound(Player player) {
ArrayList<FightMoves> moves = GetAvailableMoves();
Random random = new Random();
int change = random.nextInt(4);
if (change == 0 && moves.contains(FightMoves.HEAL)) {
HealMove();
return FightMoves.HEAL;
}
else if (change == 1 && moves.contains(FightMoves.DEFEND)) {
defend();
return FightMoves.DEFEND;
}
else if (moves.contains(FightMoves.SPECIAL)) {
SpecialAbility(player);
return FightMoves.SPECIAL;
}
else if (moves.contains(FightMoves.HEAVY_ATTACK)) {
HeavyAttack(player);
return FightMoves.HEAVY_ATTACK;
}
else if (moves.contains(FightMoves.LIGHT_ATTACK)) {
LightAttack(player);
return FightMoves.LIGHT_ATTACK;
}
else return null;
}
public int getMp() {
return mp;
@Override
public void LightAttack(IDamageable target) {
int damage = GetDamage();
Damage(target, (int)(damage * 0.4), new AttackPowerUp[]{});
ModifyStamina(MaxStamina/8, true);
}
public Weapon getWeapon() {
return weapon;
@Override
public void HeavyAttack(IDamageable target) {
int damage = GetDamage();
ModifyStamina(HeavyAttackStamina, false);
Damage(target, (int)(damage * 0.9), new AttackPowerUp[]{});
}
@Override
public void HealMove() {
super.HealMove();
ModifyStamina(MaxStamina/4, true);
}
@Override
public abstract void SpecialAbility(Entity entity);
@Override
public abstract String GetSpecialAbilityDescription(Entity entity);
@Override
public abstract String GetSpecialAbilityResultDescription(Entity entity);
}
@@ -0,0 +1,52 @@
package org.project.entity.enemies;
import org.project.constants.gameConstant.AttackPowerUp;
import org.project.constants.gameConstant.EntityState;
import org.project.entity.Entity;
import org.project.item.Accessory.Costume;
import org.project.item.Accessory.Shield;
import org.project.item.Accessory.Weapon;
import org.project.item.Item;
import org.project.item.KeyItem;
import java.util.ArrayList;
public class Goblin extends Enemy {
public Goblin (String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
int healAmount, int stamina, int maxStamina, int levelProgressAmount) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina, levelProgressAmount);
this.Key = new KeyItem("Goblin Key", this);
}
public Goblin() {
this("Goblin", 75, 75, 100, 10, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 15, 100, 100, 50);
}
public Goblin (Goblin other) {
super(other);
}
@Override
public Goblin copy() {
return new Goblin(this);
}
@Override
public void SpecialAbility(Entity entity) {
ModifyStamina(SpecialAbilityStamina, false);
Damage(entity, GetDamage() * 4, new AttackPowerUp[]{});
}
@Override
public String GetSpecialAbilityDescription(Entity entity) {
return "Goblin will rage and cause a critical damage to " + entity.Name;
}
@Override
public String GetSpecialAbilityResultDescription(Entity entity) {
return "Goblin looks at " + entity.Name + ", its eyes are red... He rages and charges " + entity.Name + " with all of its power";
}
}
@@ -1,6 +1,100 @@
package org.project.entity.enemies;
// TODO: UPDATE IMPLEMENTATION
public class Skeleton {
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
import org.project.constants.gameConstant.EntityState;
import org.project.constants.gameConstant.FightMoves;
import org.project.entity.Entity;
import org.project.item.Accessory.Costume;
import org.project.item.Accessory.Shield;
import org.project.item.Accessory.Weapon;
import org.project.item.Item;
import org.project.item.KeyItem;
import java.util.ArrayList;
import java.util.Random;
public class Skeleton extends Enemy {
boolean HasRevived = false;
public Skeleton (String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
int healAmount, int stamina, int maxStamina, int levelProgressAmount) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina, levelProgressAmount);
this.Key = new KeyItem("Skeleton Key", this);
}
public Skeleton() {
this("Skeleton", 125, 125, 200, 15, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 20, 100, 100, 100);
}
public Skeleton (Skeleton other) {
super(other);
}
@Override
public Skeleton copy() {
return new Skeleton(this);
}
@Override
public ArrayList<FightMoves> GetAvailableMoves() {
if (GetState() == EntityState.FROZEN || GetState() == EntityState.DEAD) return new ArrayList<>(){};
ArrayList<FightMoves> result = new ArrayList<>();
if (GetState() == EntityState.DOWNED) {
if (GetStamina() > MaxStamina / 2 && !HasRevived) {
Random random = new Random();
int chance = random.nextInt(2);
if (chance == 0) {
result.add(FightMoves.SPECIAL);
return result;
}
}
else {
HandleZeroHealth();
}
}
result.add(FightMoves.DEFEND);
result.add(FightMoves.LIGHT_ATTACK);
if (Health < MaxHealth) {
result.add(FightMoves.HEAL);
}
if (GetStamina() > MaxStamina / 4) {
result.add(FightMoves.HEAVY_ATTACK);
}
return result;
}
@Override
public void HandleZeroHealth() {
if (GetState() == EntityState.DOWNED) {
SetState(EntityState.DEAD);
}
SetState(EntityState.DOWNED);
}
@Override
public void SpecialAbility(Entity entity) {
SetState(EntityState.ALIVE);
Health = MaxHealth / 2;
HasRevived = true;
entity.SetState(EntityState.FROZEN);
}
@Override
public String GetSpecialAbilityDescription(Entity entity) {
return "Skeleton refuses to die and revives";
}
@Override
public String GetSpecialAbilityResultDescription(Entity entity) {
return "Just as " + entity.Name + " made sure of their victory. The bones started to shake, they gathered once more for Skeleton to shape. \"You need more thank that to kill me\" Says the skeleton";
}
}
@@ -0,0 +1,54 @@
package org.project.entity.enemies;
import org.project.constants.gameConstant.AttackPowerUp;
import org.project.constants.gameConstant.EntityState;
import org.project.entity.Entity;
import org.project.item.Accessory.Costume;
import org.project.item.Accessory.Shield;
import org.project.item.Accessory.Weapon;
import org.project.item.Item;
import org.project.item.KeyItem;
import java.util.ArrayList;
public class Vampire extends Enemy {
public Vampire (String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
int healAmount, int stamina, int maxStamina, int levelProgressAmount) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina, levelProgressAmount);
this.Key = new KeyItem("Vampire Key", this);
}
public Vampire() {
this("Vampire", 150, 150, 300, 20, EntityState.ALIVE, null, null, null, new ArrayList<>(), 8, false, 30, 100, 100, 150);
}
public Vampire (Vampire other) {
super(other);
}
@Override
public Vampire copy() {
return new Vampire(this);
}
@Override
public void SpecialAbility(Entity entity) {
int curHealth = entity.Health;
ModifyStamina(SpecialAbilityStamina, false);
Damage(entity, GetDamage(), new AttackPowerUp[]{AttackPowerUp.INEVITABLE});
Heal(curHealth - entity.Health);
}
@Override
public String GetSpecialAbilityDescription(Entity entity) {
return "Vampire will suck the blood out of " + entity.Name + " and heal themselves while hurting the enemy";
}
@Override
public String GetSpecialAbilityResultDescription(Entity entity) {
return "Vampire attacked " + entity.Name + " and sucked his blood out of his veins. He seems more powerful";
}
}
@@ -0,0 +1,58 @@
package org.project.entity.players;
import org.project.constants.gameConstant.AttackPowerUp;
import org.project.constants.gameConstant.EntityState;
import org.project.entity.Entity;
import org.project.item.Accessory.Costume;
import org.project.item.Accessory.Shield;
import org.project.item.Accessory.Weapon;
import org.project.item.Item;
import java.util.ArrayList;
public class Assassin extends Player {
public Assassin(String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
int healAmount, int stamina, int maxStamina, int level, int levelProgress) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina, level, levelProgress);
}
public Assassin(String name, int level) {
this(name);
LevelUpTo(level);
}
public Assassin(String name) {
this(name, 125, 125, 100, 15, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 35, 100, 100, 1, 0);
}
public Assassin(Assassin other) {
super(other);
}
@Override
public Assassin copy() {
return new Assassin(this);
}
@Override
public void SpecialAbility(Entity entity) {
ModifyStamina(SpecialAbilityStamina, false);
Damage(entity, GetDamage() * 3, new AttackPowerUp[]{AttackPowerUp.NO_DEFENSE});
}
@Override
public String GetSpecialAbilityDescription(Entity entity) {
return "Turn invisible and cause a critical damage to " + entity.Name + ". Your enemy cannot defend your attack \n";
}
@Override
public String GetSpecialAbilityResultDescription(Entity entity) {
if (entity.IsDefending) {
return entity.Name + " Holds their guard up, but you strike them from another direction";
}
return "\"Show Yourself coward\" Says " + entity.Name + " As they helplessly try to hit you. But their eyes cannot find you no matter how hard they try";
}
}
@@ -1,6 +1,59 @@
package org.project.entity.players;
// TODO: UPDATE IMPLEMENTATION
public class Knight {
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
import org.project.constants.gameConstant.AttackPowerUp;
import org.project.constants.gameConstant.EntityState;
import org.project.entity.Entity;
import org.project.item.Accessory.Costume;
import org.project.item.Accessory.Shield;
import org.project.item.Accessory.Weapon;
import org.project.item.Item;
import java.util.ArrayList;
public class Knight extends Player {
public Knight(String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
int healAmount, int stamina, int maxStamina, int level, int levelProgress) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina, level, levelProgress);
}
public Knight(String name, int level) {
this(name);
LevelUpTo(level);
}
public Knight(String name) {
this(name, 150, 150, 100, 20, EntityState.ALIVE, null, null, null, new ArrayList<>(), 8, false, 30, 100, 100, 1, 0);
}
public Knight(Knight other) {
super(other);
}
@Override
public Knight copy() {
return new Knight(this);
}
@Override
public void SpecialAbility(Entity entity) {
ModifyStamina(SpecialAbilityStamina, false);
Damage(entity, GetDamage(), new AttackPowerUp[]{});
entity.SetState(EntityState.FROZEN);
}
@Override
public String GetSpecialAbilityDescription(Entity entity) {
return "Slam " + entity.Name + " with your unstoppable strength and stun them for the next turn";
}
@Override
public String GetSpecialAbilityResultDescription(Entity entity) {
if (entity.IsDefending) {
return "You slammed " + entity.Name + ", they try to defend, but they were thrown to the ground";
}
return "You slammed " + entity.Name + ", your enemy seems deezy";
}
}
@@ -1,89 +1,105 @@
package org.project.entity.players;
import org.project.Interface.IDamageable;
import org.project.constants.gameConstant.AttackPowerUp;
import org.project.constants.gameConstant.EntityState;
import org.project.entity.Entity;
import org.project.item.armors.Armor;
import org.project.item.weapons.Weapon;
import org.project.item.Accessory.Costume;
import org.project.item.Accessory.Shield;
import org.project.item.Accessory.Weapon;
import org.project.item.Item;
// 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;
import java.util.ArrayList;
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
this.name = name;
this.hp = hp;
this.mp = mp;
public abstract class Player extends Entity {
public int Level;
private int LevelProgress;
this.weapon = weapon;
this.armor = armor;
public Player (String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
int healAmount, int stamina, int maxStamina, int level, int levelProgress) {
super(name, maxHealth, health, stamina, maxStamina, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount);
Level = level;
LevelProgress = levelProgress;
}
protected Player() {
super();
}
public Player(Player other) {
super(other);
this.Level = other.Level;
this.LevelProgress = other.LevelProgress;
}
@Override
public void attack(Entity target) {
target.takeDamage(weapon.getDamage());
public abstract Player copy();
public void LevelUpTo(int level) {
while (Level < level) {
UnconditionalLevelUp();
}
}
@Override
public void defend() {
// TODO
public void AddLevelProgress(int amount) {
LevelProgress += amount;
if (LevelProgress >= 100) {
LevelUp();
}
}
public void UnconditionalLevelUp() {
Level++;
double upgradeRatio = (1.1 + ((double) Level * 0.02));
int gift = Level * 10;
@Override
public void takeDamage(int damage) {
hp -= damage - armor.GetDefense();
MaxStamina = (int) (MaxStamina * upgradeRatio);
MaxHealth = (int) (MaxHealth * upgradeRatio);
BaseDamage = (int) (BaseDamage * upgradeRatio);
DefenseBonus = (int) (DefenseBonus * upgradeRatio);
HealAmount = (int) (HealAmount * upgradeRatio);
ModifyMoney(gift, true);
}
@Override
public void heal(int health) {
hp += health;
if (hp > maxHP) {
hp = maxHP;
public void LevelUp() {
while (LevelProgress >= 100) {
UnconditionalLevelUp();
LevelProgress -= 100;
}
}
@Override
public void fillMana(int mana) {
mp += mana;
if (mp > maxMP) {
mp = maxMP;
}
}
public void LightAttack(IDamageable target) {
int damage = GetDamage();
public String getName() {
return name;
}
public int getHp() {
return hp;
Damage(target, (int)(damage * 0.5), new AttackPowerUp[]{});
ModifyStamina(MaxStamina/8, false);
}
@Override
public int getMaxHP() {
return maxHP;
}
public void HeavyAttack(IDamageable target) {
int damage = GetDamage();
public int getMp() {
return mp;
Damage(target, damage, new AttackPowerUp[]{});
ModifyStamina(HeavyAttackStamina, false);
}
@Override
public int getMaxMP() {
return maxMP;
public void HealMove() {
super.HealMove();
ModifyStamina(MaxStamina/4, true);
}
public Weapon getWeapon() {
return weapon;
}
@Override
public abstract void SpecialAbility(Entity entity);
public Armor getArmor() {
return armor;
}
@Override
public abstract String GetSpecialAbilityDescription(Entity entity);
@Override
public abstract String GetSpecialAbilityResultDescription(Entity entity);
}
@@ -0,0 +1,55 @@
package org.project.entity.players;
import org.project.constants.gameConstant.AttackPowerUp;
import org.project.constants.gameConstant.EntityState;
import org.project.entity.Entity;
import org.project.item.Accessory.Costume;
import org.project.item.Accessory.Shield;
import org.project.item.Accessory.Weapon;
import org.project.item.Item;
import java.util.ArrayList;
public class Wizard extends Player {
public Wizard(String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
int healAmount, int stamina, int maxStamina, int level, int levelProgress) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina, level, levelProgress);
}
public Wizard(String name, int level) {
this(name);
LevelUpTo(level);
}
public Wizard(String name) {
this(name, 100, 100, 100, 15, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 40, 100, 100, 1, 0);
}
public Wizard(Wizard other) {
super(other);
}
@Override
public Wizard copy() {
return new Wizard(this);
}
@Override
public void SpecialAbility(Entity entity) {
ModifyStamina(SpecialAbilityStamina, false);
Damage(entity, GetDamage() * 3, new AttackPowerUp[]{AttackPowerUp.INEVITABLE});
Heal(MaxHealth/4);
}
@Override
public String GetSpecialAbilityDescription(Entity entity) {
return "Cast a spell to damage " + entity.Name + "and heal yourself. Your spell will pass enemy's defences";
}
@Override
public String GetSpecialAbilityResultDescription(Entity entity) {
return "You cased the spell, enemy cannot do anything but to look at you with fear";
}
}
@@ -45,13 +45,13 @@ public abstract class Accessory extends SellableItem implements IDamageable, IAt
@Override
public void HandleZeroHealth() {
this.DeattachFrom(this.Owner);
this.DeattachFrom(this.Owner, false);
this.Owner.Inventory.remove(this);
}
@Override
public abstract void AttachTo(Entity entity);
public abstract void AttachTo(Entity entity, boolean fromInventory);
@Override
public abstract void DeattachFrom(Entity entity);
public abstract void DeattachFrom(Entity entity, boolean toInventory);
}
@@ -35,14 +35,14 @@ public class Costume extends Accessory implements IDefender {
}
@Override
public void AttachTo(Entity entity) {
entity.RemoveFromInventory(this);
public void AttachTo(Entity entity, boolean fromInventory) {
if (fromInventory) entity.RemoveFromInventory(this);
entity.Costume = this;
}
@Override
public void DeattachFrom(Entity entity) {
public void DeattachFrom(Entity entity, boolean toInventory) {
entity.Costume = null;
entity.AddToInventory(this);
if (toInventory) entity.AddToInventory(this);
}
}
@@ -35,14 +35,14 @@ public class Shield extends Accessory implements IDefender {
}
@Override
public void AttachTo(Entity entity) {
entity.RemoveFromInventory(this);
public void AttachTo(Entity entity, boolean fromInventory) {
if (fromInventory) entity.RemoveFromInventory(this);
entity.Shield = this;
}
@Override
public void DeattachFrom(Entity entity) {
public void DeattachFrom(Entity entity, boolean toInventory) {
entity.Shield = null;
entity.AddToInventory(this);
if (toInventory) entity.AddToInventory(this);
}
}
@@ -1,8 +1,9 @@
package org.project.item.Accessory;
import org.project.Interface.IDamageUtil;
import org.project.entity.Entity;
public class Weapon extends Accessory {
public class Weapon extends Accessory implements IDamageUtil {
private final int Damage;
public Weapon (String name, Entity owner, int price, int health, int maxHealth, int damage) {
@@ -10,19 +11,20 @@ public class Weapon extends Accessory {
this.Damage = damage;
}
@Override
public int GetDamage() {
return Damage;
}
@Override
public void AttachTo(Entity entity) {
entity.RemoveFromInventory(this);
public void AttachTo(Entity entity, boolean fromInventory) {
if (fromInventory) entity.RemoveFromInventory(this);
entity.Weapon = this;
}
@Override
public void DeattachFrom(Entity entity) {
public void DeattachFrom(Entity entity, boolean toInventory) {
entity.Weapon = null;
entity.AddToInventory(this);
if (toInventory) entity.AddToInventory(this);
}
}
@@ -0,0 +1,15 @@
package org.project.location;
import org.project.entity.enemies.Dragon;
import org.project.entity.enemies.Enemy;
public class Castle extends Location {
public Castle() {
super("Castle");
}
@Override
protected Enemy GetEnemy() {
return new Dragon();
}
}
@@ -0,0 +1,15 @@
package org.project.location;
import org.project.entity.enemies.Enemy;
import org.project.entity.enemies.Vampire;
public class DarkCaves extends Location {
public DarkCaves() {
super("Dark Caves");
}
@Override
protected Enemy GetEnemy() {
return new Vampire();
}
}
@@ -0,0 +1,15 @@
package org.project.location;
import org.project.entity.enemies.Enemy;
import org.project.entity.enemies.Skeleton;
public class GraveYard extends Location {
public GraveYard() {
super("Grave Yard");
}
@Override
protected Enemy GetEnemy() {
return new Skeleton();
}
}
@@ -0,0 +1,15 @@
package org.project.location;
import org.project.entity.enemies.Enemy;
import org.project.entity.enemies.Goblin;
public class Jungle extends Location {
public Jungle() {
super("Jungle");
}
@Override
protected Enemy GetEnemy() {
return new Goblin();
}
}
@@ -3,26 +3,30 @@ package org.project.location;
import org.project.entity.enemies.Enemy;
import java.util.ArrayList;
import java.util.Random;
public class Location {
private String name;
public abstract class Location {
private final String name;
public Enemy enemy;
private ArrayList<Enemy> enemies;
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
this.locations = locations;
this.enemies = enemies;
public Location(String name) {
this.name = name;
this.enemy = GetEnemy();
}
public String getName() {
return name;
}
public String getName() { return name; }
public ArrayList<Location> getLocations() {
return locations;
}
protected abstract Enemy GetEnemy();
public ArrayList<Enemy> getEnemies() {
return enemies;
public static Location RandomLocation() {
Random random = new Random();
int chance = random.nextInt(3);
return switch (chance) {
case 0 -> new GraveYard();
case 1 -> new DarkCaves();
case 2 -> new Jungle();
default -> new Jungle();
};
}
}
@@ -1,4 +1,79 @@
package org.project.util;
import org.project.Interface.IDamageUtil;
import org.project.Interface.IDefender;
import org.project.constants.appConstants.TextColor;
import org.project.item.Accessory.Accessory;
import org.project.item.Item;
import org.project.item.KeyItem;
import org.project.item.SellableItem;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Hashtable;
public class DisplayItem {
public static void DisplayItems(ArrayList<Item> items) {
for (Item item : items) {
if (item == null) continue;
String result = item.getName();
if (item instanceof SellableItem) {
result += "\n Price = " + ((SellableItem) item).GetPrice();
}
if (item instanceof Accessory) {
result += "\n Health = " + ((Accessory) item).GetHealth() + "/" + ((Accessory) item).GetMaxHealth();
}
if (item instanceof IDamageUtil) {
result += "\n Damage = " + ((IDamageUtil) item).GetDamage();
}
if (item instanceof IDefender) {
result += "\n Defence = " + ((IDefender) item).GetDefense();
}
System.out.println(result);
}
}
public static Dictionary<Integer, Item> MenuDisplay(ArrayList<Item> items) {
int index = 0;
Dictionary<Integer, Item> dictionary = new Hashtable<>();
for (Item item : items) {
if (item == null) continue;
String result = index + " > " + item.getName();
if (item instanceof KeyItem) {
result += TextColor.Yellow + " (KEY ITEM)" + TextColor.Reset;
}
if (item instanceof SellableItem) {
result += "\n Price = " + ((SellableItem) item).GetPrice();
}
if (item instanceof Accessory) {
result += "\n Health = " + ((Accessory) item).GetHealth() + "/" + ((Accessory) item).GetMaxHealth();
}
if (item instanceof IDamageUtil) {
result += "\n Damage = " + ((IDamageUtil) item).GetDamage();
}
if (item instanceof IDefender) {
result += "\n Defence = " + ((IDefender) item).GetDefense();
}
dictionary.put(index, item);
index++;
System.out.println(result);
}
return dictionary;
}
}