diff --git a/src/Game/Battle.java b/src/Game/Battle.java index 913731c..03b4f07 100644 --- a/src/Game/Battle.java +++ b/src/Game/Battle.java @@ -45,6 +45,7 @@ public class Battle { } public void action(int answer){ + textEnemy.randomAnswer(); //the player is at the last question, the finish text must be displayed if(getLineSpeech() == 4){ diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java index 85361bc..eac4543 100644 --- a/src/Text/TextEnemy.java +++ b/src/Text/TextEnemy.java @@ -22,6 +22,8 @@ public class TextEnemy { private Vector currentData; + int[] currentRandom = new int[5]; + public TextEnemy(Enemy e){ //generate the vector of fight fightData = new FightData(e.getBranch()); @@ -36,9 +38,18 @@ public class TextEnemy { orderAttack = randomGenerate(0, fightData.nbr_line-1, 4); + randomAnswer(); + + } + + public void randomAnswer(){ //generate a random array to determine the order of the answer orderAnswer = randomGenerate(0, 3, 4); + //save the order of answer and attack + for(int k=1;k<5;k++){ + currentRandom[k] = orderAnswer[k-1]; + } } public static int[] randomGenerate( int min, int max, int nbrRandom){ @@ -88,17 +99,8 @@ public class TextEnemy { //orderAttack = randomGenerate(0, fightData.nbr_line-1, 4); for(int j=0; j<4;j++){ - int[] currentRandom = new int[5]; currentRandom[0] = orderAttack[j]; - //generate a random array to determine the order of the answer - //orderAnswer = randomGenerate(0, 3, 4); - - //save the order of answer and attack - for(int k=1;k<5;k++){ - currentRandom[k] = orderAnswer[k-1]; - } - //Format the line String[] row = new String[4]; row[0] = row[1] = row[2] = row[3] = " ";