From 0e4780ba43337353924a8f1848670ecdffedd0b6 Mon Sep 17 00:00:00 2001 From: Fastium <79766552+Fastium@users.noreply.github.com> Date: Wed, 8 Jun 2022 20:04:16 +0200 Subject: [PATCH] add fight data at enemy --- resources/fight/{fight.csv => enemi.csv} | 0 src/Entity/Enemy.java | 7 +++++ src/Text/Attack.java | 23 ++++++++++++++++ src/Text/FightData.java | 34 ++++++------------------ 4 files changed, 38 insertions(+), 26 deletions(-) rename resources/fight/{fight.csv => enemi.csv} (100%) create mode 100644 src/Text/Attack.java diff --git a/resources/fight/fight.csv b/resources/fight/enemi.csv similarity index 100% rename from resources/fight/fight.csv rename to resources/fight/enemi.csv diff --git a/src/Entity/Enemy.java b/src/Entity/Enemy.java index 22f2ec4..bf8a4d7 100644 --- a/src/Entity/Enemy.java +++ b/src/Entity/Enemy.java @@ -1,14 +1,21 @@ package Entity; +import Text.FightData; + import com.badlogic.gdx.math.Vector2; import ch.hevs.gdx2d.lib.GdxGraphics; public class Enemy extends Character{ + public FightData fightData; + public Enemy(String name, int x, int y, String img) { super(name, x, y, img); + //generate the vector of fight + fightData = new FightData(name); //TODO Auto-generated constructor stub + } public void setPosition(int x, int y){ diff --git a/src/Text/Attack.java b/src/Text/Attack.java new file mode 100644 index 0000000..e63e063 --- /dev/null +++ b/src/Text/Attack.java @@ -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; + } +} diff --git a/src/Text/FightData.java b/src/Text/FightData.java index db07cb2..7e87ca2 100644 --- a/src/Text/FightData.java +++ b/src/Text/FightData.java @@ -11,19 +11,21 @@ public class FightData { private File file; private static final String REGEX = ","; + /* 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(); for(Attack a : d.attacks){ System.out.println(a); } } + */ - public FightData(String pathname){ - file = new File(pathname); + public FightData(String name) { + file = new File("resources//fight//" + name + ".csv"); } - public void readFile(){ + public void readFile() { Attack attack; String line = ""; try { @@ -46,37 +48,17 @@ public class FightData { } + //return the vector with all attaks of one enemi public Vector getAllAttacks(){ return attacks; } - + //return the vector with one attak public Attack getAttacks(int 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; - } -}