mirror of
https://github.com/Klagarge/PokeHES.git
synced 2025-07-17 21:31:10 +00:00
c
This commit is contained in:
@ -11,23 +11,33 @@ public class FightData {
|
||||
private File file;
|
||||
private static final String REGEX = ",";
|
||||
|
||||
public int nbre_line =0;
|
||||
|
||||
public FightData(String name) {
|
||||
file = new File("./resources/Battle/Fight/" + name + ".csv");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void readFile() {
|
||||
Attack attack;
|
||||
String line = "";
|
||||
|
||||
try {
|
||||
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){
|
||||
String[] a = line.split(REGEX);//change the regex if it is another
|
||||
attack = new Attack(a[0], a[1], a[2], a[3], a[4], Float.valueOf(a[5]));
|
||||
attacks.add(attack);
|
||||
line = bf.readLine();
|
||||
//add line
|
||||
nbre_line++;
|
||||
}
|
||||
|
||||
bf.close();
|
||||
@ -35,10 +45,6 @@ public class FightData {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//return the vector with all attaks of one enemi
|
||||
|
@ -1,6 +1,7 @@
|
||||
package Text;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.Random;
|
||||
|
||||
public class TextEnemy {
|
||||
public FightData fightData;
|
||||
@ -8,12 +9,18 @@ public class TextEnemy {
|
||||
|
||||
public Vector<Line> lines = new Vector<Line>();
|
||||
|
||||
public int[] orderAnswer;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
TextEnemy t = new TextEnemy("enemi");
|
||||
|
||||
t.generateText();
|
||||
|
||||
for(Line l : t.lines) {
|
||||
System.out.println(l.line);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -28,18 +35,49 @@ public class TextEnemy {
|
||||
|
||||
}
|
||||
|
||||
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(){
|
||||
int i =1;
|
||||
|
||||
//introduction line
|
||||
lines.add(new Line(speechData.getSpeechs(0), false));
|
||||
orderAnswer = randomGenerate(fightData.nbre_line);
|
||||
for(int j=0; j<4;j++){
|
||||
|
||||
//generate the order of the answer
|
||||
|
||||
//attack and answer (number on vector : 1-4)
|
||||
lines.add(new Line(
|
||||
speechData.getSpeechs(i++) + fightData.getAttack(j).attack + "? ("+fightData.getAttack(j).xp+ ") " + "\n" +
|
||||
fightData.getAttack(j).answer1 + "\n" +
|
||||
fightData.getAttack(j).answer2 + "\n" +
|
||||
fightData.getAttack(j).answer3 + "\n" +
|
||||
fightData.getAttack(j).answer4, true));
|
||||
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));
|
||||
// TODO mélanger les attaques aléatoirement
|
||||
}
|
||||
//finish (win and death)
|
||||
|
Reference in New Issue
Block a user