Implement minor changes in game start function

This commit is contained in:
2026-05-09 14:42:00 +03:30
parent eaa0640a9c
commit f07c1416df
@@ -20,11 +20,6 @@ public class MenuActions {
public void startGame(Player player) {
while (player.getKeysCollectedCount() < 3) {
// System.out.println("Keys collected: " + player.getStringKeysCollected());
// if (askInventory(player)) {
//
// };
askInventory(player);
Enemy enemy = chooseEnemy();
Entity winner = fight(player, enemy);
@@ -34,22 +29,25 @@ public class MenuActions {
}
}
if (player.getKeysCollectedCount() == 3) {
askInventory(player);
System.out.println("Congratulations! You have successfully collected all 3 keys\n" +
"You may now fight the Dragon");
System.out.println("Make sure to upgrade before entering the castle!");
askInventory(player);
System.out.println("Entering the castle...");
Entity winner = fight(player, new Dragon());
if (winner != player) {
System.out.println("You were killed by the dragon. Game over!\nreturning to main menu...");
} else {
System.out.println("Congratulations! You killed the dragon and saved Javanest!");
}
bossFight(player);
}
}
private void bossFight(Player player) {
System.out.println("Congratulations! You have successfully collected all 3 keys\n" +
"You may now fight the Dragon");
System.out.println("Make sure to upgrade before entering the castle!");
askInventory(player);
System.out.println("Entering the castle...");
Entity winner = fight(player, new Dragon());
if (winner != player) {
System.out.println("You were killed by the dragon. Game over!\nreturning to main menu...");
} else {
System.out.println("Congratulations! You killed the dragon and saved Javanest!");
}
}
private Enemy chooseEnemy() {
while (true) {
Location location = new Location();
@@ -145,14 +143,14 @@ public class MenuActions {
int choice = random.nextInt(3) + 1;
switch (choice) {
case 1: enemy.getWeapon().lightAttack(player);
System.out.println(enemy.getType() + "attacked(light)!"); return;
System.out.println(enemy.getType() + " attacked(light)!"); return;
case 2: if(enemy.getMp() >= enemy.getWeapon().getManaCost()) {
enemy.getWeapon().heavyAttack(enemy, player);
System.out.println(enemy.getType() + "attacked(Heavy)!"); return;
System.out.println(enemy.getType() + " attacked(Heavy)!"); return;
} break;
case 3: if (enemy.getMp() >= enemy.getWeapon().getSpecialMana()){
enemy.getWeapon().useSpecialAbility(enemy, player);
System.out.println(enemy.getType() + "used special ability!"); return;
System.out.println(enemy.getType() + " used special ability!"); return;
} break;
// case 4: if (enemy.getMp() >= enemy.getDefendManaCost()) {
// enemy.defend(); return;