mirror of
https://github.com/Klagarge/PokeHES.git
synced 2025-07-17 21:31:10 +00:00
avancée sur la base de donnée des attaques et discours
This commit is contained in:
@ -54,7 +54,7 @@ public class FightData {
|
||||
}
|
||||
|
||||
//return the vector with one attak
|
||||
public Attack getAttacks(int a){
|
||||
public Attack getAttack(int a){
|
||||
return attacks.get(a);
|
||||
}
|
||||
|
||||
|
42
src/Text/SpeechData.java
Normal file
42
src/Text/SpeechData.java
Normal file
@ -0,0 +1,42 @@
|
||||
package Text;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
||||
public class SpeechData {
|
||||
|
||||
Vector<String> speechs = new Vector<String>();
|
||||
File file;
|
||||
|
||||
|
||||
public SpeechData(String name){
|
||||
file = new File("resources//fight//" + name + ".csv");
|
||||
}
|
||||
|
||||
public void readFile() {
|
||||
String line = "";
|
||||
try {
|
||||
FileReader f = new FileReader(file);
|
||||
BufferedReader bf = new BufferedReader(f);
|
||||
|
||||
line = bf.readLine();
|
||||
while(line != null){
|
||||
|
||||
Speechs.add(line);
|
||||
|
||||
line = bf.readLine();
|
||||
}
|
||||
|
||||
bf.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
public String getSpeechs(int i) {
|
||||
return speechs.elementAt(i);
|
||||
}
|
||||
}
|
42
src/Text/TextEnemy.java
Normal file
42
src/Text/TextEnemy.java
Normal file
@ -0,0 +1,42 @@
|
||||
package Text;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class TextEnemy {
|
||||
public FightData fightData;
|
||||
public SpeechData speechData;
|
||||
public boolean attackOn = false;
|
||||
|
||||
Vector<String> line = new Vector<String>();
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
public void generateText(){
|
||||
int i =0;
|
||||
//introduction line
|
||||
line.add(speechData.getSpeechs(i++));
|
||||
|
||||
for(int j=0; i<4;i++){
|
||||
//attack and answer (number on vector : 1-4)
|
||||
line.add(
|
||||
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);
|
||||
}
|
||||
//finish (win and death)
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user