I am doing a simple text based OOP java game. I am a bit stuck at the moment and hoping for a help
Here is the code
while(true){
if(question==1){
String input1 = inputString("You have entered the Dungeon, here you find a " + t.getDesc() + " would you like to fight it? Type Yes/No");
chooseDungeonbattle(input1);
}
if(question == 2){
String input2 = inputString("You have entered the Underworld, it is dark and creepy, but you are not scared...\n SNAP! There is a " + d.getDesc() + " do you wish to fight it?");
chooseUnderworldBattle(input2);
}else if(question == 3){
askUser("You have entered the Dark Forest and you met the Evil Elf, do you wish to fight it? ");
String input3 = inputString("You have entered the Underworld, here you find a " + t.getDesc() + " would you like to fight it? Type Yes/No");
//chooseAbattle3(input3);
}
//If user choose to go to Dungeon
public static void chooseDungeonbattle(String questionInput){
if(questionInput.equals("Yes")||questionInput.equals("yes")){
Battle b = new Battle();
Troll enemy = new Troll(10);
MainPlayer main = new MainPlayer( 100, 100,150,0 );
BadPlayer p = new BadPlayer("",0,0,0);
int goldReceivedDungeon;
b.getOutcome(enemy, main);
if(b.getOutcome(enemy, main).equals("You win")){
System.out.println("You win and receive " + enemy.awardCarried());
goldReceivedDungeon=main.getGold()+ enemy.awardCarried();
System.out.println("You currently have " + enemy.awardCarried());
}else{
System.out.println("Sorry you lost");
}
}
}
public static void chooseUnderworldBattle(String questionInput){
if(questionInput.equals("Yes")||questionInput.equals("yes")){
Battle b = new Battle();
Demon enemy = new Demon(20);
MainPlayer main = new MainPlayer( 100, 100,150,0 );
String asknext;
int goldReceivedDungeon;
b.getOutcome(enemy, main);
if(b.getOutcome(enemy, main).equals("You win")){
System.out.println("You win and receive " + enemy.awardCarried());
goldReceivedDungeon=main.getGold()+ enemy.awardCarried();
asknext = inputString("Would you like to move to you next quest? Press 1 for the Dungeon or 3 for The Dark forest");
}else{
System.out.println("Sorry you lost");
}
}
}
public static void chooseForestBattle(String questionInput){
if(questionInput.equals("Yes")||questionInput.equals("yes")){
Battle b = new Battle();
Elf enemy = new Elf(20);
MainPlayer main = new MainPlayer( 100, 100,150,0 );
int goldReceivedDungeon;
b.getOutcome(enemy, main);
if(b.getOutcome(enemy, main).equals("You win")){
System.out.println("You win and receive " + enemy.awardCarried());
goldReceivedDungeon=main.getGold()+ enemy.awardCarried();
asknext = inputString("Would you like to move to you next quest? Press 1 for the Dungeon or 3 for The Dark forest");
}else{
System.out.println("Sorry you lost");
}
}
}
What I am trying to do is a main Character to input a place where they want to go first (Dungeon, Underworld or Dark forest), If they choose to go to the underworld first and win there, to input where they want to go after that - Dungeon or Dark Forest. And that is all the way until the quests are finished and they collect reward from each quest. I was trying with a while loop, but just loops the same method unfortunately :( Any help is greatly appreciated :)