-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlayer.java
71 lines (48 loc) · 1.5 KB
/
Player.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.util.Scanner;
// Classe que representa o jogador
class Player {
private String name;
private int health;
private int attackDamage;
public Player(int health, int attackDamage) {
Scanner scanner = new Scanner(System.in);
System.out.println("Qual o seu nome, pobre alma?");
this.name = scanner.nextLine();
this.health = health; // Saúde inicial do jogador
this.attackDamage = attackDamage; // Dano de ataque do jogador
}
public int getHealth() {
return this.health;
}
public void reduceHealth(int damage) {
this.health -= damage;
}
public void increaseHealth(int value) {
this.health += value;
}
public boolean isDefeated() {
return this.health <= 0;
}
public void increaseAttackDamage(int value) {
this.attackDamage += value;
}
public void decreaseAttackDamage(int value) {
this.attackDamage -= value;
}
public int attack(Enemy enemy) {
int damageDealt = calculateDamage();
enemy.reduceHealth(damageDealt);
return damageDealt;
}
private int calculateDamage() {
// Lógica para calcular o dano do jogador
// Exemplo simples: Dano fixo de 10
return 10;
}
public void collectTreasure(Treasure selectedTreasure) {
// Lógica para coletar o tesouro
}
public String getName() {
return this.name;
}
}