diff --git a/src/Text/Attack.java b/src/Text/Attack.java index e63e063..48da327 100644 --- a/src/Text/Attack.java +++ b/src/Text/Attack.java @@ -6,6 +6,8 @@ public class Attack { String answer2; String answer3; String answer4; + String[] s; + float xp; Attack(String attack, String answer1,String answer2,String answer3, String answer4, float xp){ @@ -15,9 +17,19 @@ public class Attack { this.answer3 = answer3; this.answer4 = answer4; this.xp = xp; + + s = new String[4]; + s[0] = answer1; + s[1] = answer2; + s[2] = answer3; + s[3] = answer4; } public String toString(){ return attack+ " " + answer1+ " " + answer2+ " " + answer3+ " " + answer4+ " " + xp; } + + public String getAnswer(int i){ + return s[i]; + } } diff --git a/src/Text/FightData.java b/src/Text/FightData.java index 88f8b48..1ca671d 100644 --- a/src/Text/FightData.java +++ b/src/Text/FightData.java @@ -27,8 +27,6 @@ public class FightData { FileReader f = new FileReader(file); BufferedReader bf = new BufferedReader(f); - - //add the line in the vector attacks of attack line = bf.readLine(); while(line != null){ @@ -45,6 +43,7 @@ public class FightData { } catch (Exception e) { e.printStackTrace(); } + System.out.println(attacks.size()); } //return the vector with all attaks of one enemi diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java index 53b0d52..9b3f9bb 100644 --- a/src/Text/TextEnemy.java +++ b/src/Text/TextEnemy.java @@ -1,6 +1,7 @@ package Text; import java.util.Vector; +import java.util.Arrays; import java.util.Random; public class TextEnemy { @@ -9,7 +10,8 @@ public class TextEnemy { public Vector lines = new Vector(); - public int[] orderAnswer; + private int[] orderAttack; + private int[] orderAnswer; public static void main(String[] args) { @@ -35,45 +37,37 @@ public class TextEnemy { } - int[] randomGenerate(int max_val){ - int max = 8-1; - Random r = new Random(); - - int nbre = 4; - - int[] t = new int[nbre]; - int x; - int i=0; - boolean same = false; - - // initialize array at -1 - for(int j=0; j 0; i--) { + + // Pick a random index from 0 to i + int j = rd.nextInt(i+1); + + // Swap array[i] with the element at random index + int temp = a[i]; + a[i] = a[j]; + a[j] = temp; } - - return t; + //add the numbers I want + for(int i=0;i