Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void play(Player p, Scanner input, Random rand) {

int count = 0;

while (p.health > 0 && e.HP > 0) {
while (p.getHealth()> 0 && e.HP > 0) {
p.showProfile();

if (count % 2 == 0) {
Expand Down Expand Up @@ -66,7 +66,7 @@ public static void play(Player p, Scanner input, Random rand) {
}
}

if (p.health <= 0) {
if (p.getHealth() <= 0) {
System.out.println(RED + "\n __ __ _______ __ __ ______ ___ _______ ______ ");
System.out.println("| | | || || | | | | | | | | || | ");
System.out.println("| |_| || _ || | | | | _ || | | ___|| _ |");
Expand All @@ -85,7 +85,7 @@ public static void play(Player p, Scanner input, Random rand) {
if (choice == 1) {
stage++;
p.health += 3;
if (p.health > p.maxHealth) p.health = p.maxHealth;
if (p.getHealth() < p.getMaxHealth()) p.setHealth(p.getHealth() + 3);
System.out.println("You rested for a moment. HP restored by 3.");
} else {
System.out.println("You retired as a legendary hero at Stage " + stage + "!");
Expand Down
3 changes: 3 additions & 0 deletions src/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public Player(String nickname) {
public int getDamage() {
return this.damage;
}
public int getHealth() { return this.health; }
public void setHealth(int health) { this.health = health; }
public int getMaxHealth() { return this.maxHealth; }

public abstract boolean attack(Enemy enemy);
public abstract boolean heal();
Expand Down
8 changes: 8 additions & 0 deletions src/PlayerDecorator.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ public PlayerDecorator(Player p) {
public int getDamage() {
return wrappedPlayer.getDamage();
}
@Override
public int getHealth() { return wrappedPlayer.getHealth(); }

@Override
public void setHealth(int health) { wrappedPlayer.setHealth(health); }

@Override
public int getMaxHealth() { return wrappedPlayer.getMaxHealth(); }

@Override
public boolean attack(Enemy enemy) {
Expand Down
Loading