Develop #1
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,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();
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import java.util.Hashtable;
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class MultiPlayerBattleEngine extends BattleEngine {
|
public class MultiPlayerBattleEngine extends BattleEngine {
|
||||||
private Player player1;
|
private final Player player1;
|
||||||
private Player player2;
|
private final Player player2;
|
||||||
private Player player1Past;
|
private Player player1Past;
|
||||||
private Player player2Past;
|
private Player player2Past;
|
||||||
|
|
||||||
@@ -22,54 +22,67 @@ public class MultiPlayerBattleEngine extends BattleEngine {
|
|||||||
super(player1, player2);
|
super(player1, player2);
|
||||||
this.player1 = (Player) Player1;
|
this.player1 = (Player) Player1;
|
||||||
this.player2 = (Player) Player2;
|
this.player2 = (Player) Player2;
|
||||||
player1Past = null;
|
player1Past = player1.copy();
|
||||||
player2Past = null;
|
player2Past = player2.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void StartBattle() {
|
public void StartBattle() {
|
||||||
|
EntityDiff playerDiff;
|
||||||
|
EntityDiff enemyDiff;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
if (player1.GetState() != EntityState.FROZEN) {
|
||||||
FightMoves player1Move = PlayerMovesMenu(player1, player2);
|
FightMoves player1Move = PlayerMovesMenu(player1, player2);
|
||||||
showMoveExplanation(player1Move, 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) {
|
if (player1Past.GetState() == EntityState.FROZEN) {
|
||||||
player1.SetState(EntityState.ALIVE);
|
player1.SetState(EntityState.ALIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
player1Past = player1;
|
player1Past = player1.copy();
|
||||||
player2Past = player2;
|
player2Past = player2.copy();
|
||||||
|
|
||||||
EntityDiff playerDiff = getPlayerDiff(player1Past, player1);
|
|
||||||
EntityDiff enemyDiff = getPlayerDiff(player2Past, player2);
|
|
||||||
|
|
||||||
showFighter(playerDiff, player1);
|
|
||||||
showFighter(enemyDiff, player2);
|
|
||||||
|
|
||||||
|
if (player2.GetState() != EntityState.FROZEN)
|
||||||
|
{
|
||||||
FightMoves player2Move = PlayerMovesMenu(player2, player1);
|
FightMoves player2Move = PlayerMovesMenu(player2, player1);
|
||||||
showMoveExplanation(player2Move, player2, player1);
|
showMoveExplanation(player2Move, player2, player1Past);
|
||||||
|
|
||||||
if (player2Past.GetState() == EntityState.FROZEN) {
|
|
||||||
player2.SetState(EntityState.ALIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
player1Past = player1;
|
|
||||||
player2Past = player2;
|
|
||||||
|
|
||||||
playerDiff = getPlayerDiff(player1Past, player1);
|
playerDiff = getPlayerDiff(player1Past, player1);
|
||||||
enemyDiff = getPlayerDiff(player2Past, player2);
|
enemyDiff = getPlayerDiff(player2Past, player2);
|
||||||
|
|
||||||
|
System.out.println();
|
||||||
showFighter(playerDiff, player1);
|
showFighter(playerDiff, player1);
|
||||||
showFighter(enemyDiff, player2);
|
showFighter(enemyDiff, player2);
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
if (player2.GetState() == EntityState.DEAD) {
|
if (player2.GetState() == EntityState.DEAD) {
|
||||||
System.out.println(TextColor.Green + player1.Name + " WON!" + TextColor.Reset);
|
System.out.println(TextColor.Green + player1.Name + " WON!" + TextColor.Reset);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (player1.GetState() == EntityState.DEAD) {
|
|
||||||
System.out.println(TextColor.Green + player2.Name + " WON!" + TextColor.Reset);
|
if (player2Past.GetState() == EntityState.FROZEN) {
|
||||||
return;
|
player2.SetState(EntityState.ALIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player1Past = player1.copy();
|
||||||
|
player2Past = player2.copy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,10 +101,12 @@ public class MultiPlayerBattleEngine extends BattleEngine {
|
|||||||
System.out.println(entity.Name + ":");
|
System.out.println(entity.Name + ":");
|
||||||
|
|
||||||
String color = diff.health() > 0 ? TextColor.Green : TextColor.Red;
|
String color = diff.health() > 0 ? TextColor.Green : TextColor.Red;
|
||||||
System.out.println(" Health: " + entity.Health + " " + color + diff.health() + TextColor.Reset);
|
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;
|
color = diff.stamina() > 0 ? TextColor.Green : TextColor.Red;
|
||||||
System.out.println(" Stamina: " + entity.GetStamina() + " " + color + diff.stamina() + TextColor.Reset);
|
sign = diff.stamina() > 0 ? "+" : "-";
|
||||||
|
System.out.println(" Stamina: " + entity.GetStamina() + " " + color + sign + Math.abs(diff.stamina()) + TextColor.Reset);
|
||||||
|
|
||||||
if (diff.lostShield()) {
|
if (diff.lostShield()) {
|
||||||
System.out.println(" Shield: " + entity.Shield.getName() + " " + TextColor.Red + "LOST" + TextColor.Reset);
|
System.out.println(" Shield: " + entity.Shield.getName() + " " + TextColor.Red + "LOST" + TextColor.Reset);
|
||||||
@@ -103,12 +118,14 @@ public class MultiPlayerBattleEngine extends BattleEngine {
|
|||||||
|
|
||||||
if (entity.Shield != null) {
|
if (entity.Shield != null) {
|
||||||
color = diff.shieldHealth() > 0 ? TextColor.Green : TextColor.Red;
|
color = diff.shieldHealth() > 0 ? TextColor.Green : TextColor.Red;
|
||||||
System.out.println(" Shield: " + entity.Shield.getName() + " " + color + diff.shieldHealth() + TextColor.Reset);
|
sign = diff.shieldHealth() > 0 ? "+" : "-";
|
||||||
|
System.out.println(" Shield: " + entity.Shield.getName() + " " + color + sign + Math.abs(diff.shieldHealth()) + TextColor.Reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.Costume != null) {
|
if (entity.Costume != null) {
|
||||||
color = diff.costumeHealth() > 0 ? TextColor.Green : TextColor.Red;
|
color = diff.costumeHealth() > 0 ? TextColor.Green : TextColor.Red;
|
||||||
System.out.println(" Costume: " + entity.Costume.getName() + " " + color + diff.shieldHealth() + TextColor.Reset);
|
sign = diff.costumeHealth() > 0 ? "+" : "-";
|
||||||
|
System.out.println(" Costume: " + entity.Costume.getName() + " " + color + sign + Math.abs(diff.shieldHealth()) + TextColor.Reset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +173,7 @@ public class MultiPlayerBattleEngine extends BattleEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showMoveExplanation(FightMoves move, Entity performer, Entity receiver) {
|
private void showMoveExplanation(FightMoves move, Entity performer, Entity receiver) {
|
||||||
|
System.out.print(TextColor.Cyan);
|
||||||
switch (move) {
|
switch (move) {
|
||||||
case FightMoves.LIGHT_ATTACK -> System.out.println(performer.Name + " performs a light attack");
|
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.HEAVY_ATTACK -> System.out.println(performer.Name + " performs a heavy attack");
|
||||||
@@ -163,5 +181,6 @@ public class MultiPlayerBattleEngine extends BattleEngine {
|
|||||||
case FightMoves.HEAL -> System.out.println(performer.Name + " heals");
|
case FightMoves.HEAL -> System.out.println(performer.Name + " heals");
|
||||||
case FightMoves.DEFEND -> System.out.println(performer.Name + " get their guard up!");
|
case FightMoves.DEFEND -> System.out.println(performer.Name + " get their guard up!");
|
||||||
}
|
}
|
||||||
|
System.out.print(TextColor.Reset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,53 +14,60 @@ import java.util.Hashtable;
|
|||||||
import java.util.Scanner;
|
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 Player playerPast;
|
||||||
private Enemy enemyPast;
|
private Enemy enemyPast;
|
||||||
public SinglePlayerBattleEngine(Player player, Enemy enemy) {
|
public SinglePlayerBattleEngine(Player player, Enemy enemy) {
|
||||||
super(player, enemy);
|
super(player, enemy);
|
||||||
this.player = (Player) Player1;
|
this.player = (Player) Player1;
|
||||||
this.enemy = (Enemy) Player2;
|
this.enemy = (Enemy) Player2;
|
||||||
playerPast = null;
|
playerPast = player.copy();
|
||||||
enemyPast = null;
|
enemyPast = enemy.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void StartBattle() {
|
public void StartBattle() {
|
||||||
|
EntityDiff playerDiff;
|
||||||
|
EntityDiff enemyDiff;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
if (player.GetState() != EntityState.FROZEN) {
|
||||||
FightMoves playerMove = PlayerMovesMenu();
|
FightMoves playerMove = PlayerMovesMenu();
|
||||||
showMoveExplanation(playerMove, player, enemy);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
playerPast = player;
|
if (player.GetState() == EntityState.DEAD) {
|
||||||
enemyPast = enemy;
|
return;
|
||||||
|
|
||||||
EntityDiff playerDiff = getPlayerDiff(playerPast, player);
|
|
||||||
EntityDiff enemyDiff = getPlayerDiff(enemyPast, enemy);
|
|
||||||
|
|
||||||
showFighter(playerDiff, player);
|
|
||||||
showFighter(enemyDiff, enemy);
|
|
||||||
|
|
||||||
FightMoves botMove = enemy.PlayRound(player);
|
|
||||||
showMoveExplanation(botMove, enemy, player);
|
|
||||||
|
|
||||||
if (enemyPast.GetState() == EntityState.FROZEN) {
|
|
||||||
enemy.SetState(EntityState.ALIVE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playerPast = player;
|
playerPast = player.copy();
|
||||||
enemyPast = enemy;
|
enemyPast = enemy.copy();
|
||||||
|
|
||||||
|
if (enemy.GetState() != EntityState.FROZEN) {
|
||||||
|
FightMoves botMove = enemy.PlayRound(player);
|
||||||
|
showMoveExplanation(botMove, enemy, playerPast);
|
||||||
|
|
||||||
playerDiff = getPlayerDiff(playerPast, player);
|
playerDiff = getPlayerDiff(playerPast, player);
|
||||||
enemyDiff = getPlayerDiff(enemyPast, enemy);
|
enemyDiff = getPlayerDiff(enemyPast, enemy);
|
||||||
|
|
||||||
|
System.out.println();
|
||||||
showFighter(playerDiff, player);
|
showFighter(playerDiff, player);
|
||||||
showFighter(enemyDiff, enemy);
|
showFighter(enemyDiff, enemy);
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
if (enemy.GetState() == EntityState.DEAD) {
|
if (enemy.GetState() == EntityState.DEAD) {
|
||||||
enemy.DropLoot(player);
|
enemy.DropLoot(player);
|
||||||
@@ -68,9 +75,13 @@ public class SinglePlayerBattleEngine extends BattleEngine {
|
|||||||
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) {
|
|
||||||
return;
|
if (enemyPast.GetState() == EntityState.FROZEN) {
|
||||||
|
enemy.SetState(EntityState.ALIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playerPast = player.copy();
|
||||||
|
enemyPast = enemy.copy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,10 +100,12 @@ public class SinglePlayerBattleEngine extends BattleEngine {
|
|||||||
System.out.println(entity.Name + ":");
|
System.out.println(entity.Name + ":");
|
||||||
|
|
||||||
String color = diff.health() > 0 ? TextColor.Green : TextColor.Red;
|
String color = diff.health() > 0 ? TextColor.Green : TextColor.Red;
|
||||||
System.out.println(" Health: " + entity.Health + " " + color + diff.health() + TextColor.Reset);
|
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;
|
color = diff.stamina() > 0 ? TextColor.Green : TextColor.Red;
|
||||||
System.out.println(" Stamina: " + entity.GetStamina() + " " + color + diff.stamina() + TextColor.Reset);
|
sign = diff.stamina() > 0 ? "+" : "-";
|
||||||
|
System.out.println(" Stamina: " + entity.GetStamina() + " " + color + sign + Math.abs(diff.stamina()) + TextColor.Reset);
|
||||||
|
|
||||||
if (diff.lostShield()) {
|
if (diff.lostShield()) {
|
||||||
System.out.println(" Shield: " + entity.Shield.getName() + " " + TextColor.Red + "LOST" + TextColor.Reset);
|
System.out.println(" Shield: " + entity.Shield.getName() + " " + TextColor.Red + "LOST" + TextColor.Reset);
|
||||||
@@ -104,12 +117,14 @@ public class SinglePlayerBattleEngine extends BattleEngine {
|
|||||||
|
|
||||||
if (entity.Shield != null) {
|
if (entity.Shield != null) {
|
||||||
color = diff.shieldHealth() > 0 ? TextColor.Green : TextColor.Red;
|
color = diff.shieldHealth() > 0 ? TextColor.Green : TextColor.Red;
|
||||||
System.out.println(" Shield: " + entity.Shield.getName() + " " + color + diff.shieldHealth() + TextColor.Reset);
|
sign = diff.shieldHealth() > 0 ? "+" : "-";
|
||||||
|
System.out.println(" Shield: " + entity.Shield.getName() + " " + color + sign + Math.abs(diff.shieldHealth()) + TextColor.Reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.Costume != null) {
|
if (entity.Costume != null) {
|
||||||
color = diff.costumeHealth() > 0 ? TextColor.Green : TextColor.Red;
|
color = diff.costumeHealth() > 0 ? TextColor.Green : TextColor.Red;
|
||||||
System.out.println(" Costume: " + entity.Costume.getName() + " " + color + diff.shieldHealth() + TextColor.Reset);
|
sign = diff.costumeHealth() > 0 ? "+" : "-";
|
||||||
|
System.out.println(" Costume: " + entity.Costume.getName() + " " + color + sign + Math.abs(diff.shieldHealth()) + TextColor.Reset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +172,7 @@ public class SinglePlayerBattleEngine extends BattleEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showMoveExplanation(FightMoves move, Entity performer, Entity receiver) {
|
private void showMoveExplanation(FightMoves move, Entity performer, Entity receiver) {
|
||||||
|
System.out.print(TextColor.Cyan);
|
||||||
switch (move) {
|
switch (move) {
|
||||||
case FightMoves.LIGHT_ATTACK -> System.out.println(performer.Name + " performs a light attack");
|
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.HEAVY_ATTACK -> System.out.println(performer.Name + " performs a heavy attack");
|
||||||
@@ -164,5 +180,6 @@ public class SinglePlayerBattleEngine extends BattleEngine {
|
|||||||
case FightMoves.HEAL -> System.out.println(performer.Name + " heals");
|
case FightMoves.HEAL -> System.out.println(performer.Name + " heals");
|
||||||
case FightMoves.DEFEND -> System.out.println(performer.Name + " get their guard up!");
|
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<>();
|
||||||
|
if (player.Shield == null) {
|
||||||
|
System.out.println(TextColor.Red + "You do not have a Shield" + TextColor.Reset);
|
||||||
|
}
|
||||||
|
else {
|
||||||
item.add(player.Shield);
|
item.add(player.Shield);
|
||||||
DisplayItem.DisplayItems(item);
|
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<>();
|
||||||
|
if (player.Weapon == null) {
|
||||||
|
System.out.println(TextColor.Red + "You do not have a Weapon" + TextColor.Reset);
|
||||||
|
}
|
||||||
|
else {
|
||||||
item.add(player.Weapon);
|
item.add(player.Weapon);
|
||||||
DisplayItem.DisplayItems(item);
|
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<>();
|
||||||
|
if (player.Costume == null) {
|
||||||
|
System.out.println(TextColor.Red + "You do not have a Costume" + TextColor.Reset);
|
||||||
|
}
|
||||||
|
else {
|
||||||
item.add(player.Costume);
|
item.add(player.Costume);
|
||||||
DisplayItem.DisplayItems(item);
|
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user