mirror of
https://github.com/Klagarge/PokeHES.git
synced 2025-01-31 05:02:45 +00:00
xp modification
This commit is contained in:
parent
997f303567
commit
b944d9be51
@ -41,5 +41,11 @@ public class Enemy extends Character{
|
|||||||
public String getBranch(){
|
public String getBranch(){
|
||||||
return branch;
|
return branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPv() {
|
||||||
|
//the pv can go under 0, but his real pv is 0 (for the player)
|
||||||
|
return (pv<0) ? 0 : pv;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,9 @@ public class Battle {
|
|||||||
private int lineSpeech;
|
private int lineSpeech;
|
||||||
public int answer;
|
public int answer;
|
||||||
|
|
||||||
private int newXp;
|
public int newXp;
|
||||||
private int pvEnemy;
|
public int pvEnemy;
|
||||||
private int xpPlayer;
|
public int xpPlayer;
|
||||||
|
|
||||||
public boolean screenBattleOn = true;
|
public boolean screenBattleOn = true;
|
||||||
|
|
||||||
@ -23,12 +23,9 @@ public class Battle {
|
|||||||
textEnemy = new TextEnemy(e);
|
textEnemy = new TextEnemy(e);
|
||||||
textEnemy.generateText();
|
textEnemy.generateText();
|
||||||
}
|
}
|
||||||
|
pvEnemy = e.getPv();
|
||||||
lineSpeech = 0;
|
lineSpeech = 0;
|
||||||
newXp = 0;
|
newXp = 0;
|
||||||
|
|
||||||
System.out.println("lll : "+ getLine());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readNextLine(){
|
public void readNextLine(){
|
||||||
@ -44,44 +41,54 @@ public class Battle {
|
|||||||
int attack = lineSpeech-1;
|
int attack = lineSpeech-1;
|
||||||
//get number current attack random
|
//get number current attack random
|
||||||
int currentAttack = textEnemy.getCurrentData().get(attack)[0];
|
int currentAttack = textEnemy.getCurrentData().get(attack)[0];
|
||||||
System.out.println(Arrays.toString(textEnemy.getCurrentData().get(attack)));
|
|
||||||
|
|
||||||
//get number current answer random
|
//get number current answer random
|
||||||
int currentAnswer = textEnemy.getCurrentData().get(attack)[answer];
|
int currentAnswer = textEnemy.getCurrentData().get(attack)[answer];
|
||||||
|
|
||||||
//get the answer of the player
|
//get the answer of the player
|
||||||
String answerPlayer = textEnemy.fightData.getAttack(currentAttack).getAnswer(currentAnswer);
|
String answerPlayer = textEnemy.fightData.getAttack(currentAttack).getAnswer(currentAnswer);
|
||||||
System.out.println("answer player : " + answerPlayer);
|
|
||||||
|
|
||||||
//get true answer
|
//get true answer
|
||||||
String trueAsnwer = textEnemy.fightData.getAttack(currentAttack).getTrueAnswer();
|
String trueAsnwer = textEnemy.fightData.getAttack(currentAttack).getTrueAnswer();
|
||||||
System.out.println("true answer : " + trueAsnwer);
|
|
||||||
|
|
||||||
//check the choice of the player
|
//check the choice of the player
|
||||||
if(answerPlayer == trueAsnwer){
|
if(answerPlayer == trueAsnwer){
|
||||||
newXp += textEnemy.fightData.getAttack(currentAttack).getXp();
|
newXp += textEnemy.fightData.getAttack(currentAttack).getXp();
|
||||||
|
updatePlayerEnemy(textEnemy.fightData.getAttack(currentAttack).getXp());
|
||||||
System.out.println("it's true !!!!");
|
System.out.println("it's true !!!!");
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
System.out.println("it's false !!!!");
|
System.out.println("it's false !!!!");
|
||||||
}
|
}
|
||||||
|
System.out.println("pv enemy : " +pvEnemy);
|
||||||
|
System.out.println("xp player : " + xpPlayer);
|
||||||
|
System.out.println("xp win " + newXp);
|
||||||
|
|
||||||
readNextLine();
|
|
||||||
|
if(lineSpeech < 4) readNextLine();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FinishSpeech(int pvEnemy){
|
public void updatePlayerEnemy(int xp){
|
||||||
|
//add xp for the player
|
||||||
|
xpPlayer += xp;
|
||||||
|
//remove pv enemy
|
||||||
|
pvEnemy -= xp;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FinishSpeech(){
|
||||||
if(pvEnemy>0){
|
if(pvEnemy>0){
|
||||||
//alive
|
//alive (speechline = 6)
|
||||||
readNextLine();
|
for(int i=0;i<2;i++)readNextLine();;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//dead
|
//dead (speechline = 5)
|
||||||
|
readNextLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean finish(){
|
public boolean finish(){
|
||||||
return false;
|
return false;
|
||||||
@ -112,10 +119,6 @@ public class Battle {
|
|||||||
return newXp;
|
return newXp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPvEnemy(int pv){
|
|
||||||
pvEnemy = pv;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setXpPlayer(int xp){
|
public void setXpPlayer(int xp){
|
||||||
xpPlayer = xp;
|
xpPlayer = xp;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package Main;
|
package Main;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import com.badlogic.gdx.Input;
|
import com.badlogic.gdx.Input;
|
||||||
|
|
||||||
@ -66,26 +65,26 @@ public class PokeMudry extends PortableApplication {
|
|||||||
sp.e = sp.p.lastEnemy;
|
sp.e = sp.p.lastEnemy;
|
||||||
sp.sb = sp.screenManager.getScreenBattle();
|
sp.sb = sp.screenManager.getScreenBattle();
|
||||||
if(sp.e == null) System.out.println("sdfsdfsdfsdf");
|
if(sp.e == null) System.out.println("sdfsdfsdfsdf");
|
||||||
|
|
||||||
sp.b = new Battle(sp.e);
|
sp.b = new Battle(sp.e);
|
||||||
|
|
||||||
|
//set pv and xp to display
|
||||||
|
sp.b.setXpPlayer(sp.p.getXp());
|
||||||
|
|
||||||
g.resetCamera();
|
g.resetCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(onBattleScreen) sp.sb.manage(controller, sp.b);
|
if(onBattleScreen) sp.sb.manage(controller, sp.b);
|
||||||
|
|
||||||
//manage battle
|
|
||||||
if(!sp.b.getScreenBattleOn()){
|
|
||||||
sp.p.addXp(sp.b.getNewXp());
|
|
||||||
sp.e.removedPv(sp.b.getNewXp());
|
|
||||||
sp.b.setPvEnemy(sp.e.getPv());
|
|
||||||
sp.b.setXpPlayer(sp.p.getXp());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!sp.b.getScreenBattleOn() && onBattleScreen){
|
if(!sp.b.getScreenBattleOn() && onBattleScreen){
|
||||||
|
//addXp for the player
|
||||||
|
sp.p.addXp(sp.b.getNewXp());
|
||||||
|
//remove pv of the enemy
|
||||||
|
sp.e.removedPv(sp.b.getNewXp());
|
||||||
|
|
||||||
sp.p.onEnemy = false;
|
sp.p.onEnemy = false;
|
||||||
sp.sm = sp.screenManager.getScreenMap();
|
sp.sm = sp.screenManager.getScreenMap();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Graphics render
|
// Graphics render
|
||||||
|
@ -35,6 +35,7 @@ public class ScreenBattle extends RenderingScreen{
|
|||||||
//display the question
|
//display the question
|
||||||
generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK);
|
generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,14 +99,21 @@ 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());
|
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() <= 5){
|
if(battle.getLineSpeech() == 4){
|
||||||
|
//dislpay the finish speech
|
||||||
|
battle.FinishSpeech();
|
||||||
|
}
|
||||||
|
else if(battle.getLineSpeech() > 4){
|
||||||
|
//return in the map
|
||||||
battle.screenBattleOn = battle.finish();
|
battle.screenBattleOn = battle.finish();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
System.out.println("in");
|
//fix next line
|
||||||
battle.readNextLine();
|
battle.readNextLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,19 +125,15 @@ public class ScreenBattle extends RenderingScreen{
|
|||||||
|
|
||||||
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.checkAnswer(1);
|
||||||
}
|
}
|
||||||
else if (c.keyStatus.get(Input.Keys.NUM_2)){
|
else if (c.keyStatus.get(Input.Keys.NUM_2)){
|
||||||
|
|
||||||
battle.checkAnswer(2);
|
battle.checkAnswer(2);
|
||||||
}
|
}
|
||||||
else if (c.keyStatus.get(Input.Keys.NUM_3)){
|
else if (c.keyStatus.get(Input.Keys.NUM_3)){
|
||||||
|
|
||||||
battle.checkAnswer(3);
|
battle.checkAnswer(3);
|
||||||
}
|
}
|
||||||
else if (c.keyStatus.get(Input.Keys.NUM_4)){
|
else if (c.keyStatus.get(Input.Keys.NUM_4)){
|
||||||
|
|
||||||
battle.checkAnswer(4);
|
battle.checkAnswer(4);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
package Screen;
|
|
||||||
|
|
||||||
import Entity.Enemy;
|
|
||||||
import Entity.Player;
|
|
||||||
import Game.Battle;
|
|
||||||
import ch.hevs.gdx2d.lib.GdxGraphics;
|
|
||||||
|
|
||||||
public class ScreenPlayer {
|
|
||||||
public ManagerOfScreen screenManager = new ManagerOfScreen();
|
|
||||||
public Player p = null;
|
|
||||||
public Enemy e = null;
|
|
||||||
public Battle b = null;
|
|
||||||
public ScreenMap sm = null;
|
|
||||||
public ScreenBattle sb = null;
|
|
||||||
|
|
||||||
public void init(){
|
|
||||||
|
|
||||||
// One player by ScreenPlayer
|
|
||||||
p = new Player(8, 15, "desert");
|
|
||||||
//p = new Player(4, 2, "21RI");
|
|
||||||
|
|
||||||
b = new Battle(new Enemy("enemi", 0, 0, "charachter", "desert", 50, "enemi"));
|
|
||||||
|
|
||||||
// Create both type of screen and record for reuse
|
|
||||||
screenManager.registerScreen(ScreenMap.class);
|
|
||||||
screenManager.registerScreen(ScreenBattle.class);
|
|
||||||
sb = screenManager.getScreenBattle();
|
|
||||||
sm = screenManager.getScreenMap();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render(GdxGraphics g){
|
|
||||||
if(sm != null){
|
|
||||||
sm.setPlayer(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sb != null){
|
|
||||||
sb.setBattle(b);
|
|
||||||
b.setEnemy(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
screenManager.render(g);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user