SAe/SAe2.1/commentente/SAé/Heros.java
2023-06-23 13:40:21 +02:00

77 lines
1.6 KiB
Java

public class Heros extends Case {
private Arme arme;
private int pv;
public Heros(int x, int y, String t, int pdv) {
super(x, y, t);
this.pv = pdv;
this.arme = new Arme(0, x, y, "arme");
}
public String getLabelPv() {
return String.valueOf(this.pv);
}
public int getPv(){
return this.pv;
}
public void setPv(int pdv){
this.pv=pdv;
}
public Arme getArme(){
return this.arme;
}
public void setArme(int atk, String type){
this.arme.value=atk;
this.arme.type=type;
}
public boolean rencontrer(Case c) {
if (c.type.equals("or")) {
return true;
}
if (c.type.equals("arme")) {
return true;
}
if (c.type.equals("armefeu")) {
return true;
}
if (c.type.equals("armeglace")) {
return true;
}
if (c.type.equals("potion")) {
if (this.type.equals("mage")){
this.pv += c.getValue();
}
this.pv += c.getValue();
return true;
}
if (c.type.equals("monstre")) {
if (this.arme.value > 0) {
return false;
} else {
return true;
}
}
if (c.type.equals("monstrefeu")) {
if (this.arme.value > 0) {
return false;
} else {
return true;
}
}
if (c.type.equals("monstreglace")) {
if (this.arme.value > 0) {
return false;
} else {
return true;
}
}
return false;
}
}