2019-05-14 10:56:57 +02:00
|
|
|
|
|
2019-05-13 22:51:42 +02:00
|
|
|
|
package modeles;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
2019-05-14 10:56:57 +02:00
|
|
|
|
import java.util.Random;
|
2019-05-13 22:51:42 +02:00
|
|
|
|
|
|
|
|
|
public class Personnage extends EtreVivant {
|
2019-05-14 10:56:57 +02:00
|
|
|
|
|
|
|
|
|
private Arme arme;
|
|
|
|
|
private Armure armure;
|
|
|
|
|
private Bourse bourse;
|
|
|
|
|
private List<Potion> listepotion= new ArrayList<Potion>();
|
|
|
|
|
|
|
|
|
|
public Personnage(String nom, int pVieMax,int pAttaque) {
|
|
|
|
|
super(nom, pVieMax, pAttaque);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void equiper(Arme arme) {
|
|
|
|
|
arme.setProprietaire(this);
|
|
|
|
|
this.arme=arme;
|
|
|
|
|
}
|
2019-05-13 22:51:42 +02:00
|
|
|
|
public void equiper(Armure armure) {
|
2019-05-14 10:56:57 +02:00
|
|
|
|
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());
|
2019-05-17 19:30:40 +02:00
|
|
|
|
if (monstre.pVie<=0)monstre.setVivant(false);
|
2019-05-14 10:56:57 +02:00
|
|
|
|
return arme.getpArme()+getpAttaque();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
monstre.pVie=monstre.pVie=getpAttaque();
|
2019-05-17 19:30:40 +02:00
|
|
|
|
if (monstre.pVie<=0)monstre.setVivant(false);
|
2019-05-14 10:56:57 +02:00
|
|
|
|
return getpAttaque();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Bourse getBourse() {
|
|
|
|
|
return this.bourse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getValeurBourse() {
|
|
|
|
|
return this.getBourse().getValeur();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @return the arme
|
|
|
|
|
*/
|
|
|
|
|
public Arme getArme() {
|
|
|
|
|
return arme;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String obtenirBourse() {
|
|
|
|
|
Random rd = new Random();
|
|
|
|
|
this.bourse.fusionBourse(new Bourse(rd.nextInt(20)));
|
|
|
|
|
String str="Vous avez gagnez une bourse. Vous comptez vos pi<70>ces... Genial !! Vous avez d<>sormais ".concat(String.valueOf(this.getValeurBourse()).concat(" pi<70>ces d'argent !"));
|
|
|
|
|
return str;
|
|
|
|
|
|
|
|
|
|
}
|
2019-05-13 22:51:42 +02:00
|
|
|
|
|
2019-05-14 10:56:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* @return the armure
|
|
|
|
|
*/
|
|
|
|
|
public Armure getArmure() {
|
|
|
|
|
return armure;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void soin(int heal) {
|
|
|
|
|
if (pVie+heal > pVieMax)pVie=pVieMax;
|
|
|
|
|
else pVie+=heal;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-13 22:51:42 +02:00
|
|
|
|
|