/* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ package metier; /** * * @author emile.lalorcey */ public class Jeu { String nomJeu = "Jeu de Role" ; Personnage[] mesPersonnages = new Personnage[7]; /********* Constructeurs ********/ /** * Constructeur de Jeu */ public Jeu(){ this.chargerLesPersonnages(); } /********* Guetteur ********/ /** * Getteur de mes personnages * @return mes personnages */ public Personnage[] getmesPersonnages(){ return this.mesPersonnages; } /********* Setteurs ********/ /********* Fonctions ********/ /** * Crée les personnages */ private void chargerLesPersonnages(){ mesPersonnages = new Personnage[7]; mesPersonnages[0] = new Guerrier("Barbare", "", 6, 4, "Hache"); mesPersonnages[5] = new Guerrier("Garren","Guerrier08.jpg" , 0, 0, "Gourdin"); mesPersonnages[6] = new Guerrier("Hellen","Guerrier08.jpg" , 0, 0, "Gourdin"); mesPersonnages[3] = new Personnage("Gaelle", "Barbare04.jpg", 0, 0); mesPersonnages[1] = new Voleur("Raptout", "", 2, 4, "Marteau"); mesPersonnages[2] = new Sorcier("Panoramix", "", 10, 5, "Baguette de laurier"); mesPersonnages[4] = new Sorcier("Jinx","Barbare04.jpg",0,0, "Bâton"); } /** * Cette méthode sert à affiché les différents personnages avec leurs affectations * @return String tout les personnages avec leurs capacités */ @Override public String toString(){ String mesPersos = ""; for (int i = 0; i < mesPersonnages.length; i++){ mesPersos += mesPersonnages[i] + "\n" + "\n"; } return mesPersos; } /** * recherche un personnage * @param n un entier * @return le personnage recherchés */ public Personnage rechercherPerso(String n){ int indice = 0; boolean trouver = false; while(indice < this.mesPersonnages.length && !trouver){ trouver = (this.mesPersonnages[indice].getNom().equals(n)); indice++; } if(trouver){ indice--; return this.mesPersonnages[indice]; } return null; } /** * Cette fonction génère un nombre aléatoire * @param min minimum possible pour le nombre * @param max maximum possible pour le nombre * @return le nombre aléatoire */ public static int genererNbAleatoire(int min, int max) { return min + (int)(Math.random() * ((max - min) + 1)); } }