From 2e034c4f858c4c2854a7372024417cf391fee007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Fri, 17 Jun 2022 21:45:05 +0200 Subject: [PATCH] select answer with row --- src/Control/Controller.java | 1 + src/Game/Battle.java | 4 +++- src/Main/PokeHES.java | 1 + src/Screen/ScreenBattle.java | 27 ++++++++++++++++++++------- src/Text/TextEnemy.java | 16 ++++++++++------ 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/Control/Controller.java b/src/Control/Controller.java index bf4a3fd..9303ebd 100644 --- a/src/Control/Controller.java +++ b/src/Control/Controller.java @@ -25,6 +25,7 @@ public class Controller { keyStatus.put(Input.Keys.NUM_3, false); keyStatus.put(Input.Keys.NUM_4, false); keyStatus.put(Input.Keys.SPACE, false); + keyStatus.put(Input.Keys.A, false); keyStatus.put(Input.Keys.ENTER, false); } diff --git a/src/Game/Battle.java b/src/Game/Battle.java index 0b8e8b9..6f3fe2a 100644 --- a/src/Game/Battle.java +++ b/src/Game/Battle.java @@ -18,12 +18,14 @@ public class Battle { public int xpPlayer; public boolean screenBattleOn = true; + public int cursor = 0; public Battle(Enemy e){ if(e != null){ textEnemy = new TextEnemy(e); - textEnemy.generateText(); + textEnemy.generateText(cursor); } + pvEnemy = e.getPv(); lineSpeech = 0; newXp = 0; diff --git a/src/Main/PokeHES.java b/src/Main/PokeHES.java index df9ce32..cc1ded2 100644 --- a/src/Main/PokeHES.java +++ b/src/Main/PokeHES.java @@ -46,6 +46,7 @@ public class PokeHES extends PortableApplication { sp.init(); controller.init(); + enemies.add(new Enemy("Mudry", 5, 6, "21RI", 700, "informatique")); // add player, create and add all enemies in entities entities.add((Entity) sp.p); enemies.add(new Enemy("Gloeckner", 1, 7, "21N307", 600, "allemand")); diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index c59dcea..eaaec7e 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -109,24 +109,37 @@ public class ScreenBattle extends RenderingScreen{ public void manage(Controller c, Battle battle){ //add a rising front to have one impulsion if(PokeHES.risingFront){ - //the enemi is attacking + //the enemy is attacking if( battle.getAttackOn() == false){ - if (c.keyStatus.get(Input.Keys.SPACE)){ + if (c.keyStatus.get(Input.Keys.SPACE) || c.keyStatus.get(Input.Keys.A)){ battle.action(-1); } } - //the enemi is speaking + + if (c.keyStatus.get(Input.Keys.DOWN)){ + b.cursor++; + } + else if (c.keyStatus.get(Input.Keys.UP)){ + b.cursor--; + } + + if (b.cursor>3)b.cursor =0; + if (b.cursor<0)b.cursor =3; + + System.out.println("" + b.cursor); + + //the enemy is speaking if(battle.getAttackOn() == true){ - if (c.keyStatus.get(Input.Keys.NUM_1)){ + if (c.keyStatus.get(Input.Keys.NUM_1) || c.keyStatus.get(Input.Keys.A) && b.cursor == 0){ battle.action(1); } - else if (c.keyStatus.get(Input.Keys.NUM_2)){ + else if (c.keyStatus.get(Input.Keys.NUM_2) || c.keyStatus.get(Input.Keys.A) && b.cursor == 1){ battle.action(2); } - else if (c.keyStatus.get(Input.Keys.NUM_3)){ + else if (c.keyStatus.get(Input.Keys.NUM_3) || c.keyStatus.get(Input.Keys.A) && b.cursor == 2){ battle.action(3); } - else if (c.keyStatus.get(Input.Keys.NUM_4)){ + else if (c.keyStatus.get(Input.Keys.NUM_4) || c.keyStatus.get(Input.Keys.A) && b.cursor == 3){ battle.action(4); } } diff --git a/src/Text/TextEnemy.java b/src/Text/TextEnemy.java index b990934..3d45edf 100644 --- a/src/Text/TextEnemy.java +++ b/src/Text/TextEnemy.java @@ -2,6 +2,7 @@ package Text; import Entity.Enemy; import java.util.Vector; +import java.text.Normalizer; import java.util.Arrays; import java.util.Random; @@ -66,7 +67,7 @@ public class TextEnemy { //generate the text who is displays in battle screen - public void generateText(){ + public void generateText(int cursor){ int i =1; //introduction line @@ -88,13 +89,16 @@ public class TextEnemy { } //Format the line + String[] row = new String[4]; + row[0] = row[1] = row[2] = row[3] = ""; + row[cursor] = "->"; String attack = formatLine(speechData.getSpeechs(i++) + fightData.getAttack(orderAttack[j]).attack + " ("+fightData.getAttack(orderAttack[j]).getXp()+ ") ", CUT); - String answer1 = formatLine("1. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[0]) , CUT); - String answer2 = formatLine("2. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[1]) , CUT); - String answer3 = formatLine("3. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[2]) , CUT); - String answer4 = formatLine("4. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[3]) , CUT); + String answer1 = formatLine(row[0] + " " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[0]) , CUT); + String answer2 = formatLine(row[1] + " " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[1]) , CUT); + String answer3 = formatLine(row[2] + " " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[2]) , CUT); + String answer4 = formatLine(row[3] + " " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[3]) , CUT); - //attack and answer (number on vector : 1-4) + //attack and answer (number on vector : 1-4) lines.add(new Line(attack + "\n" +answer1 + "\n" + answer2 + "\n" + answer3 + "\n" + answer4, true)); //save the order of the answer