Commit 405cef0f authored by Guillaume Dewisme's avatar Guillaume Dewisme

refonte du jeu

parent 85fe1786
This diff is collapsed.
package org.example;
// on pourra la modifier par la suite si des éléments ne conviennent pas
public abstract class Character {
protected String name;
protected int maxHP;
protected int currentHP;
protected int attackPower;
protected int defense;
protected SpecialAbility specialAbility;
public Character(String name, int maxHP, int attackPower, int defense) {
this.name = name;
this.maxHP = maxHP;
this.currentHP = maxHP;
this.attackPower = attackPower;
this.defense = defense;
}
public boolean isAlive() {
return currentHP > 0;
}
public void takeDamage(int damage) {
int actualDamage = Math.max(damage - defense, 0);
currentHP = Math.max(currentHP - actualDamage, 0);
System.out.println(name + " subit " + actualDamage + " dégâts. (PV restants : " + currentHP + ")");
}
public abstract void attack(Character target);
public void useSpecialAbility(Character target) {
if (specialAbility != null) {
specialAbility.activate(this, target);
}
}
}
package org.example;
import org.example.SpecialAbility;
// Capacités spéciales des héros
public class DoubleAttack implements SpecialAbility {
@Override
public void activate(Character user, Character target) {
int damage = user.attackPower * 2;
System.out.println(user.name + " utilise Double Attaque !");
target.takeDamage(damage);
}
}
\ No newline at end of file
package org.example;
public abstract class Entity {
private int damage;
private int pvMax;
private int pv;
public void heal(){
this.pv += this.pvMax/3;
}
public int getDamage() {
return this.damage;
}
public void setDamage(int damage) {
this.damage = damage;
}
public int getPvMax() {
return this.pvMax;
}
public void setPvMax(int pvMax) {
this.pvMax = pvMax;
}
public int getPv() {
return this.pv;
}
public void setPv(int pv) {
this.pv = pv;
}
public boolean isAlive(){
return (this.pv > 0);
}
}
package org.example;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
\ No newline at end of file
package org.example;
public class Player extends Entity {
private String name;
private SpecialAbility specialAbility;
private int endurance;
private static final int MAX_ENDURANCE = 3;
public Player(String name, SpecialAbility specialAbility) {
super();
this.name = name;
this.specialAbility = specialAbility;
this.endurance = MAX_ENDURANCE;
this.setPvMax(100);
this.setPv(this.getPvMax());
this.setDamage(5);
}
public void attackEnnemy(){
--this.endurance;
//implement when Ennemy class is created
}
public void useSpecialAbility(){
if(this.specialAbility == SpecialAbility.DAMAGE){
this.setDamage(this.getDamage()*2);
}
if(this.specialAbility == SpecialAbility.FULLHEAL){
this.setPv(this.getPvMax());
}
if(this.specialAbility == SpecialAbility.SHIELD ){
//to-do
//add random for variation damage each round
}
}
}
package org.example;
public enum SpecialAbility {
DAMAGE,
FULLHEAL,
SHIELD,
// ... other abilities ...
}
// Interface pour les capacités spéciales
public interface SpecialAbility {
void activate(Character user, Character target);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment