package modeles; import labyrinthe.*; import java.util.ArrayList; import java.util.List; import java.util.Random; public class Personnage extends EtreVivant { private int arme =-1; private int armure=-1; private Bourse bourse; private List listepotion= new ArrayList(); public Personnage(String nom, int pVieMax,int pAttaque) { super(nom, pVieMax, pAttaque); this.bourse=new Bourse(0); } /** * @return the armure */ public int getArmure() { return armure; } public Bourse getBourse() { return this.bourse; } public List getPotion() { return this.listepotion; } public int getValeurBourse() { return this.getBourse().getValeur(); } /** * @return the arme */ public int getArme() { return arme; } public void equiper(Arme arme,Labyrinthe lab) { this.arme=lab.getListeArme().indexOf(arme); } public void equiper(Armure armure,Labyrinthe lab) { this.armure=lab.getListeArmure().indexOf(armure); } public void utiliser(Potion potion) { soin(); } public void seDeplacer(Salle salle) { this.salle=salle; } public void gagnerUnePotion() { Potion potion=new Potion(100); listepotion.add(potion); } public int attaquer(Monstre monstre,Labyrinthe lab) { if(arme>=0) { lab.getListeArme().get(arme).utilisation(); monstre.pVie=monstre.pVie-(lab.getListeArme().get(arme).getpArme()+getpAttaque()); if (monstre.pVie<=0)monstre.setVivant(false); return lab.getListeArme().get(arme).getpArme()+getpAttaque(); } else { monstre.pVie=monstre.pVie-getpAttaque(); if (monstre.pVie<=0)monstre.setVivant(false); return getpAttaque(); } } public String remplirBourse() { Random rd = new Random(); this.bourse.setValeur(this.bourse.getValeur()+rd.nextInt(20)); String str="Vous avez gagnez une bourse. Vous comptez vos pieces... Genial !! Vous avez desormais "+this.getValeurBourse()+" pieces d'argent !"; return str; } public void soin(int heal) { if (pVie+heal > pVieMax)pVie=pVieMax; else pVie+=heal; } }