2022-06-08 23:30:15 +02:00
|
|
|
package Text;
|
|
|
|
|
|
|
|
import java.util.Vector;
|
2022-06-12 12:10:57 +02:00
|
|
|
import java.util.Random;
|
2022-06-08 23:30:15 +02:00
|
|
|
|
|
|
|
public class TextEnemy {
|
|
|
|
public FightData fightData;
|
|
|
|
public SpeechData speechData;
|
|
|
|
|
2022-06-10 19:33:24 +02:00
|
|
|
public Vector<Line> lines = new Vector<Line>();
|
|
|
|
|
2022-06-12 12:10:57 +02:00
|
|
|
public int[] orderAnswer;
|
|
|
|
|
2022-06-10 19:33:24 +02:00
|
|
|
public static void main(String[] args) {
|
2022-06-12 12:10:57 +02:00
|
|
|
|
2022-06-10 19:33:24 +02:00
|
|
|
TextEnemy t = new TextEnemy("enemi");
|
2022-06-12 12:10:57 +02:00
|
|
|
|
2022-06-10 19:33:24 +02:00
|
|
|
t.generateText();
|
2022-06-12 12:10:57 +02:00
|
|
|
|
2022-06-10 19:33:24 +02:00
|
|
|
for(Line l : t.lines) {
|
|
|
|
System.out.println(l.line);
|
|
|
|
}
|
2022-06-12 12:10:57 +02:00
|
|
|
|
2022-06-10 19:33:24 +02:00
|
|
|
|
|
|
|
}
|
2022-06-08 23:30:15 +02:00
|
|
|
|
|
|
|
public TextEnemy(String name){
|
|
|
|
//generate the vector of fight
|
|
|
|
fightData = new FightData(name);
|
|
|
|
fightData.readFile();
|
|
|
|
|
|
|
|
//generate the vector of Speechs
|
|
|
|
speechData = new SpeechData(name);
|
|
|
|
speechData.readFile();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-12 12:10:57 +02:00
|
|
|
int[] randomGenerate(int max_val){
|
|
|
|
int min_val = 0;
|
|
|
|
int x;
|
|
|
|
int[] t = new int[max_val-1];
|
|
|
|
Random ran = new Random();
|
|
|
|
|
|
|
|
int i=0;
|
|
|
|
|
|
|
|
|
|
|
|
while(i<t.length){
|
|
|
|
System.out.println(i);
|
|
|
|
t[i] = ran.nextInt(max_val) + min_val;
|
|
|
|
for(int j : t){
|
|
|
|
if(t[i] == j){
|
|
|
|
t[i] = ran.nextInt(max_val) + min_val;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-08 23:30:15 +02:00
|
|
|
public void generateText(){
|
2022-06-10 19:33:24 +02:00
|
|
|
int i =1;
|
2022-06-12 12:10:57 +02:00
|
|
|
|
2022-06-08 23:30:15 +02:00
|
|
|
//introduction line
|
2022-06-10 19:33:24 +02:00
|
|
|
lines.add(new Line(speechData.getSpeechs(0), false));
|
2022-06-12 12:10:57 +02:00
|
|
|
orderAnswer = randomGenerate(fightData.nbre_line);
|
2022-06-10 19:33:24 +02:00
|
|
|
for(int j=0; j<4;j++){
|
2022-06-12 12:10:57 +02:00
|
|
|
|
|
|
|
//generate the order of the answer
|
|
|
|
|
2022-06-09 06:58:49 +02:00
|
|
|
//attack and answer (number on vector : 1-4)
|
2022-06-10 19:33:24 +02:00
|
|
|
lines.add(new Line(
|
2022-06-12 12:10:57 +02:00
|
|
|
speechData.getSpeechs(i++) + fightData.getAttack(orderAnswer[j]).attack + " ? ("+fightData.getAttack(orderAnswer[j]).xp+ ") " + "\n" +
|
|
|
|
fightData.getAttack(orderAnswer[j]).answer1 + "\n" +
|
|
|
|
fightData.getAttack(orderAnswer[j]).answer2 + "\n" +
|
|
|
|
fightData.getAttack(orderAnswer[j]).answer3 + "\n" +
|
|
|
|
fightData.getAttack(orderAnswer[j]).answer4, true));
|
2022-06-09 06:58:49 +02:00
|
|
|
// TODO mélanger les attaques aléatoirement
|
2022-06-08 23:30:15 +02:00
|
|
|
}
|
|
|
|
//finish (win and death)
|
2022-06-10 19:33:24 +02:00
|
|
|
lines.add(new Line(speechData.getSpeechs(5), false));
|
|
|
|
lines.add(new Line(speechData.getSpeechs(6), false));
|
2022-06-08 23:30:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-06-09 06:58:49 +02:00
|
|
|
|