6 Commits
Author SHA1 Message Date
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
19 changed files with 593 additions and 72 deletions
@@ -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,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};
}
}
@@ -1,4 +1,15 @@
package org.project.engine;
public class BattleEngine {
import org.project.entity.Entity;
public abstract class BattleEngine {
public Entity Player1;
public Entity Player2;
public BattleEngine(Entity player1, Entity player2) {
Player1 = player1;
Player2 = player2;
}
public abstract void StartBattle();
}
@@ -1,6 +1,11 @@
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() {}
@@ -13,4 +18,36 @@ public abstract class MainEngine {
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());
}
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());
}
int choice = scanner.nextInt();
if (choice >= 0 && choice < roles.length) {
return PlayerRolesExt.CreatePlayer(roles[choice], name);
}
}
}
}
@@ -1,4 +1,15 @@
package org.project.engine;
public class MultiPlayerBattleEngine {
import org.project.entity.enemies.Enemy;
import org.project.entity.players.Player;
public class MultiPlayerBattleEngine extends BattleEngine {
public MultiPlayerBattleEngine(Player player1, Player player2) {
super(player1, player2);
}
@Override
public void StartBattle() {
}
}
@@ -1,4 +1,39 @@
package org.project.engine;
public class MultiplayerEngine extends MainEngine{
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();
}
}
@@ -1,4 +1,55 @@
package org.project.engine;
public class SinglePlayerBattleEngine {
import org.project.constants.appConstants.TextColor;
import org.project.constants.gameConstant.EntityState;
import org.project.constants.gameConstant.FightMoves;
import org.project.entity.enemies.Enemy;
import org.project.entity.players.Player;
public class SinglePlayerBattleEngine extends BattleEngine {
private Player player;
private Enemy enemy;
public SinglePlayerBattleEngine(Player player, Enemy enemy) {
super(player, enemy);
player = (Player) Player1;
enemy = (Enemy) Player2;
}
@Override
public void StartBattle() {
Player playerPast = player;
Enemy enemyPast = enemy;
while (true) {
if (enemyPast.GetState() == EntityState.FROZEN) {
enemy.SetState(EntityState.ALIVE);
}
if (playerPast.GetState() == EntityState.FROZEN) {
player.SetState(EntityState.ALIVE);
}
// TODO: get diffs
// TODO: player round
// TODO: show players stats
// TODO: bot move
FightMoves botMove = enemy.PlayRound(player);
switch (botMove)
if (enemy.GetState() == EntityState.DEAD) {
enemy.DropLoot(player);
player.AddLevelProgress(enemy.LevelProgressAmount);
System.out.println(TextColor.Green + player.Name + " WON!" + TextColor.Reset);
return;
}
else if (player.GetState() == EntityState.DEAD) {
return;
}
playerPast = player;
enemyPast = enemy;
}
}
}
@@ -2,13 +2,17 @@ package org.project.engine;
import org.project.constants.appConstants.ConsoleColor;
import org.project.constants.appConstants.TextColor;
import org.project.constants.gameConstant.ItemClass;
import org.project.entity.players.Assassin;
import org.project.entity.players.Knight;
import org.project.constants.gameConstant.*;
import org.project.entity.players.Player;
import org.project.entity.players.Wizard;
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 {
@@ -28,55 +32,75 @@ public class SinglePlayerEngine extends MainEngine {
System.out.println("How should me call you, hero? ");
String name = scanner.nextLine();
boolean InValidInput = false;
do {
System.out.println("Greetings, " + name + ". May we know your role? \n" +
"0 > Wizard" +
"1 > Assassin" +
"2 > Knight");
System.out.println("Greetings, " + name + ". May we know your role? \n");
int choice = scanner.nextInt();
player = RoleMenu(name);
switch (choice) {
case 0 -> player = new Wizard(name);
case 1 -> player = new Assassin(name);
case 2 -> player = new Knight(name);
default -> InValidInput = true;
}
} while (InValidInput);
System.out.println("Very well, " + TextColor.Cyan + GetIntro() + ConsoleColor.Reset + " your journey begins!");
System.out.println("Very well, " + TextColor.Cyan + player.Name + ConsoleColor.Reset + " your journey begins!");
System.out.println();
while (true) {
boolean canFightDragon = false;
if (player.GetInventoryByClass(ItemClass.KEY).size() == 3) {
canFightDragon = true;
}
boolean canFightDragon = player.GetInventoryByClass(ItemClass.KEY).size() == 3;
Location location = Location.RandomLocation();
System.out.println(GetLocationIntro(location));
while (true) {
boolean continueLoop = false;
do {
System.out.println(GetLocationIntro(location));
System.out.println("What do you do, " + player.Name + "?");
System.out.println(
"0 > FIGHT!\n" +
"1 > Go to the next location\n" +
"2 > Visit the market place in the town"
"""
0 > FIGHT!
1 > Go to the next location
2 > Visit the market place in the town
3 > Check inventory"""
);
if (canFightDragon) {
System.out.println("3 > Go to the castle to face the dragon");
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;
}
}
}
@@ -85,20 +109,221 @@ public class SinglePlayerEngine extends MainEngine {
}
public String GetLocationIntro(Location location) {
if (location instanceof Jungle) {
return player.Name + " enters the woods, after a few steps, they see a green goblin searching for food a few steps away";
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 a more 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 -> "";
};
}
else if (location instanceof GraveYard) {
return player.Name + " goes inside the grave ward, they cannot see a more than 10 steps ahead because of the fog in the air. After lurking through out the graves, the shadow appears... It's a skeleton!";
public void MarketPlace() {
Scanner scanner = new Scanner(System.in);
System.out.println("You've entered the marketplace, what would you like to do?");
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 shields
8 > Buy shields
9 > Exit
""");
int choice = scanner.nextInt();
switch (choice) {
case 0 -> DisplayItem.DisplayItems(player.GetInventory());
case 1 -> {
player.SellByClass(ItemClass.UNNECESSARY);
System.out.println(TextColor.Green + "Unnecessary goods sold" + TextColor.Reset);
}
else if (location instanceof DarkCaves) {
return player.Name + " dives into the darkness. As our hero was going deeper, a black smoke appears, a vampire is nearby...";
case 2 -> {
player.SellByClass(ItemClass.ACCESSORY);
System.out.println(TextColor.Green + "accessories sold" + TextColor.Reset);
}
else if (location instanceof Castle) {
return player.Name + " Goes through the gates, the dragon looks at " + player.Name + "... It knows that an epic battle awaits both it them";
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<>();
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()) {
accessory.AttachTo(player);
player.ModifyMoney(accessory.GetPrice(), false);
}
else {
return "";
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<>();
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()) {
accessory.AttachTo(player);
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<>();
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()) {
accessory.AttachTo(player);
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("You open your inventory, what would you like to do?");
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 -> DisplayItem.DisplayItems(player.GetInventory());
case 1 -> {
System.out.println(TextColor.Blue + "Current shield: ");
ArrayList<Item> item = new ArrayList<>();
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) {
((Accessory) shield).AttachTo(player);
}
}
case 2 -> {
System.out.println(TextColor.Blue + "Current weapon: ");
ArrayList<Item> item = new ArrayList<>();
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) {
((Accessory) weapon).AttachTo(player);
}
}
case 3 -> {
System.out.println(TextColor.Blue + "Current costume: ");
ArrayList<Item> item = new ArrayList<>();
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) {
((Accessory) costume).AttachTo(player);
}
}
case 4 -> wantsToStay = false;
}
}
}
}
@@ -15,15 +15,15 @@ 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 healAmount, int stamina, int maxStamina, int levelProgressAmount) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina);
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);
this("Dragon", 5000, 5000, 0, 100, EntityState.ALIVE, null, null, null, new ArrayList<>(){}, 50, false, 50, 500, 500, 1000);
}
@Override
@@ -20,14 +20,16 @@ import java.util.Random;
public abstract class Enemy extends Entity {
protected KeyItem Key;
public int LevelProgressAmount;
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 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() {
@@ -14,15 +14,15 @@ 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 healAmount, int stamina, int maxStamina, int levelProgressAmount) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina);
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);
this("Goblin", 75, 75, 100, 10, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 15, 100, 100, 50);
}
@Override
@@ -18,15 +18,15 @@ public class Skeleton extends Enemy {
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 healAmount, int stamina, int maxStamina, int levelProgressAmount) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina);
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);
this("Skeleton", 125, 125, 200, 15, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 20, 100, 100, 100);
}
@Override
@@ -76,6 +76,7 @@ public class Skeleton extends Enemy {
SetState(EntityState.ALIVE);
Health = MaxHealth / 2;
HasRevived = true;
entity.SetState(EntityState.FROZEN);
}
@Override
@@ -14,15 +14,15 @@ 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 healAmount, int stamina, int maxStamina, int levelProgressAmount) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina);
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);
this("Vampire", 150, 150, 300, 20, EntityState.ALIVE, null, null, null, new ArrayList<>(), 8, false, 30, 100, 100, 150);
}
@Override
@@ -44,6 +44,7 @@ public abstract class Player extends Entity {
}
public void LevelUp() {
while (LevelProgress >= 100) {
Level++;
double upgradeRatio = (1.1 + ((double) Level * 0.02));
int gift = Level * 10;
@@ -56,6 +57,7 @@ public abstract class Player extends Entity {
HealAmount = (int) (HealAmount * upgradeRatio);
ModifyMoney(gift, true);
}
}
@Override
public void LightAttack(IDamageable target) {
@@ -26,7 +26,7 @@ public abstract class Location {
case 0 -> new GraveYard();
case 1 -> new DarkCaves();
case 2 -> new Jungle();
default -> null;
default -> new Jungle();
};
}
}
@@ -1,4 +1,75 @@
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) {
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 Damage = " + ((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) {
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 Damage = " + ((IDefender) item).GetDefense();
}
dictionary.put(index, item);
index++;
System.out.println(result);
}
return dictionary;
}
}