java-ascii-game/src/Player.java
2024-06-08 00:43:15 +02:00

47 lines
1.1 KiB
Java

import processing.core.PApplet;
import java.util.ArrayList;
import java.util.List;
/**
* This is the main player of the game we can move around with and interact.
*/
public class Player extends Fightable implements Health {
int health;
int maxHealth = 20;
List<Skill> skills = new ArrayList<Skill>();
Skill skill = new Tritt(window, this);
Player(Fenster window) {
super(window);
this.type = "@";
pos.set_on_grid(20, 20);
this.health = maxHealth;
this.skills.add(new Tritt(window, (Fightable) window.player));
}
Player(Fenster window, int exp, Position pos, int level) {
super(window);
this.experience = exp;
this.pos = pos;
this.level = level;
}
public void damage(int damage) {
health = health - damage;
if (health <= 0) {
health = 0;
window.dead();
}
}
public void heal(int healing) {
health = health + healing;
if (health > maxHealth) {
health = maxHealth;
}
}
}