Compare commits
11
Commits
da218c1134
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
821d27098c | ||
|
|
a8d1b1011f | ||
|
|
dc963742aa | ||
|
|
76baf0f2cf | ||
|
|
879655f62e | ||
|
|
6f39911a34 | ||
|
|
71f1f272f2 | ||
|
|
a0a8626436 | ||
|
|
3af890f4b5 | ||
|
|
c1a4456328 | ||
|
|
a29997e733 |
@@ -0,0 +1 @@
|
|||||||
|
/Java-Knight/target/
|
||||||
@@ -3,6 +3,6 @@ package org.project.Interface;
|
|||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
public interface IAttachable {
|
public interface IAttachable {
|
||||||
public void AttachTo(Entity entity);
|
public void AttachTo(Entity entity, boolean fromInventory);
|
||||||
public void DeattachFrom(Entity entity);
|
public void DeattachFrom(Entity entity, boolean toInventory);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,49 @@
|
|||||||
package org.project;
|
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.Scanner;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
static void main(String[] args) {
|
||||||
// TODO: ADD LOCATIONS TO YOUR GAME
|
Scanner scanner = new Scanner(System.in);
|
||||||
List<Location> locations = new ArrayList<>();
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package org.project.constants.appConstants;
|
package org.project.constants.appConstants;
|
||||||
|
|
||||||
public class ConsoleColor {
|
public class ConsoleColor {
|
||||||
public static final String Reset = "\\u001B[0m";
|
public static final String Reset = "\u001B[0m";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package org.project.constants.appConstants;
|
package org.project.constants.appConstants;
|
||||||
|
|
||||||
public class TextColor extends ConsoleColor{
|
public class TextColor extends ConsoleColor{
|
||||||
public static String Black = "\\u001B[30m";
|
public static String Black = "\u001B[30m";
|
||||||
public static String Red = "\\u001B[31m";
|
public static String Red = "\u001B[31m";
|
||||||
public static String Green = "\\u001B[32m";
|
public static String Green = "\u001B[32m";
|
||||||
public static String Yellow = "\\u001B[33m";
|
public static String Yellow = "\u001B[33m";
|
||||||
public static String Blue = "\\u001B[34m";
|
public static String Blue = "\u001B[34m";
|
||||||
public static String Magenta = "\\u001B[35m";
|
public static String Magenta = "\u001B[35m";
|
||||||
public static String Cyan = "\\u001B[36m";
|
public static String Cyan = "\u001B[36m";
|
||||||
public static String White = "\\u001B[37m";
|
public static String White = "\u001B[37m";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ public abstract class BattleEngine {
|
|||||||
public Entity Player2;
|
public Entity Player2;
|
||||||
|
|
||||||
public BattleEngine(Entity player1, Entity player2) {
|
public BattleEngine(Entity player1, Entity player2) {
|
||||||
|
player1.ResetStamina();
|
||||||
|
player1.RestoreHealth();
|
||||||
|
player2.RestoreHealth();
|
||||||
|
player2.ResetStamina();
|
||||||
Player1 = player1;
|
Player1 = player1;
|
||||||
Player2 = player2;
|
Player2 = player2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public abstract class MainEngine {
|
|||||||
while (true) {
|
while (true) {
|
||||||
for (PlayerRoles role : roles) {
|
for (PlayerRoles role : roles) {
|
||||||
System.out.println(index + " > " + role.name().toLowerCase());
|
System.out.println(index + " > " + role.name().toLowerCase());
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
int choice = scanner.nextInt();
|
int choice = scanner.nextInt();
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ public abstract class MainEngine {
|
|||||||
while (true) {
|
while (true) {
|
||||||
for (PlayerRoles role : roles) {
|
for (PlayerRoles role : roles) {
|
||||||
System.out.println(index + " > " + role.name().toLowerCase());
|
System.out.println(index + " > " + role.name().toLowerCase());
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
int choice = scanner.nextInt();
|
int choice = scanner.nextInt();
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,186 @@
|
|||||||
package org.project.engine;
|
package org.project.engine;
|
||||||
|
|
||||||
import org.project.entity.enemies.Enemy;
|
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 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 {
|
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) {
|
public MultiPlayerBattleEngine(Player player1, Player player2) {
|
||||||
super(player1, player2);
|
super(player1, player2);
|
||||||
|
this.player1 = (Player) Player1;
|
||||||
|
this.player2 = (Player) Player2;
|
||||||
|
player1Past = player1.copy();
|
||||||
|
player2Past = player2.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void StartBattle() {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +1,185 @@
|
|||||||
package org.project.engine;
|
package org.project.engine;
|
||||||
|
|
||||||
|
import org.project.common.models.EntityDiff;
|
||||||
import org.project.constants.appConstants.TextColor;
|
import org.project.constants.appConstants.TextColor;
|
||||||
import org.project.constants.gameConstant.EntityState;
|
import org.project.constants.gameConstant.EntityState;
|
||||||
import org.project.constants.gameConstant.FightMoves;
|
import org.project.constants.gameConstant.FightMoves;
|
||||||
|
import org.project.entity.Entity;
|
||||||
import org.project.entity.enemies.Enemy;
|
import org.project.entity.enemies.Enemy;
|
||||||
import org.project.entity.players.Player;
|
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 {
|
public class SinglePlayerBattleEngine extends BattleEngine {
|
||||||
private Player player;
|
private final Player player;
|
||||||
private Enemy enemy;
|
private final Enemy enemy;
|
||||||
|
private Player playerPast;
|
||||||
|
private Enemy enemyPast;
|
||||||
public SinglePlayerBattleEngine(Player player, Enemy enemy) {
|
public SinglePlayerBattleEngine(Player player, Enemy enemy) {
|
||||||
super(player, enemy);
|
super(player, enemy);
|
||||||
player = (Player) Player1;
|
this.player = (Player) Player1;
|
||||||
enemy = (Enemy) Player2;
|
this.enemy = (Enemy) Player2;
|
||||||
|
playerPast = player.copy();
|
||||||
|
enemyPast = enemy.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void StartBattle() {
|
public void StartBattle() {
|
||||||
Player playerPast = player;
|
EntityDiff playerDiff;
|
||||||
Enemy enemyPast = enemy;
|
EntityDiff enemyDiff;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (enemyPast.GetState() == EntityState.FROZEN) {
|
if (player.GetState() != EntityState.FROZEN) {
|
||||||
enemy.SetState(EntityState.ALIVE);
|
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) {
|
if (playerPast.GetState() == EntityState.FROZEN) {
|
||||||
player.SetState(EntityState.ALIVE);
|
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) {
|
if (enemy.GetState() == EntityState.DEAD) {
|
||||||
enemy.DropLoot(player);
|
enemy.DropLoot(player);
|
||||||
player.AddLevelProgress(enemy.LevelProgressAmount);
|
player.AddLevelProgress(enemy.LevelProgressAmount);
|
||||||
System.out.println(TextColor.Green + player.Name + " WON!" + TextColor.Reset);
|
System.out.println(TextColor.Green + player.Name + " WON!" + TextColor.Reset);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (player.GetState() == EntityState.DEAD) {
|
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerPast = player;
|
if (enemyPast.GetState() == EntityState.FROZEN) {
|
||||||
enemyPast = enemy;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
System.out.println(TextColor.Cyan + GetIntro() + ConsoleColor.Reset);
|
System.out.println(TextColor.Cyan + GetIntro() + ConsoleColor.Reset);
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("How should me call you, hero? ");
|
System.out.println("How should we call you, hero? ");
|
||||||
String name = scanner.nextLine();
|
String name = scanner.nextLine();
|
||||||
|
|
||||||
System.out.println("Greetings, " + name + ". May we know your role? \n");
|
System.out.println("Greetings, " + TextColor.Cyan + name + TextColor.Reset +". May we know your role? \n");
|
||||||
|
|
||||||
player = RoleMenu(name);
|
player = RoleMenu(name);
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
|
|
||||||
boolean continueLoop = false;
|
boolean continueLoop = false;
|
||||||
do {
|
do {
|
||||||
System.out.println(GetLocationIntro(location));
|
System.out.println(TextColor.Cyan + GetLocationIntro(location) + TextColor.Reset);
|
||||||
System.out.println("What do you do, " + player.Name + "?");
|
System.out.println("What do you do, " + player.Name + "?");
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"""
|
"""
|
||||||
@@ -113,7 +113,7 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
case Jungle jungle ->
|
case Jungle jungle ->
|
||||||
player.Name + " enters the woods, after a few steps, they see a green goblin searching for food a few steps away";
|
player.Name + " enters the woods, after a few steps, they see a green goblin searching for food a few steps away";
|
||||||
case GraveYard graveYard ->
|
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!";
|
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 ->
|
case DarkCaves darkCaves ->
|
||||||
player.Name + " dives into the darkness. As our hero was going deeper, a black smoke appears, a vampire is nearby...";
|
player.Name + " dives into the darkness. As our hero was going deeper, a black smoke appears, a vampire is nearby...";
|
||||||
case Castle castle ->
|
case Castle castle ->
|
||||||
@@ -125,7 +125,7 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
public void MarketPlace() {
|
public void MarketPlace() {
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
System.out.println("You've entered the marketplace, what would you like to do?");
|
System.out.println(TextColor.Cyan + "You've entered the marketplace, what would you like to do?" + TextColor.Reset);
|
||||||
boolean wantsToStay = true;
|
boolean wantsToStay = true;
|
||||||
while (wantsToStay) {
|
while (wantsToStay) {
|
||||||
System.out.println("Money = " + player.GetMoney() + "\n");
|
System.out.println("Money = " + player.GetMoney() + "\n");
|
||||||
@@ -137,15 +137,21 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
4 > Sell the costumes
|
4 > Sell the costumes
|
||||||
5 > Sell the Weapons
|
5 > Sell the Weapons
|
||||||
6 > Buy shields
|
6 > Buy shields
|
||||||
7 > Buy shields
|
7 > Buy weapon
|
||||||
8 > Buy shields
|
8 > Buy costume
|
||||||
9 > Exit
|
9 > Exit
|
||||||
""");
|
""");
|
||||||
|
|
||||||
int choice = scanner.nextInt();
|
int choice = scanner.nextInt();
|
||||||
|
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 0 -> DisplayItem.DisplayItems(player.GetInventory());
|
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 -> {
|
case 1 -> {
|
||||||
player.SellByClass(ItemClass.UNNECESSARY);
|
player.SellByClass(ItemClass.UNNECESSARY);
|
||||||
System.out.println(TextColor.Green + "Unnecessary goods sold" + TextColor.Reset);
|
System.out.println(TextColor.Green + "Unnecessary goods sold" + TextColor.Reset);
|
||||||
@@ -171,8 +177,13 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
|
|
||||||
System.out.println(TextColor.Blue + "Current shield: ");
|
System.out.println(TextColor.Blue + "Current shield: ");
|
||||||
ArrayList<Item> item = new ArrayList<>();
|
ArrayList<Item> item = new ArrayList<>();
|
||||||
item.add(player.Shield);
|
if (player.Shield == null) {
|
||||||
DisplayItem.DisplayItems(item);
|
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);
|
System.out.println(TextColor.Reset);
|
||||||
|
|
||||||
ArrayList<Item> items = new ArrayList<>(Arrays.asList(Shields.getShields()));
|
ArrayList<Item> items = new ArrayList<>(Arrays.asList(Shields.getShields()));
|
||||||
@@ -185,7 +196,8 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
|
|
||||||
if (accessory != null) {
|
if (accessory != null) {
|
||||||
if (player.GetMoney() >= accessory.GetPrice()) {
|
if (player.GetMoney() >= accessory.GetPrice()) {
|
||||||
accessory.AttachTo(player);
|
if (player.Shield != null) player.Shield.DeattachFrom(player, true);
|
||||||
|
accessory.AttachTo(player, false);
|
||||||
player.ModifyMoney(accessory.GetPrice(), false);
|
player.ModifyMoney(accessory.GetPrice(), false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -198,8 +210,13 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
|
|
||||||
System.out.println(TextColor.Blue + "Current weapon: ");
|
System.out.println(TextColor.Blue + "Current weapon: ");
|
||||||
ArrayList<Item> item = new ArrayList<>();
|
ArrayList<Item> item = new ArrayList<>();
|
||||||
item.add(player.Weapon);
|
if (player.Weapon == null) {
|
||||||
DisplayItem.DisplayItems(item);
|
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);
|
System.out.println(TextColor.Reset);
|
||||||
|
|
||||||
ArrayList<Item> items = new ArrayList<>(Arrays.asList(Weapons.getWeapons()));
|
ArrayList<Item> items = new ArrayList<>(Arrays.asList(Weapons.getWeapons()));
|
||||||
@@ -212,7 +229,8 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
|
|
||||||
if (accessory != null) {
|
if (accessory != null) {
|
||||||
if (player.GetMoney() >= accessory.GetPrice()) {
|
if (player.GetMoney() >= accessory.GetPrice()) {
|
||||||
accessory.AttachTo(player);
|
if (player.Weapon != null) player.Weapon.DeattachFrom(player, true);
|
||||||
|
accessory.AttachTo(player, false);
|
||||||
player.ModifyMoney(accessory.GetPrice(), false);
|
player.ModifyMoney(accessory.GetPrice(), false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -225,8 +243,13 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
|
|
||||||
System.out.println(TextColor.Blue + "Current costume: ");
|
System.out.println(TextColor.Blue + "Current costume: ");
|
||||||
ArrayList<Item> item = new ArrayList<>();
|
ArrayList<Item> item = new ArrayList<>();
|
||||||
item.add(player.Costume);
|
if (player.Costume == null) {
|
||||||
DisplayItem.DisplayItems(item);
|
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);
|
System.out.println(TextColor.Reset);
|
||||||
|
|
||||||
ArrayList<Item> items = new ArrayList<>(Arrays.asList(Costumes.getCostumes()));
|
ArrayList<Item> items = new ArrayList<>(Arrays.asList(Costumes.getCostumes()));
|
||||||
@@ -239,7 +262,8 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
|
|
||||||
if (accessory != null) {
|
if (accessory != null) {
|
||||||
if (player.GetMoney() >= accessory.GetPrice()) {
|
if (player.GetMoney() >= accessory.GetPrice()) {
|
||||||
accessory.AttachTo(player);
|
if (player.Costume != null) player.Costume.DeattachFrom(player, true);
|
||||||
|
accessory.AttachTo(player, false);
|
||||||
player.ModifyMoney(accessory.GetPrice(), false);
|
player.ModifyMoney(accessory.GetPrice(), false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -255,7 +279,8 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
public void InventoryView() {
|
public void InventoryView() {
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
System.out.println("You open your inventory, what would you like to do?");
|
System.out.println(TextColor.Cyan + "You open your inventory, what would you like to do?\n" + TextColor.Reset);
|
||||||
|
|
||||||
boolean wantsToStay = true;
|
boolean wantsToStay = true;
|
||||||
while (wantsToStay) {
|
while (wantsToStay) {
|
||||||
System.out.println("Money = " + player.GetMoney() + "\n");
|
System.out.println("Money = " + player.GetMoney() + "\n");
|
||||||
@@ -270,10 +295,20 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
int choice = scanner.nextInt();
|
int choice = scanner.nextInt();
|
||||||
|
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 0 -> DisplayItem.DisplayItems(player.GetInventory());
|
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 -> {
|
case 1 -> {
|
||||||
System.out.println(TextColor.Blue + "Current shield: ");
|
System.out.println(TextColor.Blue + "Current shield: ");
|
||||||
ArrayList<Item> item = new ArrayList<>();
|
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);
|
item.add(player.Shield);
|
||||||
DisplayItem.DisplayItems(item);
|
DisplayItem.DisplayItems(item);
|
||||||
System.out.println(TextColor.Reset);
|
System.out.println(TextColor.Reset);
|
||||||
@@ -285,12 +320,17 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
Item shield = dictionary.get(index);
|
Item shield = dictionary.get(index);
|
||||||
|
|
||||||
if (shield != null) {
|
if (shield != null) {
|
||||||
((Accessory) shield).AttachTo(player);
|
if (player.Shield != null) player.Shield.DeattachFrom(player, true);
|
||||||
|
((Accessory) shield).AttachTo(player, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 2 -> {
|
case 2 -> {
|
||||||
System.out.println(TextColor.Blue + "Current weapon: ");
|
System.out.println(TextColor.Blue + "Current weapon: ");
|
||||||
ArrayList<Item> item = new ArrayList<>();
|
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);
|
item.add(player.Weapon);
|
||||||
DisplayItem.DisplayItems(item);
|
DisplayItem.DisplayItems(item);
|
||||||
System.out.println(TextColor.Reset);
|
System.out.println(TextColor.Reset);
|
||||||
@@ -302,12 +342,17 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
Item weapon = dictionary.get(index);
|
Item weapon = dictionary.get(index);
|
||||||
|
|
||||||
if (weapon != null) {
|
if (weapon != null) {
|
||||||
((Accessory) weapon).AttachTo(player);
|
if (player.Weapon != null) player.Weapon.DeattachFrom(player, true);
|
||||||
|
((Accessory) weapon).AttachTo(player, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 3 -> {
|
case 3 -> {
|
||||||
System.out.println(TextColor.Blue + "Current costume: ");
|
System.out.println(TextColor.Blue + "Current costume: ");
|
||||||
ArrayList<Item> item = new ArrayList<>();
|
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);
|
item.add(player.Costume);
|
||||||
DisplayItem.DisplayItems(item);
|
DisplayItem.DisplayItems(item);
|
||||||
System.out.println(TextColor.Reset);
|
System.out.println(TextColor.Reset);
|
||||||
@@ -319,7 +364,8 @@ public class SinglePlayerEngine extends MainEngine {
|
|||||||
Item costume = dictionary.get(index);
|
Item costume = dictionary.get(index);
|
||||||
|
|
||||||
if (costume != null) {
|
if (costume != null) {
|
||||||
((Accessory) costume).AttachTo(player);
|
if (player.Costume != null) player.Costume.DeattachFrom(player, true);
|
||||||
|
((Accessory) costume).AttachTo(player, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 4 -> wantsToStay = false;
|
case 4 -> wantsToStay = false;
|
||||||
|
|||||||
@@ -56,6 +56,32 @@ public abstract class Entity implements IDamageable, IHealable, IDefendable, IFi
|
|||||||
|
|
||||||
protected Entity() {}
|
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 int GetStamina() { return Stamina; }
|
||||||
|
|
||||||
public void ResetStamina() { Stamina = MaxStamina; }
|
public void ResetStamina() { Stamina = MaxStamina; }
|
||||||
@@ -68,10 +94,11 @@ public abstract class Entity implements IDamageable, IHealable, IDefendable, IFi
|
|||||||
Stamina = MaxStamina;
|
Stamina = MaxStamina;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
Stamina -= amount;
|
Stamina -= amount;
|
||||||
if (Stamina < 0) {
|
if (Stamina < 0) {
|
||||||
Stamina = 0;
|
Stamina = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +173,7 @@ public abstract class Entity implements IDamageable, IHealable, IDefendable, IFi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void TakeDamage(int amount, AttackPowerUp[] powerUps) {
|
public void TakeDamage(int amount, AttackPowerUp[] powerUps) {
|
||||||
if (!defencePowerUps.contains(DefencePowerUp.INVISIBLE)) return;
|
if (defencePowerUps != null && !defencePowerUps.contains(DefencePowerUp.INVISIBLE)) return;
|
||||||
|
|
||||||
IDefender[] defenders = GetDefenders();
|
IDefender[] defenders = GetDefenders();
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,15 @@ public class Dragon extends Enemy {
|
|||||||
this("Dragon", 5000, 5000, 0, 100, EntityState.ALIVE, null, null, null, new ArrayList<>(){}, 50, false, 50, 500, 500, 1000);
|
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
|
@Override
|
||||||
public void DropLoot(Player player) {
|
public void DropLoot(Player player) {
|
||||||
Key.Owner = player;
|
Key.Owner = player;
|
||||||
|
|||||||
@@ -36,6 +36,14 @@ public abstract class Enemy extends Entity {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Enemy(Enemy other) {
|
||||||
|
super(other);
|
||||||
|
this.Key = new KeyItem(other.Key.getName(), other.Key.Owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Enemy copy();
|
||||||
|
|
||||||
public void DropLoot(Player player) {
|
public void DropLoot(Player player) {
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,15 @@ public class Goblin extends Enemy {
|
|||||||
this("Goblin", 75, 75, 100, 10, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 15, 100, 100, 50);
|
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
|
@Override
|
||||||
public void SpecialAbility(Entity entity) {
|
public void SpecialAbility(Entity entity) {
|
||||||
ModifyStamina(SpecialAbilityStamina, false);
|
ModifyStamina(SpecialAbilityStamina, false);
|
||||||
|
|||||||
@@ -29,6 +29,15 @@ public class Skeleton extends Enemy {
|
|||||||
this("Skeleton", 125, 125, 200, 15, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 20, 100, 100, 100);
|
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
|
@Override
|
||||||
public ArrayList<FightMoves> GetAvailableMoves() {
|
public ArrayList<FightMoves> GetAvailableMoves() {
|
||||||
if (GetState() == EntityState.FROZEN || GetState() == EntityState.DEAD) return new ArrayList<>(){};
|
if (GetState() == EntityState.FROZEN || GetState() == EntityState.DEAD) return new ArrayList<>(){};
|
||||||
|
|||||||
@@ -25,6 +25,15 @@ public class Vampire extends Enemy {
|
|||||||
this("Vampire", 150, 150, 300, 20, EntityState.ALIVE, null, null, null, new ArrayList<>(), 8, false, 30, 100, 100, 150);
|
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
|
@Override
|
||||||
public void SpecialAbility(Entity entity) {
|
public void SpecialAbility(Entity entity) {
|
||||||
int curHealth = entity.Health;
|
int curHealth = entity.Health;
|
||||||
|
|||||||
@@ -27,12 +27,19 @@ public class Assassin extends Player {
|
|||||||
this(name, 125, 125, 100, 15, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 35, 100, 100, 1, 0);
|
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
|
@Override
|
||||||
public void SpecialAbility(Entity entity) {
|
public void SpecialAbility(Entity entity) {
|
||||||
ModifyStamina(SpecialAbilityStamina, false);
|
ModifyStamina(SpecialAbilityStamina, false);
|
||||||
entity.SetState(EntityState.FROZEN);
|
|
||||||
Damage(entity, GetDamage() * 3, new AttackPowerUp[]{AttackPowerUp.NO_DEFENSE});
|
Damage(entity, GetDamage() * 3, new AttackPowerUp[]{AttackPowerUp.NO_DEFENSE});
|
||||||
Heal(MaxHealth/4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,15 @@ public class Knight extends Player {
|
|||||||
this(name, 150, 150, 100, 20, EntityState.ALIVE, null, null, null, new ArrayList<>(), 8, false, 30, 100, 100, 1, 0);
|
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
|
@Override
|
||||||
public void SpecialAbility(Entity entity) {
|
public void SpecialAbility(Entity entity) {
|
||||||
ModifyStamina(SpecialAbilityStamina, false);
|
ModifyStamina(SpecialAbilityStamina, false);
|
||||||
@@ -36,7 +45,7 @@ public class Knight extends Player {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetSpecialAbilityDescription(Entity entity) {
|
public String GetSpecialAbilityDescription(Entity entity) {
|
||||||
return "Slam " + entity.Name + "with your unstoppable strength and stun them for the next turn";
|
return "Slam " + entity.Name + " with your unstoppable strength and stun them for the next turn";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -29,9 +29,18 @@ public abstract class Player extends Entity {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Player(Player other) {
|
||||||
|
super(other);
|
||||||
|
this.Level = other.Level;
|
||||||
|
this.LevelProgress = other.LevelProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Player copy();
|
||||||
|
|
||||||
public void LevelUpTo(int level) {
|
public void LevelUpTo(int level) {
|
||||||
while (Level < level) {
|
while (Level < level) {
|
||||||
LevelUp();
|
UnconditionalLevelUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,19 +52,23 @@ public abstract class Player extends Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UnconditionalLevelUp() {
|
||||||
|
Level++;
|
||||||
|
double upgradeRatio = (1.1 + ((double) Level * 0.02));
|
||||||
|
int gift = Level * 10;
|
||||||
|
|
||||||
|
MaxStamina = (int) (MaxStamina * upgradeRatio);
|
||||||
|
MaxHealth = (int) (MaxHealth * upgradeRatio);
|
||||||
|
BaseDamage = (int) (BaseDamage * upgradeRatio);
|
||||||
|
DefenseBonus = (int) (DefenseBonus * upgradeRatio);
|
||||||
|
HealAmount = (int) (HealAmount * upgradeRatio);
|
||||||
|
ModifyMoney(gift, true);
|
||||||
|
}
|
||||||
|
|
||||||
public void LevelUp() {
|
public void LevelUp() {
|
||||||
while (LevelProgress >= 100) {
|
while (LevelProgress >= 100) {
|
||||||
Level++;
|
UnconditionalLevelUp();
|
||||||
double upgradeRatio = (1.1 + ((double) Level * 0.02));
|
|
||||||
int gift = Level * 10;
|
|
||||||
|
|
||||||
LevelProgress -= 100;
|
LevelProgress -= 100;
|
||||||
MaxStamina = (int) (MaxStamina * upgradeRatio);
|
|
||||||
MaxHealth = (int) (MaxHealth * upgradeRatio);
|
|
||||||
BaseDamage = (int) (BaseDamage * upgradeRatio);
|
|
||||||
DefenseBonus = (int) (DefenseBonus * upgradeRatio);
|
|
||||||
HealAmount = (int) (HealAmount * upgradeRatio);
|
|
||||||
ModifyMoney(gift, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,15 +77,15 @@ public abstract class Player extends Entity {
|
|||||||
int damage = GetDamage();
|
int damage = GetDamage();
|
||||||
|
|
||||||
Damage(target, (int)(damage * 0.5), new AttackPowerUp[]{});
|
Damage(target, (int)(damage * 0.5), new AttackPowerUp[]{});
|
||||||
ModifyStamina(MaxStamina/8, true);
|
ModifyStamina(MaxStamina/8, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void HeavyAttack(IDamageable target) {
|
public void HeavyAttack(IDamageable target) {
|
||||||
int damage = GetDamage();
|
int damage = GetDamage();
|
||||||
ModifyStamina(HeavyAttackStamina, false);
|
|
||||||
|
|
||||||
Damage(target, damage, new AttackPowerUp[]{});
|
Damage(target, damage, new AttackPowerUp[]{});
|
||||||
|
ModifyStamina(HeavyAttackStamina, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,6 +27,15 @@ public class Wizard extends Player {
|
|||||||
this(name, 100, 100, 100, 15, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 40, 100, 100, 1, 0);
|
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
|
@Override
|
||||||
public void SpecialAbility(Entity entity) {
|
public void SpecialAbility(Entity entity) {
|
||||||
ModifyStamina(SpecialAbilityStamina, false);
|
ModifyStamina(SpecialAbilityStamina, false);
|
||||||
|
|||||||
@@ -45,13 +45,13 @@ public abstract class Accessory extends SellableItem implements IDamageable, IAt
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void HandleZeroHealth() {
|
public void HandleZeroHealth() {
|
||||||
this.DeattachFrom(this.Owner);
|
this.DeattachFrom(this.Owner, false);
|
||||||
this.Owner.Inventory.remove(this);
|
this.Owner.Inventory.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract void AttachTo(Entity entity);
|
public abstract void AttachTo(Entity entity, boolean fromInventory);
|
||||||
|
|
||||||
@Override
|
@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
|
@Override
|
||||||
public void AttachTo(Entity entity) {
|
public void AttachTo(Entity entity, boolean fromInventory) {
|
||||||
entity.RemoveFromInventory(this);
|
if (fromInventory) entity.RemoveFromInventory(this);
|
||||||
entity.Costume = this;
|
entity.Costume = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void DeattachFrom(Entity entity) {
|
public void DeattachFrom(Entity entity, boolean toInventory) {
|
||||||
entity.Costume = null;
|
entity.Costume = null;
|
||||||
entity.AddToInventory(this);
|
if (toInventory) entity.AddToInventory(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,14 +35,14 @@ public class Shield extends Accessory implements IDefender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void AttachTo(Entity entity) {
|
public void AttachTo(Entity entity, boolean fromInventory) {
|
||||||
entity.RemoveFromInventory(this);
|
if (fromInventory) entity.RemoveFromInventory(this);
|
||||||
entity.Shield = this;
|
entity.Shield = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void DeattachFrom(Entity entity) {
|
public void DeattachFrom(Entity entity, boolean toInventory) {
|
||||||
entity.Shield = null;
|
entity.Shield = null;
|
||||||
entity.AddToInventory(this);
|
if (toInventory) entity.AddToInventory(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ public class Weapon extends Accessory implements IDamageUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void AttachTo(Entity entity) {
|
public void AttachTo(Entity entity, boolean fromInventory) {
|
||||||
entity.RemoveFromInventory(this);
|
if (fromInventory) entity.RemoveFromInventory(this);
|
||||||
entity.Weapon = this;
|
entity.Weapon = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void DeattachFrom(Entity entity) {
|
public void DeattachFrom(Entity entity, boolean toInventory) {
|
||||||
entity.Weapon = null;
|
entity.Weapon = null;
|
||||||
entity.AddToInventory(this);
|
if (toInventory) entity.AddToInventory(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import java.util.Hashtable;
|
|||||||
public class DisplayItem {
|
public class DisplayItem {
|
||||||
public static void DisplayItems(ArrayList<Item> items) {
|
public static void DisplayItems(ArrayList<Item> items) {
|
||||||
for (Item item : items) {
|
for (Item item : items) {
|
||||||
|
if (item == null) continue;
|
||||||
|
|
||||||
String result = item.getName();
|
String result = item.getName();
|
||||||
|
|
||||||
if (item instanceof SellableItem) {
|
if (item instanceof SellableItem) {
|
||||||
@@ -30,7 +32,7 @@ public class DisplayItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (item instanceof IDefender) {
|
if (item instanceof IDefender) {
|
||||||
result += "\n Damage = " + ((IDefender) item).GetDefense();
|
result += "\n Defence = " + ((IDefender) item).GetDefense();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(result);
|
System.out.println(result);
|
||||||
@@ -42,6 +44,8 @@ public class DisplayItem {
|
|||||||
Dictionary<Integer, Item> dictionary = new Hashtable<>();
|
Dictionary<Integer, Item> dictionary = new Hashtable<>();
|
||||||
|
|
||||||
for (Item item : items) {
|
for (Item item : items) {
|
||||||
|
if (item == null) continue;
|
||||||
|
|
||||||
String result = index + " > " + item.getName();
|
String result = index + " > " + item.getName();
|
||||||
|
|
||||||
if (item instanceof KeyItem) {
|
if (item instanceof KeyItem) {
|
||||||
@@ -61,7 +65,7 @@ public class DisplayItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (item instanceof IDefender) {
|
if (item instanceof IDefender) {
|
||||||
result += "\n Damage = " + ((IDefender) item).GetDefense();
|
result += "\n Defence = " + ((IDefender) item).GetDefense();
|
||||||
}
|
}
|
||||||
|
|
||||||
dictionary.put(index, item);
|
dictionary.put(index, item);
|
||||||
|
|||||||
Reference in New Issue
Block a user