Skip to content

Commit

Permalink
*Bug erradicated - While loop continuously ran within attacks
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanNikaloasTheFirst committed Dec 7, 2022
1 parent 61d301e commit c8716cb
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/PokemonGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ private static void start(Pokemon Pikachu, Pokemon Squirtle, Pokemon Charmander,
public static void rollAttack(Pokemon attackingPokemon, Pokemon defendingPokemon) throws InterruptedException {
int attackDamage = (int) (Math.random() * attackingPokemon.getLevel());
if (attackingPokemon.getHealthPoints() > 0) {
if (attackingPokemon.getType() == defendingPokemon.getType()) {
attackDamage = (int) (attackDamage / 2 + 0.5);

System.out.println(attackingPokemon.getName() + " used " + attackingPokemon.getMoveOne() + " and caused " + attackDamage + " pts of damage");
defendingPokemon.setHealthPoints(defendingPokemon.getHealthPoints() - attackDamage);
System.out.println(defendingPokemon.getName() + " HP: " + defendingPokemon.getHealthPoints());
Expand All @@ -70,27 +69,23 @@ public static void rollAttack(Pokemon attackingPokemon, Pokemon defendingPokemon
}
}

}


public static void rollAttack2(Pokemon attackingPokemon, Pokemon defendingPokemon) throws InterruptedException {
int attackDamage = (int) (Math.random() * attackingPokemon.getLevel());
if (attackingPokemon.getHealthPoints() > 0) {
if (attackingPokemon.getType() == defendingPokemon.getType()) {
attackDamage = (int) (attackDamage / 2 + 0.5);
System.out.println(attackingPokemon.getName() + " used " + attackingPokemon.getMoveTwo() + " and caused " + attackDamage + "pts of damage");
defendingPokemon.setHealthPoints(defendingPokemon.getHealthPoints() - attackDamage);
System.out.println(defendingPokemon.getName() + " HP: " + defendingPokemon.getHealthPoints());
Thread.sleep(3000);
System.out.println("-------------------");
}
}
}


public static void rollAttack3(Pokemon attackingPokemon, Pokemon defendingPokemon) throws InterruptedException {
int attackDamage = (int) (Math.random() * attackingPokemon.getLevel());
if (attackingPokemon.getHealthPoints() > 0) {
if(attackingPokemon.getType() == defendingPokemon.getType()) {
attackDamage = (int) (attackDamage / 2 + 0.5);
System.out.println(attackingPokemon.getName() + " used " + attackingPokemon.getMoveThree() + " and caused " + attackDamage + "pts of damage");
defendingPokemon.setHealthPoints(defendingPokemon.getHealthPoints() - attackDamage);
System.out.println(defendingPokemon.getName() + " HP: " + defendingPokemon.getHealthPoints());
Expand All @@ -99,7 +94,6 @@ public static void rollAttack3(Pokemon attackingPokemon, Pokemon defendingPokemo
}
}

}

public static void challenges(Pokemon attackingPokemon, Pokemon defendingPokemon, ArrayList badges) throws InterruptedException {
int user;
Expand Down

0 comments on commit c8716cb

Please sign in to comment.