package STRAT; import java.util.Scanner; public class Game { public void startGame(){ Scanner input = new Scanner(System.in); Hero H = new Hero(); Enemies E = new Enemies(); Store S = new Store(); Death D = new Death(); Points P = new Points(); Restart R = new Restart(); Loop L = new Loop(); BattlePoints BP = new BattlePoints(); PlayerBP PBP = new PlayerBP(); String battle1 = input.nextLine(); PBP.PlayerBattlePoints = PBP.PlayerBattlePoints + BP.bp1; if(battle1.equals("1")){ System.out.println(""); E.enemyOneHealth = E.enemyOneHealth - H.attackOne; System.out.println("BAM!"); System.out.println(""); System.out.println("Enemy Health = " + E.enemyOneHealth); } else if(battle1.equals("2")){ System.out.println(""); E.enemyOneHealth = E.enemyOneHealth - H.attackTwo; System.out.println("BAM!"); System.out.println(""); System.out.println("Enemy Health = " + E.enemyOneHealth); } else if(battle1.equalsIgnoreCase("3")){ System.out.println(""); E.enemyOneHealth = E.enemyOneHealth - H.attackThree; System.out.println("BAM!"); System.out.println(""); System.out.println("Enemy Health = " + E.enemyOneHealth); } else if(battle1.equalsIgnoreCase("Restart")){ R.isRestarting(); } else { System.out.println(""); System.out.println("Invalid Input"); return; } if(E.enemyOneHealth == D.death){ H.heroHealth = H.heroHealth + 0; } if(E.enemyOneHealth < D.death){ H.heroHealth = H.heroHealth + 0; } else { System.out.println(""); System.out.println("ATTACK RETURNED!"); H.heroHealth = H.heroHealth - E.eOA1; } if(E.eOA1 == 0){ System.out.println(""); System.out.println("Attack Missed!"); System.out.println(" BP = " + PBP.PlayerBattlePoints); System.out.println(""); System.out.println(" HP = " + H.heroHealth); } else { System.out.println(" BP = " + PBP.PlayerBattlePoints); System.out.println(""); System.out.println(" HP = " + H.heroHealth); } if(E.enemyOneHealth == D.death){ System.out.println(""); System.out.println("YOU WIN!"); System.out.println(""); P.playerPoints = true; H.myPoints = H.myPoints + P.PP1; System.out.println("You Gained " + P.PP1 + " Points!"); System.out.println(""); System.out.println(" PP = " + P.PP1); } else if(E.enemyOneHealth < D.death){ System.out.println(""); System.out.println("YOU WIN!"); System.out.println(""); P.playerPoints = true; H.myPoints = H.myPoints + P.PP1; System.out.println("You Gained " + P.PP1 + " Points!"); System.out.println(""); System.out.println(" PP = " + P.PP1); } if(H.heroHealth == D.death){ System.out.println(""); System.out.println("You Died!"); System.out.println(""); System.out.println("Restart?"); System.out.println(""); } else if(H.heroHealth < D.death){ System.out.println(""); System.out.println("You Died!"); System.out.println(""); System.out.println("Restart?"); System.out.println(""); } String battle1a = input.nextLine(); if(battle1a.equals("1")){ System.out.println(""); E.enemyOneHealth = E.enemyOneHealth - H.attackOne; System.out.println("BAM!"); System.out.println(""); System.out.println("Enemy Health = " + E.enemyOneHealth); } else if(battle1a.equals("2")){ System.out.println(""); E.enemyOneHealth = E.enemyOneHealth - H.attackTwo; System.out.println("BAM!"); System.out.println(""); System.out.println("Enemy Health = " + E.enemyOneHealth); } else if(battle1a.equalsIgnoreCase("3")){ System.out.println(""); E.enemyOneHealth = E.enemyOneHealth - H.attackThree; System.out.println("BAM!"); System.out.println(""); System.out.println("Enemy Health = " + E.enemyOneHealth); } else if(battle1a.equalsIgnoreCase("Restart")){ R.isRestarting(); } else { System.out.println(""); System.out.println("Invalid Input"); return; } if(E.enemyOneHealth == D.death){ H.heroHealth = H.heroHealth + 0; } if(E.enemyOneHealth < D.death){ H.heroHealth = H.heroHealth + 0; } else { System.out.println(""); System.out.println("ATTACK RETURNED!"); H.heroHealth = H.heroHealth - E.eOA1; } if(E.eOA1 == 0){ System.out.println(""); System.out.println("Attack Missed!"); System.out.println(""); System.out.println(" HP = " + H.heroHealth); } else { System.out.println(""); System.out.println(" HP = " + H.heroHealth); } if(E.enemyOneHealth == D.death){ System.out.println(""); System.out.println("YOU WIN!"); System.out.println(""); P.playerPoints = true; H.myPoints = H.myPoints + P.PP1; System.out.println("You Gained " + P.PP1 + " Points!"); System.out.println(""); System.out.println(" PP = " + P.PP1); } else if(E.enemyOneHealth < D.death){ System.out.println(""); System.out.println("YOU WIN!"); System.out.println(""); P.playerPoints = true; H.myPoints = H.myPoints + P.PP1; System.out.println("You Gained " + P.PP1 + " Points!"); System.out.println(""); System.out.println(" PP = " + P.PP1); } if(H.heroHealth == D.death){ System.out.println(""); System.out.println("You Died!"); System.out.println(""); System.out.println("Restart?"); System.out.println(""); } else if(H.heroHealth < D.death){ System.out.println(""); System.out.println("You Died!"); System.out.println(""); System.out.println("Restart?"); System.out.println(""); } String battle1b = input.nextLine(); if(battle1b.equals("1")){ System.out.println(""); E.enemyOneHealth = E.enemyOneHealth - H.attackOne; System.out.println("BAM!"); System.out.println(""); System.out.println("Enemy Health = " + E.enemyOneHealth); } else if(battle1b.equals("2")){ System.out.println(""); E.enemyOneHealth = E.enemyOneHealth - H.attackTwo; System.out.println("BAM!"); System.out.println(""); System.out.println("Enemy Health = " + E.enemyOneHealth); } else if(battle1b.equalsIgnoreCase("3")){ System.out.println(""); E.enemyOneHealth = E.enemyOneHealth - H.attackThree; System.out.println("BAM!"); System.out.println(""); System.out.println("Enemy Health = " + E.enemyOneHealth); } else if(battle1b.equalsIgnoreCase("Restart")){ R.isRestarting(); } else { System.out.println(""); System.out.println("Invalid Input"); return; } if(E.enemyOneHealth == D.death){ H.heroHealth = H.heroHealth + 0; } if(E.enemyOneHealth < D.death){ H.heroHealth = H.heroHealth + 0; } else { System.out.println(""); System.out.println("ATTACK RETURNED!"); H.heroHealth = H.heroHealth - E.eOA1; } if(E.enemyOneHealth == D.death){ System.out.println(""); System.out.println("YOU WIN!"); System.out.println(""); P.playerPoints = true; H.myPoints = H.myPoints + P.PP1; System.out.println("You Gained " + P.PP1 + " Points!"); System.out.println(""); System.out.println(" PP = " + P.PP1); } else if(E.enemyOneHealth < D.death){ System.out.println(""); System.out.println("YOU WIN!"); System.out.println(""); P.playerPoints = true; H.myPoints = H.myPoints + P.PP1; System.out.println("You Gained " + P.PP1 + " Points!"); System.out.println(""); System.out.println(" PP = " + P.PP1); } if(E.eOA1 == 0){ System.out.println(""); System.out.println("Attack Missed!"); System.out.println(""); System.out.println(" HP = " + H.heroHealth); } else { System.out.println(""); System.out.println(" HP = " + H.heroHealth); } if(H.heroHealth == D.death){ System.out.println(""); System.out.println("You Died!"); System.out.println(""); System.out.println("Restart?"); System.out.println(""); } else if(H.heroHealth < D.death){ System.out.println(""); System.out.println("You Died!"); System.out.println(""); System.out.println("Restart?"); System.out.println(""); } String restart = input.nextLine(); if(restart.equalsIgnoreCase("Restart")){ R.isRestarting(); } else { System.out.println(""); System.out.println("Invalid Input"); return; } if(E.enemyOneHealth == D.death){ System.out.println(""); System.out.println("YOU WIN!"); System.out.println(""); P.playerPoints = true; H.myPoints = H.myPoints + P.PP1; System.out.println("You Gained " + P.PP1 + " Points!"); System.out.println(""); System.out.println(" PP = " + P.PP1); } else if(E.enemyOneHealth < D.death){ System.out.println(""); System.out.println("YOU WIN!"); System.out.println(""); P.playerPoints = true; H.myPoints = H.myPoints + P.PP1; System.out.println("You Gained " + P.PP1 + " Points!"); System.out.println(""); System.out.println(" PP = " + P.PP1); } } }
What im trying to do is loop to the top of my code, without it kinda restarting. I'm making a game (but it's not an actual game, type game, that is why I am putting it here) and what im trying to do is, have it loop, until either, I die or I kill boss 1.
Here is part of my code.
(I couldn't get my code under here, so it is on top lol)
At the end, I made a loop that wasn't really successful, I would call my void, which in the class it called the startGame(), but when I was done, it would reset, which is not what I wanted. EDIT: I removed the loop, so it's not in the code. But, I had it in there before.
Too, if someone helps me with this, I'll most likely shorten my battle strings.
Thank you so much!
Edited by Error, 23 June 2014 - 09:22 AM.