diff --git a/src/Entity/Enemy.java b/src/Entity/Enemy.java index 9b56d9e..60d63b0 100644 --- a/src/Entity/Enemy.java +++ b/src/Entity/Enemy.java @@ -6,15 +6,16 @@ public class Enemy extends Character{ - public Enemy(String name, int x, int y, String img, String map) { + public Enemy(String name, int x, int y, String img, String map, int pv) { super(name, x, y, img, map); //generate his text this.map = map; turn(Character.Direction.DOWN); - //generate the vector of fight - //FightData fightData = new FightData(name); + + this.pv = pv; + } @@ -28,8 +29,8 @@ public class Enemy extends Character{ } @Override - protected void removedPv(int pv) { - // TODO Auto-generated method stub + public void removedPv(int pv) { + this.pv -= pv; } diff --git a/src/Entity/Player.java b/src/Entity/Player.java index 182939c..77ae101 100644 --- a/src/Entity/Player.java +++ b/src/Entity/Player.java @@ -12,7 +12,7 @@ import Screen.ScreenMap; public class Player extends Character{ - private int xp; + private int xp = 0; public Enemy lastEnemy = null; public boolean onEnemy = false; @@ -21,7 +21,7 @@ public class Player extends Character{ } public void addXp(int xp){ - + this.xp += xp; } public void manageEntity(ScreenMap sm, Controller c) { diff --git a/src/Game/Battle.java b/src/Game/Battle.java index 3f3e819..f0c750c 100644 --- a/src/Game/Battle.java +++ b/src/Game/Battle.java @@ -6,24 +6,21 @@ import Entity.Enemy; import Text.TextEnemy; public class Battle { - - TextEnemy textEnemy; + public TextEnemy textEnemy; private int lineSpeech; - public int answer; - private int winPoint; + private int newXp; public boolean screenBattleOn = true; - - public Battle(Enemy enemy){ + public Battle(Enemy e){ textEnemy = new TextEnemy("enemi"); // should be enemy.name textEnemy.generateText(); lineSpeech = 0; - winPoint = 0; + newXp = 0; System.out.println("lll : "+ getLine()); @@ -46,7 +43,6 @@ public class Battle { //get number current answer random int currentAnswer = textEnemy.getCurrentData().get(attack)[answer]; - System.out.println("current answer : " + currentAnswer); //get the answer of the player String answerPlayer = textEnemy.fightData.getAttack(currentAttack).getAnswer(currentAnswer); @@ -58,7 +54,9 @@ public class Battle { //check the choice of the player if(answerPlayer == trueAsnwer){ + newXp += textEnemy.fightData.getAttack(currentAttack).getXp(); System.out.println("it's true !!!!"); + } else{ System.out.println("it's false !!!!"); @@ -89,6 +87,8 @@ public class Battle { public boolean getScreenBattleOn(){ return screenBattleOn; } - - + + public int getNewXp(){ + return newXp; + } } diff --git a/src/Main/PokeMudry.java b/src/Main/PokeMudry.java index 3019271..3e4f1b4 100644 --- a/src/Main/PokeMudry.java +++ b/src/Main/PokeMudry.java @@ -45,8 +45,8 @@ public class PokeMudry extends PortableApplication { // add player, create and add all enemies in entities entities.add((Entity) sp.p); - enemies.add(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert")); - enemies.add(new Enemy("Pignat", 5, 1, "lumberjack_sheet32", "test")); + enemies.add(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert", 100)); + enemies.add(new Enemy("Pignat", 5, 1, "lumberjack_sheet32", "test", 150)); for (Enemy enemy : enemies) { entities.add(enemy); } //Init all entities @@ -75,6 +75,8 @@ public class PokeMudry extends PortableApplication { if(!sp.b.getScreenBattleOn() && onBattleScreen){ sp.p.onEnemy = false; sp.sm = sp.screenManager.getScreenMap(); + sp.p.addXp(sp.b.getNewXp()); + sp.e.removedPv(sp.b.getNewXp()); } // Graphics render diff --git a/src/Text/Attack.java b/src/Text/Attack.java index c915827..a23b2ea 100644 --- a/src/Text/Attack.java +++ b/src/Text/Attack.java @@ -9,7 +9,7 @@ public class Attack { String answer4; public String[] s; - float xp; + private int xp; Attack(String attack, String answer1,String answer2,String answer3, String answer4, float xp){ this.attack = attack; @@ -38,4 +38,8 @@ public class Attack { return answer1; } + public int getXp() { + return xp; + } + }