1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2024-11-26 19:13:27 +00:00

Merge pull request #6 from Klagarge/fight-data

add fight data at enemy
This commit is contained in:
Fastium 2022-06-08 19:04:37 +01:00 committed by GitHub
commit 1a84524e14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 26 deletions

View File

@ -1,14 +1,21 @@
package Entity; package Entity;
import Text.FightData;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import ch.hevs.gdx2d.lib.GdxGraphics; import ch.hevs.gdx2d.lib.GdxGraphics;
public class Enemy extends Character{ public class Enemy extends Character{
public FightData fightData;
public Enemy(String name, int x, int y, String img) { public Enemy(String name, int x, int y, String img) {
super(name, x, y, img); super(name, x, y, img);
//generate the vector of fight
fightData = new FightData(name);
//TODO Auto-generated constructor stub //TODO Auto-generated constructor stub
} }
public void setPosition(int x, int y){ public void setPosition(int x, int y){

23
src/Text/Attack.java Normal file
View File

@ -0,0 +1,23 @@
package Text;
public class Attack {
String attack;
String answer1;
String answer2;
String answer3;
String answer4;
float xp;
Attack(String attack, String answer1,String answer2,String answer3, String answer4, float xp){
this.attack = attack;
this.answer1 = answer1;
this.answer2 = answer2;
this.answer3 = answer3;
this.answer4 = answer4;
this.xp = xp;
}
public String toString(){
return attack+ " " + answer1+ " " + answer2+ " " + answer3+ " " + answer4+ " " + xp;
}
}

View File

@ -11,19 +11,21 @@ public class FightData {
private File file; private File file;
private static final String REGEX = ","; private static final String REGEX = ",";
/*
public static void main(String[] args) { public static void main(String[] args) {
FightData d = new FightData("app/src/main/java/test_map/data/donnee.csv"); FightData d = new FightData("enemi");
d.readFile(); d.readFile();
for(Attack a : d.attacks){ for(Attack a : d.attacks){
System.out.println(a); System.out.println(a);
} }
} }
*/
public FightData(String pathname){ public FightData(String name) {
file = new File(pathname); file = new File("resources//fight//" + name + ".csv");
} }
public void readFile(){ public void readFile() {
Attack attack; Attack attack;
String line = ""; String line = "";
try { try {
@ -46,37 +48,17 @@ public class FightData {
} }
//return the vector with all attaks of one enemi
public Vector<Attack> getAllAttacks(){ public Vector<Attack> getAllAttacks(){
return attacks; return attacks;
} }
//return the vector with one attak
public Attack getAttacks(int a){ public Attack getAttacks(int a){
return attacks.get(a); return attacks.get(a);
} }
} }
class Attack{
String attack;
String answer1;
String answer2;
String answer3;
String answer4;
float xp;
Attack(String attack, String answer1,String answer2,String answer3, String answer4, float xp){
this.attack = attack;
this.answer1 = answer1;
this.answer2 = answer2;
this.answer3 = answer3;
this.answer4 = answer4;
this.xp = xp;
}
public String toString(){
return attack+ " " + answer1+ " " + answer2+ " " + answer3+ " " + answer4+ " " + xp;
}
}