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

72 lines
1.6 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;
2022-06-16 18:59:45 +02:00
import java.nio.charset.StandardCharsets;
2022-06-08 19:04:37 +02:00
import java.util.Vector;
public class FightData {
private Vector<Attack> attacks = new Vector<Attack>();
private File file;
2022-06-14 01:14:54 +02:00
private static String regex = ";";
2022-06-08 19:04:37 +02:00
2022-06-13 20:53:09 +02:00
2022-06-12 12:10:57 +02:00
public int nbre_line =0;
2022-06-14 01:14:54 +02:00
public FightData(String branch) {
2022-06-16 10:26:51 +02:00
file = new File("./Data/Battle/Fight/" + branch + ".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 {
2022-06-16 18:59:45 +02:00
FileReader f = new FileReader(file, StandardCharsets.UTF_8);
2022-06-08 19:04:37 +02:00
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();
2022-06-14 01:14:54 +02:00
System.out.println(line);
2022-06-08 19:04:37 +02:00
while(line != null){
2022-06-14 01:14:54 +02:00
String[] a = line.split(regex);//change the regex if it is another
System.out.println(a.length);
attack = new Attack(a[0], a[1], a[2], a[3], a[4], Integer.valueOf(a[5]));
2022-06-08 19:04:37 +02:00
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
}