Skip to content

Instantly share code, notes, and snippets.

@ComputerSaiyajin
Last active February 15, 2023 22:54
Boss battle
//Player Algorithm:
//For player class, the player (Ichigo) starts with 500 HP and 100 SP
//For each turn, the player is presented with an option of skills to use against the boss on the console
//The player can do four different skills:
// 1. Broadsword Slash
// 2. Broadsword Cleaver
// 3. Focus
// 4. Getsuga Tensho!
//Broadsword Slash is the basic attack that does 100 damage to the boss without taking any SP
//Broadsword Cleaver is a stronger version of Broadsword Cleaver that does 500 damage to the boss at the cost of 5 SP
//Focus allows the player to heal 75 HP at the cost of 15 SP, but the boss has a 50% chance of attacking you not allowing you to heal
//Getsuga Tensho! is an attack that does 1000 damage to the boss at the cost of 30 SP
//The Player wins when the boss' heath reaches zero
//The Player gets a GAME OVER when their health reaches Zero
//Boss Algorithm:
//For boss class, the boss starts with 10000 HP
//The boss can do three different attacks, and these attacks are done at random chance by the boss' choice:
// 1. lightattack
// 2. heavyattack
// 3. CHARGE!
//lightattack does 20 damage to the player
//heavyattack does 50 damage to the player
//Charge! does 150 damage to the player, but requires a wind up for the boss to do with a countdown on the console
//When the boss is defeated, it makes the "ARGGHH" sound
import java.util.*;
public class Boss extends Character{
public String name;
public String attack;
public String noise;
public int health;
public Boss(String name, /*String attack,*/ String noise, int health) {
this.name = "Heckran";
this.noise = "ARGGHH";
/* ArrayList<Object> assault = new ArrayList <Object>();
this.assault = "lightattack";
this.assault = "heavyattack";
this.assault = "Charge!";*/
this.health = 10000;
}
@Override
abstract void attack(Character defendingCharacter);/*{
public static void sleep(int time) {
try {
Thread.sleep(time);
} catch (Exception e) {}
}
/*
for (Integer max1 : intList, player.health > 0) {
Random random = new Random();
int num = random.nextInt(yourListLength);
if (nextInt == 0 ) {
System.out.println(this.name + " attacks " + defendingCharacter.name + " and deals 20 damage!");
defendingCharacter.health -= 20;
}if (nextInt == 1 ) {
System.out.println(this.name + " attacks " + defendingCharacter.name + " and deals 50 damage!");
defendingCharacter.health -= 50;
}if (nextInt == 2 ) {
System.out.println(boss.name + " is winding up for an attack");
sleep(5000);
System.out.println("5");
sleep(5000);
System.out.println("4");
sleep(5000);
System.out.println("3");
sleep(5000);
System.out.println("2");
sleep(5000);
System.out.println("1");
sleep(5000);
System.out.println(this.name + " charges at " + defendingCharacter.name + " and deals 150 damage!");
defendingCharacter.health -= 150;
}
}
}*/
}
abstract class Character {
abstract void attack(Character defendingCharacter);
}
 javac -classpath .:/run_dir/junit-4.12.jar:target/dependency/* -d . Boss.java Character.java Main.java Player.java
Boss.java:2: error: Boss is not abstract and does not override abstract method attack(Character) in Character
public class Boss extends Character{
^
Player.java:27: error: cannot find symbol
case "Broadsword Slash": System.out.println(this.name + " attacks the " + defendingCharacter.name + " and deals 100 damage!");
^
symbol: variable name
location: variable defendingCharacter of type Character
Player.java:28: error: cannot find symbol
defendingCharacter.health -= 100;
^
symbol: variable health
location: variable defendingCharacter of type Character
Player.java:29: error: cannot find symbol
case "Broadsword Cleaver": System.out.println(this.name + " attacks the " + defendingCharacter.name + " and deals 500 damage!");
^
symbol: variable name
location: variable defendingCharacter of type Character
Player.java:30: error: cannot find symbol
defendingCharacter.health -= 500;
^
symbol: variable health
location: variable defendingCharacter of type Character
Player.java:42: error: cannot find symbol
case "Getsuga Tensho!": System.out.println(this.name + " attacks the " + defendingCharacter.name + " with a Getsuga Tensho and deals 100 damage!");
^
symbol: variable name
location: variable defendingCharacter of type Character
Player.java:43: error: cannot find symbol
defendingCharacter.health -= 1000;
^
symbol: variable health
location: variable defendingCharacter of type Character
Player.java:47: error: cannot find symbol
} if (defendingCharacter.health <= 0) {
^
symbol: variable health
location: variable defendingCharacter of type Character
Player.java:48: error: cannot find symbol
System.out.println("The " + defendingCharacter.name + " lets out its death scream, \"" + defendingCharacter.noise + "!\" and then dies. YOU WIN");
^
symbol: variable name
location: variable defendingCharacter of type Character
Player.java:48: error: cannot find symbol
System.out.println("The " + defendingCharacter.name + " lets out its death scream, \"" + defendingCharacter.noise + "!\" and then dies. YOU WIN");
^
symbol: variable noise
location: variable defendingCharacter of type Character
Player.java:50: error: cannot find symbol
System.out.println("The " + defendingCharacter.name + " is hurt and enraged!");
^
symbol: variable name
location: variable defendingCharacter of type Character
11 errors
exit status 1
import java.util.Scanner;
import java.util.*;
class Main {
public static void main(String[] args) {
Player player = new Player();
System.out.println(player.name);
System.out.println(player.skill);
System.out.println(player.health);
System.out.println(player.SP);
Scanner choice = new Scanner(System.in);
System.out.println("1. Broadsword Slash\n"
+ "2. Broadsword Cleaver\n"
+ "3. Focus\n"
+ "4. Getsuga Tensho!");
int skill = choice.nextInt();
Boss boss = new Boss("Heckran", /*20, 50, 150,*/ "ARGGHH", 10000);
}
}
import java.util.Scanner;
import java.util.*;
public class Player extends Character{
public String name;
public String skill;
public int health;
public int SP;
public Player() {
this.name = "Ichigo";
ArrayList<Object> skill = new ArrayList <Object>();
this.skill = "Broadsword Slash";
this.skill = "Broadsword Cleaver";
this.skill = "Focus";
this.skill = "Getsuga Tensho!";
this.health = 500;
this.SP = 150;
}
// Scanner choice = new Scanner(System.in);
//int skill = choice.nextInt();
@Override
public void attack(Character defendingCharacter) {
switch(skill) {
case "Broadsword Slash": System.out.println(this.name + " attacks the " + defendingCharacter.name + " and deals 100 damage!");
defendingCharacter.health -= 100;
case "Broadsword Cleaver": System.out.println(this.name + " attacks the " + defendingCharacter.name + " and deals 500 damage!");
defendingCharacter.health -= 500;
this.SP -= 5;
case "Focus": /*Random random = new Random();
int num = random.nextInt(2-0);
if(num == 0){*/
System.out.println(this.name + " used focus and healed 75 damage!");
this.health += 75;
this.SP -= 15;
/*}if(num == 1) {
System.out.println(defendingCharacter.name + " attacks " + this.name + " and deals 20 damage!");
this.health -= 20;
}*/
case "Getsuga Tensho!": System.out.println(this.name + " attacks the " + defendingCharacter.name + " with a Getsuga Tensho and deals 100 damage!");
defendingCharacter.health -= 1000;
this.SP -= 40;
} if (this.health <= 0) {
System.out.println("GAME OVER!");
} if (defendingCharacter.health <= 0) {
System.out.println("The " + defendingCharacter.name + " lets out its death scream, \"" + defendingCharacter.noise + "!\" and then dies. YOU WIN");
} else {
System.out.println("The " + defendingCharacter.name + " is hurt and enraged!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment