1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2025-03-14 06:44:33 +00:00
PokeHES/src/Text/TextEnemy.java

91 lines
2.3 KiB
Java
Raw Normal View History

package Text;
import java.util.Vector;
2022-06-12 12:10:57 +02:00
import java.util.Random;
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
}
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;
}
public void generateText(){
2022-06-10 19:33:24 +02:00
int i =1;
2022-06-12 12:10:57 +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
}
//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-09 06:58:49 +02:00