diff --git a/resources/Battle/Fight/enemi.csv b/resources/Battle/Fight/enemi.csv index 17a9151..c06dd70 100644 --- a/resources/Battle/Fight/enemi.csv +++ b/resources/Battle/Fight/enemi.csv @@ -1,7 +1,7 @@ -attaque1,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,1 -attaque2,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,10 -attaque3,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,3 -attaque4,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,45 -attaque5,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,4 -attaque6,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,6 -attaque7,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,3 +attaque1;contre-attaque 1;contre-attaque 2;contre-attaque 3;contre-attaque 4;1 +attaque2;contre-attaque 1;contre-attaque 2;contre-attaque 3;contre-attaque 4;10 +attaque3;contre-attaque 1;contre-attaque 2;contre-attaque 3;contre-attaque 4;3 +attaque4;contre-attaque 1;contre-attaque 2;contre-attaque 3;contre-attaque 4;45 +attaque5;contre-attaque 1;contre-attaque 2;contre-attaque 3;contre-attaque 4;4 +attaque6;contre-attaque 1;contre-attaque 2;contre-attaque 3;contre-attaque 4;6 +attaque7;contre-attaque 1;contre-attaque 2;contre-attaque 3;contre-attaque 4;3 diff --git a/resources/Battle/Fight/informatique.csv b/resources/Battle/Fight/informatique.csv index 88d8496..65892e7 100644 --- a/resources/Battle/Fight/informatique.csv +++ b/resources/Battle/Fight/informatique.csv @@ -1,5 +1,5 @@ -Convertir 0b01010111 en décimal :;87;79;afg;83;25 -Convertir 0b11110011 en héxadécimal :;F3;Q8;35;12;25 -Quel est la valeur de 'a' en ASCII en décimal ?;97;0;42;2;25 -Quel mot est utile à une fonction qui retourne rien ?;void;break;Integer;false;25 +Convertir 0b01010111 en décimal :;87;79;afg;83;25 +Convertir 0b11110011 en héxadécimal :;F3;Q8;35;12;25 +Quel est la valeur de 'a' en ASCII en décimal ?;97;0;42;2;25 +Quel mot est utile à une fonction qui retourne rien ?;void;break;Integer;false;25 Comment convertir un string en int ?;int a = Integer.parseInt(String s);int a = String s;Je sais pas;int a = String.changeInt(String s);25 diff --git a/resources/Battle/Speech/mudry.txt b/resources/Battle/Speech/mudry.txt new file mode 100644 index 0000000..5202573 --- /dev/null +++ b/resources/Battle/Speech/mudry.txt @@ -0,0 +1,7 @@ +Un mudry sauvage se balade dans les salles de classe. Il va te tester pour savoir si tu a traviallé cette année +Une question pour commencer : +Encore une autre : +Est ce que tu est vraiment chaud pour +Vas-y...quoi ! +Tu m'as vaincu. Moi le Mudry tout puissant ! +Pas fortiche mon gars ! \ No newline at end of file diff --git a/src/Entity/Enemy.java b/src/Entity/Enemy.java index 9b56d9e..7deea2e 100644 --- a/src/Entity/Enemy.java +++ b/src/Entity/Enemy.java @@ -4,17 +4,22 @@ import com.badlogic.gdx.math.Vector2; public class Enemy extends Character{ + private String branch; - 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, String branch) { 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.branch = branch; + + this.pv = pv; + } @@ -28,9 +33,13 @@ public class Enemy extends Character{ } @Override - protected void removedPv(int pv) { - // TODO Auto-generated method stub + public void removedPv(int pv) { + this.pv -= pv; } + + public String getBranch(){ + return branch; + } } 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..2cde061 100644 --- a/src/Game/Battle.java +++ b/src/Game/Battle.java @@ -6,24 +6,24 @@ import Entity.Enemy; import Text.TextEnemy; public class Battle { - - TextEnemy textEnemy; + private Enemy e; + public TextEnemy textEnemy; private int lineSpeech; - public int answer; - private int winPoint; + private int newXp; public boolean screenBattleOn = true; - - public Battle(Enemy enemy){ - textEnemy = new TextEnemy("enemi"); // should be enemy.name - textEnemy.generateText(); - + public Battle(Enemy e){ + if(e != null){ + textEnemy = new TextEnemy(e); + textEnemy.generateText(); + } + lineSpeech = 0; - winPoint = 0; + newXp = 0; System.out.println("lll : "+ getLine()); @@ -46,7 +46,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 +57,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 !!!!"); @@ -78,7 +79,10 @@ public class Battle { } public String getLine(){ + if(e==null) return null; + return textEnemy.lines.get(lineSpeech).line; + } @@ -89,6 +93,12 @@ public class Battle { public boolean getScreenBattleOn(){ return screenBattleOn; } - - + + public int getNewXp(){ + return newXp; + } + + public void setEnemy(Enemy e){ + this.e = e; + } } diff --git a/src/Main/PokeMudry.java b/src/Main/PokeMudry.java index 3019271..1b4d60f 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", 25, "informatique")); + //enemies.add(new Enemy("Pignat", 5, 1, "lumberjack_sheet32", "test", 150)); for (Enemy enemy : enemies) { entities.add(enemy); } //Init all entities @@ -65,6 +65,8 @@ public class PokeMudry extends PortableApplication { if (sp.p.onEnemy && onMapScreen){ sp.e = sp.p.lastEnemy; sp.sb = sp.screenManager.getScreenBattle(); + if(sp.e == null) System.out.println("sdfsdfsdfsdf"); + sp.b = new Battle(sp.e); g.resetCamera(); } @@ -75,6 +77,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/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index e0176b6..2d638d9 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -75,7 +75,9 @@ public class ScreenBattle extends RenderingScreen{ g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, WIDTH_DIALOG, HEIGHT_DIALOG, 0); //dialog - if(b != null) g.drawString(15, 245 ,b.getLine() , optimus40); + if(b == null) return; + if(b.getLine() == null) return; + g.drawString(15, 245 ,b.getLine() , optimus40); diff --git a/src/Screen/ScreenPlayer.java b/src/Screen/ScreenPlayer.java index 4f4b436..04197ed 100644 --- a/src/Screen/ScreenPlayer.java +++ b/src/Screen/ScreenPlayer.java @@ -16,10 +16,10 @@ public class ScreenPlayer { public void init(){ // One player by ScreenPlayer - //p = new Player(8, 15, "desert"); - p = new Player(4, 2, "21RI"); + p = new Player(8, 15, "desert"); + //p = new Player(4, 2, "21RI"); - b = new Battle(e); + b = new Battle(new Enemy("enemi", 0, 0, "charachter", "desert", 50, "enemi")); // Create both type of screen and record for reuse screenManager.registerScreen(ScreenMap.class); @@ -36,6 +36,7 @@ public class ScreenPlayer { if(sb != null){ sb.setBattle(b); + b.setEnemy(e); } screenManager.render(g); diff --git a/src/Text/Attack.java b/src/Text/Attack.java index c915827..5618f51 100644 --- a/src/Text/Attack.java +++ b/src/Text/Attack.java @@ -9,9 +9,9 @@ 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){ + Attack(String attack, String answer1,String answer2,String answer3, String answer4, int xp){ this.attack = attack; this.answer1 = answer1; this.answer2 = answer2; @@ -38,4 +38,8 @@ public class Attack { return answer1; } + public int getXp() { + return xp; + } + } diff --git a/src/Text/FightData.java b/src/Text/FightData.java index 99914e5..7cd6c6f 100644 --- a/src/Text/FightData.java +++ b/src/Text/FightData.java @@ -9,14 +9,14 @@ public class FightData { private Vector attacks = new Vector(); private File file; - private static final String REGEX = ","; + private static String regex = ";"; public int nbre_line =0; - public FightData(String name) { - file = new File("./resources/Battle/Fight/" + name + ".csv"); + public FightData(String branch) { + file = new File("./resources/Battle/Fight/" + branch + ".csv"); } @@ -30,9 +30,11 @@ public class FightData { //add the line in the vector attacks of attack line = bf.readLine(); + System.out.println(line); while(line != null){ - String[] a = line.split(REGEX);//change the regex if it is another - attack = new Attack(a[0], a[1], a[2], a[3], a[4], Float.valueOf(a[5])); + String[] a = line.split(regex);//change the regex if it is another + System.out.println(a.length); + attack = new Attack(a[0], a[1], a[2], a[3], a[4], Integer.valueOf(a[5])); attacks.add(attack); line = bf.readLine(); //add line diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java index a783fa1..eb43dd2 100644 --- a/src/Text/TextEnemy.java +++ b/src/Text/TextEnemy.java @@ -1,6 +1,9 @@ package Text; import java.util.Vector; + +import Entity.Enemy; + import java.util.Arrays; import java.util.Random; @@ -17,24 +20,22 @@ public class TextEnemy { public static void main(String[] args) { - TextEnemy t = new TextEnemy("enemi"); + TextEnemy t = new TextEnemy(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert", 25, "informatique")); t.generateText(); for(Line l : t.lines) { System.out.println(l.line); } - - } - public TextEnemy(String name){ + public TextEnemy(Enemy e){ //generate the vector of fight - fightData = new FightData(name); + fightData = new FightData(e.getBranch()); fightData.readFile(); //generate the vector of Speechs - speechData = new SpeechData(name); + speechData = new SpeechData(e.getName()); speechData.readFile(); //save random data (attack and ansver) : attack, answer 1, answer 2 answer 3, answer 4 @@ -98,7 +99,7 @@ public class TextEnemy { //attack and answer (number on vector : 1-4) lines.add(new Line( - speechData.getSpeechs(i++) + fightData.getAttack(orderAttack[j]).attack + " ? ("+fightData.getAttack(orderAttack[j]).xp+ ") " + "\n" + + speechData.getSpeechs(i++) + fightData.getAttack(orderAttack[j]).attack + " ? ("+fightData.getAttack(orderAttack[j]).getXp()+ ") " + "\n" + "1. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[0]) + "\n" + "2. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[1]) + "\n" + "3. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[2]) + "\n" +