You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
1.9 KiB
Java

package modeles;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
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) {
super(nom, pVieMax, pAttaque);
}
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 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èces... Genial !! Vous avez désormais ".concat(String.valueOf(this.getValeurBourse()).concat(" pièces d'argent !"));
return str;
}
/**
* @return the armure
*/
public Armure getArmure() {
return armure;
}
public void soin(int heal) {
if (pVie+heal > pVieMax)pVie=pVieMax;
else pVie+=heal;
}
}