2020-04-17 16:04:44 +02:00
|
|
|
package main;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2020-04-21 13:45:45 +02:00
|
|
|
import carte.CarteLieu;
|
2020-04-18 13:18:21 +02:00
|
|
|
import effet.Effet;
|
2020-04-19 11:55:59 +02:00
|
|
|
import personnage.CartePersonnage;
|
2020-04-18 13:18:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-17 16:04:44 +02:00
|
|
|
public class Joueur {
|
|
|
|
private GestionnaireEquipements gestionnaireEquipements;
|
2020-04-18 13:18:21 +02:00
|
|
|
private String nom;
|
|
|
|
private boolean revele;
|
2020-04-17 17:32:53 +02:00
|
|
|
private Plateau plateau;
|
2020-04-19 11:55:59 +02:00
|
|
|
private CartePersonnage cartePersonnage;
|
|
|
|
private Equipe equipe;
|
2020-04-21 12:31:59 +02:00
|
|
|
private CarteLieu carteLieu;
|
|
|
|
|
2020-04-17 16:04:44 +02:00
|
|
|
|
|
|
|
// map keys
|
|
|
|
public static final String PLAYER_HP = "hp";
|
|
|
|
public static final String PLAYER_TURN = "turn";
|
2020-04-18 19:39:59 +02:00
|
|
|
public static final String PLAYER_DAMAGE = "damage";
|
2020-04-17 16:04:44 +02:00
|
|
|
public static final String PLAYER_RESISTANCE = "resistance";
|
|
|
|
public static final String PLAYER_REVEAL = "reveal";
|
|
|
|
public static final String PLAYER_IMMUNITY = "immunity";
|
2020-04-18 19:39:59 +02:00
|
|
|
public static final String PLAYER_NB_EQUIPEMENTS = "nb_equipements";
|
2020-04-17 16:04:44 +02:00
|
|
|
|
|
|
|
private Map<String, Integer> stats;
|
|
|
|
|
2020-04-19 11:55:59 +02:00
|
|
|
public enum Equipe{
|
|
|
|
NEUTRE,
|
|
|
|
SHADOW,
|
|
|
|
HUNTER
|
|
|
|
}
|
|
|
|
|
2020-04-18 13:18:21 +02:00
|
|
|
public Joueur(String nom) {
|
|
|
|
this.nom = nom;
|
|
|
|
this.revele = false;
|
|
|
|
|
2020-04-17 16:04:44 +02:00
|
|
|
|
|
|
|
stats = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
// Initialisation joueur depuis valeurs perso
|
|
|
|
|
|
|
|
//stats.put(PLAYER_HP, char.getHP());
|
|
|
|
//stats.put(PLAYER_TURN, 1);
|
|
|
|
//stats.put(PLAYER_DAMAGE, 0); - dégats en +
|
|
|
|
//stats.put(PLAYER_RESISTANCE, 0);
|
|
|
|
//stats.put(PLAYER_REVEAL, 0);
|
|
|
|
//stats.put(PLAYER_IMMUNITY, 0);
|
|
|
|
// immunité à certains effets?
|
|
|
|
}
|
2020-04-18 13:18:21 +02:00
|
|
|
|
2020-04-17 16:04:44 +02:00
|
|
|
//shadows, hunters ou neutre
|
2020-04-19 11:55:59 +02:00
|
|
|
public Equipe getEquipe() {
|
|
|
|
return this.equipe;
|
2020-04-17 16:04:44 +02:00
|
|
|
}
|
|
|
|
|
2020-04-20 12:38:06 +02:00
|
|
|
public void setStat(String key, int valeur) {
|
2020-04-21 11:46:41 +02:00
|
|
|
|
|
|
|
// TODO Il faut créer des observers de mort
|
2020-04-20 12:38:06 +02:00
|
|
|
this.stats.put(key, valeur);
|
2020-04-17 16:04:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getStat(String key) {
|
2020-04-20 12:38:06 +02:00
|
|
|
|
|
|
|
if(stats.containsKey(key)) {
|
|
|
|
return stats.get(key);
|
|
|
|
}else {
|
|
|
|
return -1;
|
|
|
|
}
|
2020-04-17 16:04:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int getNbEquipments() {
|
|
|
|
return gestionnaireEquipements.getNbEquipments();
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Joueur> getJoueursAdjacents() {
|
2020-04-21 12:31:59 +02:00
|
|
|
|
|
|
|
List<Joueur> joueurs = this.carteLieu.getJoueursAdjacents();
|
|
|
|
joueurs.remove(this);
|
|
|
|
return joueurs;
|
2020-04-17 16:04:44 +02:00
|
|
|
}
|
2020-04-18 13:18:21 +02:00
|
|
|
|
2020-04-18 19:39:59 +02:00
|
|
|
public Equipement[] getEquipements() {
|
2020-04-18 13:18:21 +02:00
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void voler(Joueur j2, Equipement equipement) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public Equipement choisir(Equipement[] equipements) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-04-21 11:46:41 +02:00
|
|
|
public void attaquer(Joueur j2, int attaqueDice) {
|
2020-04-18 13:18:21 +02:00
|
|
|
|
2020-04-21 11:46:41 +02:00
|
|
|
int blessure = evaluerImmunite(j2)*(this.evaluerAttaque(j2) + attaqueDice);
|
|
|
|
|
|
|
|
if(blessure > 0)
|
|
|
|
{
|
|
|
|
j2.addStat(PLAYER_HP, -blessure);
|
2020-04-21 16:02:01 +02:00
|
|
|
//this.cartePersonnage.attaquer(j2);
|
2020-04-21 11:46:41 +02:00
|
|
|
}
|
2020-04-18 13:18:21 +02:00
|
|
|
}
|
2020-04-21 11:46:41 +02:00
|
|
|
|
|
|
|
private int evaluerAttaque(Joueur j2) {
|
|
|
|
|
|
|
|
return this.getStat(PLAYER_DAMAGE)-j2.getStat(PLAYER_RESISTANCE);
|
|
|
|
}
|
|
|
|
|
|
|
|
private int evaluerImmunite(Joueur j2) {
|
|
|
|
|
|
|
|
int nbToursImmune = j2.getStat(PLAYER_IMMUNITY);
|
|
|
|
|
|
|
|
return nbToursImmune > 0 ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addStat(String key, int valeur)
|
|
|
|
{
|
|
|
|
int valeurBase = this.getStat(key);
|
|
|
|
this.setStat(Joueur.PLAYER_HP,valeurBase+valeur);
|
|
|
|
}
|
|
|
|
|
2020-04-18 13:18:21 +02:00
|
|
|
|
|
|
|
public Plateau getPlateau() {
|
|
|
|
return this.plateau;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Joueur choisirAdjacents() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Effet choisir(Effet[] effets) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean getRevele() {
|
|
|
|
return this.revele;
|
|
|
|
}
|
2020-04-17 16:04:44 +02:00
|
|
|
|
2020-04-19 11:55:59 +02:00
|
|
|
public CartePersonnage getCartePersonnage() {
|
|
|
|
return this.cartePersonnage;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCartePersonnage(CartePersonnage cp) {
|
|
|
|
this.cartePersonnage = cp;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEquipe(Equipe equipe) {
|
|
|
|
this.equipe = equipe;
|
|
|
|
|
2020-04-18 14:05:53 +02:00
|
|
|
}
|
|
|
|
|
2020-04-20 12:38:06 +02:00
|
|
|
public void setPlateau(Plateau plateau2) {
|
|
|
|
this.plateau = plateau2;
|
|
|
|
}
|
|
|
|
|
2020-04-21 13:45:45 +02:00
|
|
|
public boolean choisir() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void utiliserEffetLieu() {
|
|
|
|
this.carteLieu.utiliser(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void deplacer(CarteLieu cl) {
|
|
|
|
|
2020-04-21 15:27:27 +02:00
|
|
|
if(this.carteLieu != null){
|
2020-04-21 13:45:45 +02:00
|
|
|
this.carteLieu.remove(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.carteLieu = cl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-21 15:27:27 +02:00
|
|
|
public Joueur choisirTous() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public CarteLieu getCarteLieu() {
|
|
|
|
return this.carteLieu;
|
|
|
|
}
|
|
|
|
|
2020-04-17 16:04:44 +02:00
|
|
|
}
|