1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2025-03-14 14:54:33 +00:00
PokeHES/src/Game/Battle.java

131 lines
3.0 KiB
Java
Raw Normal View History

2022-06-10 19:33:24 +02:00
package Game;
2022-06-13 20:53:09 +02:00
import java.util.Arrays;
2022-06-12 12:10:57 +02:00
import Entity.Enemy;
import Text.TextEnemy;
2022-06-10 19:33:24 +02:00
public class Battle {
2022-06-12 12:10:57 +02:00
2022-06-14 01:14:54 +02:00
private Enemy e;
2022-06-13 23:11:17 +02:00
public TextEnemy textEnemy;
2022-06-12 14:26:02 +02:00
private int lineSpeech;
public int answer;
2022-06-13 20:53:09 +02:00
2022-06-15 09:53:54 +02:00
public int newXp;
public int pvEnemy;
public int xpPlayer;
2022-06-13 21:54:05 +02:00
2022-06-13 21:58:13 +02:00
public boolean screenBattleOn = true;
2022-06-12 14:26:02 +02:00
2022-06-13 23:11:17 +02:00
public Battle(Enemy e){
2022-06-14 01:14:54 +02:00
if(e != null){
textEnemy = new TextEnemy(e);
textEnemy.generateText();
}
2022-06-15 09:53:54 +02:00
pvEnemy = e.getPv();
2022-06-12 14:26:02 +02:00
lineSpeech = 0;
2022-06-13 23:11:17 +02:00
newXp = 0;
2022-06-12 12:10:57 +02:00
}
public void readNextLine(){
//change line
2022-06-13 21:38:00 +02:00
System.out.println(textEnemy.lines.size());
if(lineSpeech < textEnemy.lines.size()-1){
lineSpeech++;
}
2022-06-12 12:10:57 +02:00
}
2022-06-13 20:53:09 +02:00
//check the choice answer
public void checkAnswer(int answer){
int attack = lineSpeech-1;
//get number current attack random
int currentAttack = textEnemy.getCurrentData().get(attack)[0];
//get number current answer random
int currentAnswer = textEnemy.getCurrentData().get(attack)[answer];
//get the answer of the player
String answerPlayer = textEnemy.fightData.getAttack(currentAttack).getAnswer(currentAnswer);
//get true answer
String trueAsnwer = textEnemy.fightData.getAttack(currentAttack).getTrueAnswer();
//check the choice of the player
if(answerPlayer == trueAsnwer){
2022-06-13 23:11:17 +02:00
newXp += textEnemy.fightData.getAttack(currentAttack).getXp();
2022-06-15 09:53:54 +02:00
updatePlayerEnemy(textEnemy.fightData.getAttack(currentAttack).getXp());
2022-06-13 20:53:09 +02:00
System.out.println("it's true !!!!");
2022-06-13 23:11:17 +02:00
2022-06-13 20:53:09 +02:00
}
else{
System.out.println("it's false !!!!");
}
2022-06-15 09:53:54 +02:00
System.out.println("pv enemy : " +pvEnemy);
System.out.println("xp player : " + xpPlayer);
System.out.println("xp win " + newXp);
2022-06-13 20:53:09 +02:00
2022-06-15 09:53:54 +02:00
if(lineSpeech < 4) readNextLine();
}
2022-06-13 20:53:09 +02:00
2022-06-15 09:53:54 +02:00
public void updatePlayerEnemy(int xp){
//add xp for the player
xpPlayer += xp;
//remove pv enemy
pvEnemy -= xp;
2022-06-13 20:53:09 +02:00
}
2022-06-15 09:53:54 +02:00
public void FinishSpeech(){
2022-06-14 12:51:47 +02:00
if(pvEnemy>0){
2022-06-15 09:53:54 +02:00
//alive (speechline = 6)
for(int i=0;i<2;i++)readNextLine();;
2022-06-14 12:51:47 +02:00
}
else{
2022-06-15 09:53:54 +02:00
//dead (speechline = 5)
readNextLine();
2022-06-14 12:51:47 +02:00
}
}
2022-06-13 21:38:00 +02:00
public boolean finish(){
return false;
}
2022-06-14 12:51:47 +02:00
2022-06-12 12:10:57 +02:00
public boolean getAttackOn(){
return textEnemy.lines.get(lineSpeech).attackOn;
}
2022-06-11 21:45:45 +02:00
2022-06-12 12:10:57 +02:00
public String getLine(){
2022-06-14 01:14:54 +02:00
if(e==null) return null;
2022-06-12 12:10:57 +02:00
return textEnemy.lines.get(lineSpeech).line;
}
2022-06-12 14:26:02 +02:00
2022-06-14 12:51:47 +02:00
//get the line for the dialog
2022-06-12 14:26:02 +02:00
public int getLineSpeech() {
return lineSpeech;
}
2022-06-13 21:54:05 +02:00
2022-06-14 12:51:47 +02:00
//return true if the screen is active
2022-06-13 21:57:01 +02:00
public boolean getScreenBattleOn(){
2022-06-13 21:54:05 +02:00
return screenBattleOn;
}
2022-06-13 23:11:17 +02:00
2022-06-14 12:51:47 +02:00
//get the total xp win in the battle
2022-06-13 23:11:17 +02:00
public int getNewXp(){
return newXp;
}
2022-06-14 01:14:54 +02:00
2022-06-14 12:51:47 +02:00
public void setXpPlayer(int xp){
xpPlayer = xp;
}
//set enemy
2022-06-14 01:14:54 +02:00
public void setEnemy(Enemy e){
this.e = e;
}
2022-06-10 19:33:24 +02:00
}