85 lines
1.7 KiB
Java
85 lines
1.7 KiB
Java
|
package modeles;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
|
||
|
public class Personnage extends EtreVivant {
|
||
|
|
||
|
private Arme arme;
|
||
|
private Armure armure;
|
||
|
private Bourse bourse;
|
||
|
private List<Potion> listepotion= new ArrayList<Potion>();
|
||
|
|
||
|
public Personnage(String nom, int pVieMax,int pAttaque, Salle salle) {
|
||
|
super(nom, pVieMax, pAttaque, salle);
|
||
|
}
|
||
|
|
||
|
public void equiper(Arme arme) {
|
||
|
arme.setProprietaire(this);
|
||
|
this.arme=arme;
|
||
|
}
|
||
|
public void equiper(Armure armure) {
|
||
|
armure.setProprietaire(this);
|
||
|
this.armure=armure;
|
||
|
}
|
||
|
|
||
|
public void utiliser(Potion potion) {
|
||
|
soin();
|
||
|
}
|
||
|
|
||
|
public void seDeplacer(Salle salle) {
|
||
|
this.salle=salle;
|
||
|
}
|
||
|
|
||
|
public void allerMarche(Salle marche){
|
||
|
this.salle=marche;
|
||
|
}
|
||
|
|
||
|
public List<Potion> getPotion() {
|
||
|
return this.listepotion;
|
||
|
}
|
||
|
|
||
|
public void gagnerUnePotion() {
|
||
|
Potion potion=new Potion(100);
|
||
|
listepotion.add(potion);
|
||
|
}
|
||
|
|
||
|
public void soin() {
|
||
|
this.pVie=this.pVieMax;
|
||
|
}
|
||
|
|
||
|
public int attaquer(Monstre monstre) {
|
||
|
if(arme!=null) {
|
||
|
monstre.pVie=monstre.pVie-(arme.getpArme()+getpAttaque());
|
||
|
return arme.getpArme()+getpAttaque();
|
||
|
}
|
||
|
else {
|
||
|
monstre.pVie=monstre.pVie=getpAttaque();
|
||
|
return getpAttaque();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public Bourse getBourse() {
|
||
|
return this.bourse;
|
||
|
}
|
||
|
|
||
|
public void getValeurBourse() {
|
||
|
System.out.println(this.getBourse().getValeur());
|
||
|
}
|
||
|
/* @return the arme
|
||
|
*/
|
||
|
public Arme getArme() {
|
||
|
return arme;
|
||
|
}
|
||
|
|
||
|
/* @return the armure
|
||
|
*/
|
||
|
public Armure getArmure() {
|
||
|
return armure;
|
||
|
}
|
||
|
|
||
|
public void soin(int heal) {
|
||
|
if (pVie+heal > pVieMax)pVie=pVieMax;
|
||
|
else pVie+=heal;
|
||
|
}
|
||
|
}
|