Skip to content
Closed
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
36 changes: 33 additions & 3 deletions src/main/java/Character.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
class Character implements Combatant {
abstract class Character implements Combatant {
// 🗒️ PROPIEDADES
protected String name;
protected int health;
// le falta el status
protected Status status;

// 🏗️ CONSTRUCTOR
protected Character(String name, int health) {
this.name = name;
this.health = health;
// el status inicial debe ser siempre REGULAR
this.status = Status.REGULAR;
}

@Override
public void receiveDamage(int damage) {
this.health -= damage;
System.out.println(this.name + " ha recibido " + damage + " de daño");
if (!this.isAlive()) {
this.health = 0;
this.status = Status.DEAD;
System.out.println(this.name + " ha muerto");
}
}

@Override
public boolean isAlive() {
return health > 0;
}

@Override
public int getCurrentHealth() {
return this.health;
}

@Override
public String getName() {
return this.name;
}

@Override
public String getStatus() {
return this.status.name();
}
}