implement repairKit in Game class

This commit is contained in:
2026-05-11 12:49:36 +03:30
parent c80c0425b1
commit ed48aaf7d9
3 changed files with 5 additions and 2 deletions
@@ -5,6 +5,7 @@ import org.project.entity.players.Assassin;
import org.project.entity.players.Knight; import org.project.entity.players.Knight;
import org.project.entity.players.Player; import org.project.entity.players.Player;
import org.project.entity.players.Wizard; import org.project.entity.players.Wizard;
import org.project.item.consumables.repairKit;
import org.project.location.Location; import org.project.location.Location;
import java.util.ArrayList; import java.util.ArrayList;
@@ -160,7 +161,7 @@ public class Game {
if (turn == 0) { if (turn == 0) {
System.out.println("Choose your action:"); System.out.println("Choose your action:");
System.out.println("1. Light attack 2. Heavy attack 3. Defend" + System.out.println("1. Light attack 2. Heavy attack 3. Defend" +
" 4. Heal 5. Special ability 6. Flask"); " 4. Heal 5. Special ability 6. Flask 7.Repair Kit");
int choice = sc.nextInt(); int choice = sc.nextInt();
boolean actionTaken = handlePlayerAction(choice, enemy); boolean actionTaken = handlePlayerAction(choice, enemy);
if (!actionTaken) continue; if (!actionTaken) continue;
@@ -210,6 +211,7 @@ public class Game {
case 4 -> { player.heal(10); return player.isSuccessfulAction(); } case 4 -> { player.heal(10); return player.isSuccessfulAction(); }
case 5 -> { player.specialAbility(enemy); return player.isSuccessfulAction(); } case 5 -> { player.specialAbility(enemy); return player.isSuccessfulAction(); }
case 6 -> { player.getFlask().use(player); return true; } case 6 -> { player.getFlask().use(player); return true; }
case 7 -> {new repairKit().use(player); return true;}
default -> { System.out.println("Invalid choice."); return false; } default -> { System.out.println("Invalid choice."); return false; }
} }
} }
@@ -38,6 +38,7 @@ public abstract class Player implements Entity, CombatOptions {
this.maxMP = mp; this.maxMP = mp;
this.weapon = weapon; this.weapon = weapon;
this.armor = armor; this.armor = armor;
} }
@Override @Override
@@ -16,6 +16,6 @@ public class repairKit extends Consumable{
} }
((Player) (target)).getArmor().repair(); ((Player) (target)).getArmor().repair();
consume(); consume();
System.out.println("(" + getQuantity() + " charges remaining)"); System.out.println("Armor repaired!");
} }
} }