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

69 lines
1.4 KiB
Java
Raw Normal View History

2022-06-08 19:04:37 +02:00
package Text;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Vector;
public class FightData {
private Vector<Attack> attacks = new Vector<Attack>();
private File file;
private static final String REGEX = ",";
2022-06-13 20:53:09 +02:00
2022-06-12 12:10:57 +02:00
public int nbre_line =0;
2022-06-08 20:04:16 +02:00
public FightData(String name) {
2022-06-09 19:15:11 +02:00
file = new File("./resources/Battle/Fight/" + name + ".csv");
2022-06-13 20:53:09 +02:00
2022-06-08 19:04:37 +02:00
}
2022-06-08 20:04:16 +02:00
public void readFile() {
2022-06-08 19:04:37 +02:00
Attack attack;
String line = "";
2022-06-12 12:10:57 +02:00
2022-06-08 19:04:37 +02:00
try {
FileReader f = new FileReader(file);
BufferedReader bf = new BufferedReader(f);
2022-06-12 12:10:57 +02:00
//add the line in the vector attacks of attack
2022-06-08 19:04:37 +02:00
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();
2022-06-12 12:10:57 +02:00
//add line
nbre_line++;
2022-06-08 19:04:37 +02:00
}
bf.close();
2022-06-10 19:33:24 +02:00
} catch (Exception e) {
2022-06-08 19:04:37 +02:00
e.printStackTrace();
2022-06-10 19:33:24 +02:00
}
2022-06-13 20:53:09 +02:00
2022-06-08 19:04:37 +02:00
}
2022-06-08 20:04:16 +02:00
//return the vector with all attaks of one enemi
2022-06-08 19:04:37 +02:00
public Vector<Attack> getAllAttacks(){
return attacks;
}
2022-06-08 20:04:16 +02:00
//return the vector with one attak
public Attack getAttack(int a){
2022-06-08 19:04:37 +02:00
return attacks.get(a);
}
2022-06-13 20:53:09 +02:00
2022-06-08 19:04:37 +02:00
}