1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2024-11-23 09:53:28 +00:00
This commit is contained in:
Fastium 2022-06-15 18:20:40 +02:00
parent 045329d8f6
commit 24774190b6
4 changed files with 37 additions and 49 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,5 @@
package Game; package Game;
import java.util.Arrays;
import Entity.Enemy; import Entity.Enemy;
import Text.TextEnemy; import Text.TextEnemy;
@ -10,7 +8,7 @@ public class Battle {
private Enemy e; private Enemy e;
public TextEnemy textEnemy; public TextEnemy textEnemy;
private int lineSpeech; private int lineSpeech;
public int answer;
public int newXp; public int newXp;
public int pvEnemy; public int pvEnemy;
@ -31,9 +29,30 @@ public class Battle {
public void readNextLine(){ public void readNextLine(){
//change line //change line
System.out.println(textEnemy.lines.size()); System.out.println(textEnemy.lines.size());
if(lineSpeech < textEnemy.lines.size()-1){ if(lineSpeech < 5){
lineSpeech++; lineSpeech++;
} }
}
public void action(int answer){
System.out.println("pv enemy : " +pvEnemy);
System.out.println("xp player : " + xpPlayer);
System.out.println("xp win " + newXp);
if(getLineSpeech() == 4){
FinishSpeech();
}
else if( getLineSpeech() == 5 || getLineSpeech() == 6){
finish();
}
else if(0 < getLineSpeech() && getLineSpeech() < 4){
checkAnswer(answer);
}
else{
readNextLine();
}
} }
//check the choice answer //check the choice answer
@ -61,14 +80,7 @@ public class Battle {
else{ else{
System.out.println("it's false !!!!"); System.out.println("it's false !!!!");
} }
System.out.println("pv enemy : " +pvEnemy); readNextLine();
System.out.println("xp player : " + xpPlayer);
System.out.println("xp win " + newXp);
if(lineSpeech < 4) readNextLine();
} }
public void updatePlayerEnemy(int xp){ public void updatePlayerEnemy(int xp){
@ -82,19 +94,20 @@ public class Battle {
public void FinishSpeech(){ public void FinishSpeech(){
if(pvEnemy>0){ if(pvEnemy>0){
//alive (speechline = 6) //alive (speechline = 6)
for(int i=0;i<2;i++)readNextLine();; lineSpeech += 2;
System.out.println("enemy alive");
} }
else{ else{
//dead (speechline = 5) //dead (speechline = 5)
readNextLine(); lineSpeech += 1;
System.out.println("enemy dead");
} }
} }
public boolean finish(){ public void finish(){
return false; screenBattleOn = false;
} }
public boolean getAttackOn(){ public boolean getAttackOn(){
return textEnemy.lines.get(lineSpeech).attackOn; return textEnemy.lines.get(lineSpeech).attackOn;
} }

View File

@ -27,14 +27,10 @@ public class ScreenBattle extends RenderingScreen{
private Battle b = null; private Battle b = null;
@Override @Override
public void onInit() { public void onInit() {
//display the question //display the question
generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK); generateFont("resources/font/Ubuntu-Regular.ttf", 30, Color.BLACK);
} }
@ -44,8 +40,6 @@ public class ScreenBattle extends RenderingScreen{
g.clear(Color.BLACK); g.clear(Color.BLACK);
displayDialog(g); displayDialog(g);
//System.out.println("render: " + battle.getLineSpeech());
} }
@Override @Override
@ -80,12 +74,8 @@ public class ScreenBattle extends RenderingScreen{
if(b.getLine() == null) return; if(b.getLine() == null) return;
g.drawString(15, 245 ,b.getLine() , optimus40); g.drawString(15, 245 ,b.getLine() , optimus40);
} }
public void displayEnemy(Enemy e){ public void displayEnemy(Enemy e){
// TODO affficher l'enemi // TODO affficher l'enemi
} }
@ -98,43 +88,28 @@ public class ScreenBattle extends RenderingScreen{
public void manage(Controller c, Battle battle){ public void manage(Controller c, Battle battle){
if(PokeMudry.front_montant){ if(PokeMudry.front_montant){
System.out.println("manage: " + battle.getLineSpeech());
if( battle.getAttackOn() == false){ if( battle.getAttackOn() == false){
if (c.keyStatus.get(Input.Keys.SPACE)){ if (c.keyStatus.get(Input.Keys.SPACE)){
if(battle.getLineSpeech() == 4){ battle.action(-1);
//dislpay the finish speech
battle.FinishSpeech();
}
else if(battle.getLineSpeech() > 4){
//return in the map
battle.screenBattleOn = battle.finish();
}
else{
//fix next line
battle.readNextLine();
}
} }
if (c.keyStatus.get(Input.Keys.ENTER)){ if (c.keyStatus.get(Input.Keys.ENTER)){
battle.screenBattleOn = battle.finish(); battle.screenBattleOn = battle.screenBattleOn;
} }
} }
if(battle.getAttackOn() == true){ if(battle.getAttackOn() == true){
if (c.keyStatus.get(Input.Keys.NUM_1)){ if (c.keyStatus.get(Input.Keys.NUM_1)){
battle.checkAnswer(1); battle.action(1);
} }
else if (c.keyStatus.get(Input.Keys.NUM_2)){ else if (c.keyStatus.get(Input.Keys.NUM_2)){
battle.checkAnswer(2); battle.action(2);
} }
else if (c.keyStatus.get(Input.Keys.NUM_3)){ else if (c.keyStatus.get(Input.Keys.NUM_3)){
battle.checkAnswer(3); battle.action(3);
} }
else if (c.keyStatus.get(Input.Keys.NUM_4)){ else if (c.keyStatus.get(Input.Keys.NUM_4)){
battle.checkAnswer(4); battle.action(4);
} }
} }