package Text; import java.util.Vector; import Entity.Enemy; import Entity.Character.Direction; import java.util.Arrays; import java.util.Random; public class TextEnemy { private static final int CUT = 60; public FightData fightData; public SpeechData speechData; public Vector lines = new Vector(); private int[] orderAttack; private int[] orderAnswer; private Vector currentData; public static void main(String[] args) { TextEnemy t = new TextEnemy(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert", 25, "informatique", Direction.NULL)); t.generateText(); for(Line l : t.lines) { System.out.println(l.line); } } public TextEnemy(Enemy e){ //generate the vector of fight fightData = new FightData(e.getBranch()); fightData.readFile(); //generate the vector of Speechs speechData = new SpeechData(e.getName()); speechData.readFile(); //save random data (attack and ansver) : attack, answer 1, answer 2 answer 3, answer 4 currentData = new Vector(); } public static int[] randomGenerate( int min, int max, int nbreRandom){ //create an array with all the number I need int[] a = new int[max-min+1]; int k = min; for(int i=0;k<=max;i++){ a[i] = k; k++; } //create a new array with the numbers I want int[] b = new int[nbreRandom]; // Creating object for Random class Random rd = new Random(); // Starting from the last element and swapping one by one. for (int i = a.length-1; i > 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; } //add the numbers I want for(int i=0;i getCurrentData() { return currentData; } public String formatLine(String line, int cut){ String cutLine = ""; String newLine = ""; int startC = 0; int stoppC = cut; if(cut>line.length()-1){ newLine =line; } else{ char[] c = new char[line.length()]; for(int i=0; i=startC; i--){ if(c[i] == ' '){ stoppC = i; break; } else if(stoppC == c.length-1){ break; } } //découper le mot for(int i=startC;i<=stoppC;i++){ cutLine += c[i]; } newLine += cutLine+"\n"; cutLine = ""; startC = stoppC + 1; if(c.length-1-stoppC <=0){ break; } else if(c.length-1-stoppC <= cut){ stoppC = c.length-1; } else{ stoppC += cut; } } } return newLine; } }