Upload files to "WitchGame"

This commit is contained in:
gaven 2025-09-26 16:45:25 +00:00
parent a18e15592b
commit bf8c413466
4 changed files with 798 additions and 0 deletions

35
WitchGame/Spell.java Normal file
View File

@ -0,0 +1,35 @@
package witchGame;
import java.util.Random;
public abstract class Spell {
static Random rand = new Random();
protected String name = "spell";
protected int manaCost = 0;
public Spell(String name) {
this.name = name;
}
public Spell() {}
public abstract int cast();
public String getName() {
return name;
}
protected int getManaCost() {
return manaCost;
}
public int dice(int num, int of) {
int dieTotal = 0;
for (int i = 0; i < num; i++) {
dieTotal += rand.nextInt(of) + 1;
}
return dieTotal;
}
}

12
WitchGame/TargetType.java Normal file
View File

@ -0,0 +1,12 @@
package witchGame;
public enum TargetType {
Null,
Self,
Enemy,
AllEnemies,
Untargetable,
}

352
WitchGame/witch.java Normal file
View File

@ -0,0 +1,352 @@
package witchGame;
import java.util.ArrayList;
import java.util.Arrays;
//import java.util.Collections;
import java.util.HashMap;
import java.util.Random;
import java.util.Scanner;
//@SuppressWarnings("unused")
public class witch {
final static String[] biomes = {"arctic", "coastal", "desert", "forest", "grassland", "hills", "mountains", "swampland", "underdark", "underwater", "urban"};
final static String[] damageTypes = {"acid", "bludgeoning", "cold", "fire", "force", "lightning", "necrotic", "piercing", "poison", "psychic", "radiant", "slashing", "thunder"};
public static int game = 1;
public static int score = 0;
public static int level = 1;
public static int playerMana = 25;
public static int saveDC = 15;
public static int playerAC = 10;
public static int playerHealth = 15;
public static int tempHealth = 0;
public static boolean reaction = true;
public static ArrayList<Condition> playerConditions;
public static final ArrayList<Spell> spellIndex = new ArrayList<>();
static {
// Level 0 Spells:
spellIndex.add(new DamageSpell("Acid Splash", AttackType.DexteritySave, 1, 6, 0, true, 0, false, 1, DamageType.Acid, null));
spellIndex.add(new DamageSpell("Chill Touch", AttackType.RangedSpellAttack, 1, 8, 0, false, 0, false, 1, DamageType.Necrotic, new Condition(ConditionType.CantHeal, 1)));
spellIndex.add(new DamageSpell("Eldrich Blast", AttackType.RangedSpellAttack, 1, 10, 0, false, 0, false, 1, DamageType.Force, null));
spellIndex.add(new DamageSpell("Firebolt", AttackType.RangedSpellAttack, 1, 10, 0, false, 0, false, 1, DamageType.Fire, null));
spellIndex.add(new DamageSpell("Poison Spray", AttackType.ConstitutionSave, 1, 12, 0, false, 0, false, 1, DamageType.Poison, null));
spellIndex.add(new DamageSpell("Produce Flame", AttackType.RangedSpellAttack, 1, 8, 0, false, 0, false, 1, DamageType.Fire, new Condition(ConditionType.Light, 1)));
spellIndex.add(new DamageSpell("Ray of Frost", AttackType.RangedSpellAttack, 1, 10, 0, false, 0, false, 1, DamageType.Cold, null));
spellIndex.add(new DamageSpell("Sacred Flame", AttackType.DexteritySave, 1, 10, 0, false, 0, false, 1, DamageType.Radiant, null));
spellIndex.add(new DamageSpell("Shocking Grasp", AttackType.MeleeSpellAttack, 1, 10, 0, false, 0, false, 1, DamageType.Lightning, new Condition(ConditionType.CantPursue, 1)));
spellIndex.add(new DamageSpell("Vicious Mockery", AttackType.WisdomSave, 1, 4, 0, false, 0, false, 1, DamageType.Psychic, new Condition(ConditionType.DisadvantageOnAttacks, 1)));
// Level 1 Spells:
spellIndex.add(new DamageSpell("Burning Hands", AttackType.DexteritySave, 3, 6, 0, true, 2, true, 1, DamageType.Fire, null));
spellIndex.add(new DamageSpell("Guiding Bolt", AttackType.RangedSpellAttack, 4, 6, 0, false, 2, false, 1, DamageType.Radiant, null));
spellIndex.add(new DamageSpell("Hellish Rebuke", AttackType.DexteritySave, 2, 10, 0, false, 2, false, 1, DamageType.Fire, null));
spellIndex.add(new DamageSpell("Inflict Wounds", AttackType.MeleeSpellAttack, 3, 10, 0, false, 2, false, 1, DamageType.Necrotic, null));
spellIndex.add(new DamageSpell("Magic Missile", AttackType.AutoHit, 1, 4, 1, false, 2, false, 3, DamageType.Force, null));
spellIndex.add(new DamageSpell("Thunderwave", AttackType.ConstitutionSave, 2, 8, 0, true, 2, true, 1, DamageType.Thunder, null));
// Level 2 Spells:
spellIndex.add(new DamageSpell("Acid Arrow", AttackType.RangedSpellAttack, 4, 4, 5, false, 3, true, 1, DamageType.Acid, null));
spellIndex.add(new DamageSpell("Scorching Ray", AttackType.RangedSpellAttack, 2, 6, 0, false, 3, false, 3, DamageType.Fire, null));
spellIndex.add(new DamageSpell("Shatter", AttackType.ConstitutionSave, 3, 8, 0, true, 3, true, 1, DamageType.Thunder, null));
// Level 3 Spells:
spellIndex.add(new DamageSpell("Fireball", AttackType.DexteritySave, 8, 6, 0, true, 5, true, 1, DamageType.Fire, null));
spellIndex.add(new DamageSpell("Lightning Bolt", AttackType.DexteritySave, 8, 6, 0, false, 5, true, 1, DamageType.Lightning, null));
}
public static ArrayList<Spell> spellbook = new ArrayList<>();
public static ArrayList<Enemy> enemies = new ArrayList<>();
public static ArrayList<Enemy> enemiesEncountered = new ArrayList<>();
// Initialize Map
public static int[][] map = new int[25][45];
public static int[][] map_ = new int[map.length+2][map[0].length+2];
// Print all values in map
public static void printMap() {
for (int[] i : map) {
System.out.print("\t");
for (int j : i) {
System.out.print(j + " ");
}
System.out.println();
}
}
static Random rand = new Random();
// Roll any number [num] of dice with any number of sides [of]
public static int dice(int num, int of) {
int dieTotal = 0;
for (int i = 0; i < num; i++) {
dieTotal += rand.nextInt(of) + 1;
}
for (int i = 0; i > num; i--) {
dieTotal -= rand.nextInt(of) + 1;
}
return dieTotal;
}
// Generates a random Enemy out of the ArrayList<Enemy> Enemy.enemyList and places a copy of it in ArrayList<Enemy> witch.enemies
public static void randomEnemy() {
Enemy newEnemy = Enemy.enemyList.get(rand.nextInt(Enemy.enemyList.size())).clone();
// Enemy newEnemy = Enemy.enemyList.get(10).clone(); // generates a goat
witch.enemies.add(newEnemy);
System.out.println("A new " + newEnemy.getName() + " has appeared.");
}
// Searches ArrayList<Enemy> Enemy.enemyList for an Enemy with the same name as the parameter [name]. If found, the enemy is cloned and added to ArrayList<Enemy> witch.enemies
public static void newEnemy(String name) {
for (Enemy e : Enemy.enemyList) {
if (e.getName().compareToIgnoreCase(name) == 0) {
Enemy newEnemy = e.clone();
witch.enemies.add(newEnemy);
return;
}
}
throw new IllegalArgumentException("Enemy not found @ name: " + name);
}
// The enemy at the index [index] of ArrayList<Enemy> Enemy.enemyList is cloned and added to ArrayList<Enemy> witch.enemies
public static void newEnemy(int index) {
if (Enemy.enemyList.size() > index) {
witch.enemies.add(Enemy.enemyList.get(index).clone());
return;
}
throw new IllegalArgumentException("Enemy not found @ index: " + index);
}
public static void addRandomEnemies() {
for (int i = 1; i - 1 < rand.nextInt(5); i++) { //rand.nextInt(5)
witch.randomEnemy();
}
witch.randomEnemy();
}
public static void showHealth() {
// Spacing to make enemy health bars line up
int[] len = new int[witch.enemies.size()];
for (int e = 0; e < witch.enemies.size(); e++) {
len[e] = witch.enemies.get(e).getName().length();
}
int max = Arrays.stream(len).max().getAsInt();
String[] spa = new String[witch.enemies.size()];
for (int e = 0; e < witch.enemies.size(); e++) {
len[e] = -(len[e] - max);
spa[e] = "";
for (int i = 0; i < len[e]; i++) {
spa[e] += " ";
}
}
// Prints enemy numbers, name and health bars
System.out.println();
for (int e = 0; e < witch.enemies.size(); e++) {
System.out.print("Enemy " + (e + 1) + ": " + witch.enemies.get(e).getName() + spa[e] + " - [");
double healthPercent = (100 * witch.enemies.get(e).getHealth()) / (witch.enemies.get(e).getMaxHealth());
for (int i = 0; i < 10; i++) {
if (i < healthPercent / 10) {
System.out.print("=");
} else {
System.out.print(" ");
}
}
System.out.println("]");
// Prints health values if witchRunner.showHealth is on
if (witchRunner.showHealth) {
System.out.println("\t " + witch.enemies.get(e).getHealth() + " / " + witch.enemies.get(e).getMaxHealth());
}
}
// After all enemies health are printed, print the player's health
System.out.println();
System.out.println("You have " + playerHealth + " health.");
System.out.println();
}
// Allows the player to add a spell to their spellbook between 2 spell levels
public static Spell addSpell(int levelMin, int levelMax) {
// Turns level to Mana Cost
int[] mana = new int[]{getManaCost(levelMin), getManaCost(levelMax)};
int firstSpell = 0;
int secondSpell = 0;
for (Integer sp = 0; sp < spellIndex.size(); sp++) {
if (spellIndex.get(sp).getManaCost() >= mana[0]) {
firstSpell = sp;
break;
}
}
for (Integer sp = spellIndex.size() - 1; sp > 0; sp--) {
if (spellIndex.get(sp).getManaCost() <= mana[1]) {
secondSpell = sp;
break;
}
}
// System.out.println(firstSpell);
// System.out.println(secondSpell);
// System.out.println(Arrays.toString(getList(firstSpell, secondSpell)));
// System.out.println("First: " + firstSpell + " - Second: " + secondSpell);
// for (int i = 0; i < 1000; i++)
// System.out.println(rand.nextInt(secondSpell+1-firstSpell)+firstSpell);
// if (secondSpell - firstSpell + 1 >= witch.spellbook.size() + 3) {
if (checkSpells(getList(firstSpell, secondSpell))) {
int[] spells = new int[]{0, 0, 0};
while (!checkSpells(spells)) {
spells = new int[]{rand.nextInt(secondSpell + 1 - firstSpell) + firstSpell, rand.nextInt(secondSpell + 1 - firstSpell) + firstSpell, rand.nextInt(secondSpell + 1 - firstSpell) + firstSpell};
}
@SuppressWarnings("resource")
Scanner sc = new Scanner(System.in);
System.out.println("Choose a spell to add to your Spellbook: ");
System.out.println((spells[0] != -1 ? spellIndex.get(spells[0]).getName() : "") + (spells[1] != -1 ? " " + spellIndex.get(spells[1]).getName() : "") + (spells[2] != -1 ? " " + spellIndex.get(spells[2]).getName() : ""));
String input;
int spellSelection = -1;
while (spellSelection == -1) {
input = sc.nextLine().toLowerCase();
if (input.compareTo("spellbook") == 0 || input.compareTo("sb") == 0) {
witchRunner.showSpellbook();
}
if (input.replaceAll(" ", "").startsWith("id") || input.replaceAll(" ", "").startsWith("identify")) {
for (int sp : spells) {
spellbook.add(spellIndex.get(sp));
}
// witchRunner.showSpellbook();
witchRunner.identify(input.replaceAll(" ", ""));
for (int sp : spells) {
spellbook.remove(spellbook.lastIndexOf(spellIndex.get(sp)));
}
}
for (int sp : spells) {
if (input.replaceAll(" ", "").compareToIgnoreCase(spellIndex.get(sp).getName().replaceAll(" ", "")) == 0) {
spellSelection = sp;
}
if (input.replaceAll("[^\\d]", "").compareTo(input) == 0 && input.replaceAll("[^\\d]", "").compareTo("") != 0) {
// if (input.replaceAll("[^0-9]", "").compareTo(input) == 0) {
int spInt = Integer.parseInt(input.replaceAll("[^\\d]", ""));
if (spInt > 0 && spInt < 4) {
spellSelection = spells[spInt - 1];
}
}
}
}
System.out.println();
witch.spellbook.add(spellIndex.get(spellSelection));
return spellIndex.get(spellSelection);
}
return null;
}
static boolean checkSpells(int[] spells) {
// System.out.println("CheckSpells");
HashMap<Spell, Integer> map = new HashMap<>();
for (Integer sp : spells) {
map.put(spellIndex.get(sp), sp);
}
for (Spell sp : witch.spellbook) {
map.put(sp, spellIndex.indexOf(sp));
}
return (map.size() - witch.spellbook.size() >= 3);
}
// Returns the mana cost of a spell with the level of the spell being parameter [spellLevel]
static int getManaCost(int spellLevel) {
return switch (spellLevel) {
case 0 -> 0;
case 1 -> 2;
case 2 -> 3;
case 3 -> 5;
case 4 -> 6;
case 5 -> 7;
case 6 -> 9;
case 7 -> 10;
case 8 -> 11;
case 9 -> 13;
default -> -1;
};
}
// Returns an int[] of values from [low] to [high] including both numbers
static int[] getList(int low, int high) {
ArrayList<Integer> arrList = new ArrayList<>();
for (int i = low; i <= high; i++) {
arrList.add(i);
}
return arrList.stream().mapToInt(Integer::intValue).toArray();
}
public static int increaseScore(int val) {
return score += val;
}
public static void adjustLevel() {
if (score < 300) {
level = 1;
} else if (score < 900) {
level = 2;
} else if (score < 2700) {
level = 3;
} else if (score < 6500) {
level = 4;
} else if (score < 14000) {
level = 5;
} else if (score < 23000) {
level = 6;
} else if (score < 34000) {
level = 7;
} else if (score < 48000) {
level = 8;
} else if (score < 64000) {
level = 9;
} else if (score < 85000) {
level = 10;
} else if (score < 100000) {
level = 11;
} else if (score < 120000) {
level = 12;
} else if (score < 140000) {
level = 13;
} else if (score < 165000) {
level = 14;
} else if (score < 195000) {
level = 15;
} else if (score < 225000) {
level = 16;
} else if (score < 265000) {
level = 17;
} else if (score < 305000) {
level = 18;
} else if (score < 355000) {
level = 19;
} else if (score >= 35500) {
level = 20;
}
// System.out.println(level);
}
public static void removeEnemy(Enemy enemy) {
score += enemy.getXP();
enemies.remove(enemy);
enemy.deathMessage();
for (int i = 0; i < enemiesEncountered.size(); i++) {
if (enemy.getName().compareTo(enemiesEncountered.get(i).getName()) == 0) {
return;
}
}
enemiesEncountered.add(enemy);
}
}

399
WitchGame/witchRunner.java Normal file
View File

@ -0,0 +1,399 @@
package witchGame;
import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
//import java.util.ArrayList;
import java.util.Scanner;
import javax.swing.JFrame;
//@SuppressWarnings("unused")
public class witchRunner {
public static boolean showHealth = true;
public static boolean showMap = true;
public static Spell cast(String input) {
input = input.substring(4);
if (getSpell(input) != null) {
getSpell(input).cast();
return getSpell(input);
}
System.out.println("Could not find spell: " + input + "\n");
return null;
}
public static Object getInput(String input) {
System.out.println();
if (input.compareTo("regen") == 0 || input.compareTo("regenerate") == 0) {
regenerate();
return null;
}
if (input.compareTo("spellbook") == 0 || input.compareTo("sb") == 0) {
showSpellbook();
return null;
}
if (input.compareTo("health") == 0) {
showHealth();
return null;
}
if (input.compareTo("actions") == 0) {
showActions();
return null;
}
if (input.startsWith("id") || input.startsWith("identify")) {
identify(input);
return null;
}
if (input.startsWith("cast")) {
return cast(input);
}
return null;
}
public static Spell getSpell(String toCast) {
if (toCast == null) {
return null;
}
for (Spell k : witch.spellbook) {
if (toCast.replaceAll("[^A-z]", "").compareToIgnoreCase(k.getName().replaceAll(" ", "")) == 0) {
return k;
}
}
if (Integer.parseInt("0" + toCast.replaceAll("[^0-9]", "")) > 0 && Integer.parseInt("0" + toCast.replaceAll("[^0-9]", "")) <= witch.spellbook.size()) {
Spell k = witch.spellbook.get(Integer.parseInt(toCast.replaceAll("[^0-9]", "")) - 1);
return k;
}
return null;
}
private static void showActions() {
System.out.println("Actions: \nCast\nItem (uncoded)\nInventory (uncoded)\nIdentify (spells coded; enemies beta)");
}
private static void regenerate() {
witch.playerMana = 25;
witch.playerHealth = 15;
System.out.println("Mana: " + witch.playerMana);
System.out.println("Health: " + witch.playerHealth);
}
private static void showHealth() {
showHealth = !showHealth;
System.out.println(showHealth);
}
static void showSpellbook() {
System.out.println("Current Spellbook: ");
for (int i = 0; i < witch.spellbook.size(); i++) {
System.out.println((i < 9 ? "0" : "") + (i + 1) + "- " + witch.spellbook.get(i).getName());
}
System.out.println();
}
static void identify(String input) {
if (input.startsWith("identify")) {
input = input.substring(8);
} else {
input = input.substring(2);
}
String inputTrimed = new String (input);
inputTrimed.replaceAll(" ", "").toLowerCase();
if (getSpell(inputTrimed) != null) { // Check Spellbook if the spell is castable
System.out.println(getSpell(inputTrimed).toString());
return;
}
for (Enemy i : witch.enemiesEncountered) { // Check Enemies Encountered
if (inputTrimed.compareToIgnoreCase(i.getName().replaceAll(" ", "")) == 0) {
System.out.println(i.toString());
return;
}
}
for (Spell i : witch.spellIndex) {
if (inputTrimed.compareToIgnoreCase(i.getName().replaceAll(" ", "")) == 0) {
System.out.println("Learn the spell " + i.getName() + " to identify it\n");
return;
}
}
for (Enemy i : witch.enemies) {
if (inputTrimed.compareToIgnoreCase(i.getName()) == 0) {
System.out.println("Defeat a " + i.getName() + " to identify it\n");
return;
}
}
System.out.println("Could not find \"" + input.trim() + "\"\n");
}
public static boolean checkRegions(int[][] locations) {
for (int l = 0; l < locations.length; l++) {
for (int k = l + 1; k < locations.length; k++) {
int dx = locations[l][0] - locations[k][0];
int dy = locations[l][1] - locations[k][1];
if (Math.abs(dx) + Math.abs(dy) < 5) {
return false;
}
}
}
return true;
}
public static boolean checkIntersections() {
for (int x = 1; x < witch.map.length-1; x++) {
for (int y = 1; y < witch.map[0].length-1; y++) {
boolean[] adj = new boolean[regions.length];
int count = 0;
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
adj[witch.map_[x+i+1][y+j+1]] = true;
}
}
for (int i = 0; i < adj.length; i++) {
// System.out.print(adj[i] + " ");
if (adj[i]) {
count++;
}
}
// System.out.println(count);
if (count > 3) {
// System.out.println("ERROR ERROR");
// witch.printMap();
return false;
}
}
}
return true;
}
public static int[][] regions = new int[10][2];
public static void main(String[] args) {
// ----------------------------------------------------------------------------------------------
// Map Generation
// ----------------------------------------------------------------------------------------------
// public int[][] regions = new int[20][2];
while (!checkRegions(regions) || !checkIntersections()) {
// System.out.println(checkRegions(regions));
witch.map = new int[witch.map.length][witch.map[0].length];
regions = new int[regions.length][regions[0].length];
for (int i = 0; i < regions.length; i++) {
int x = witch.rand.nextInt(witch.map.length);
int y = witch.rand.nextInt(witch.map[0].length);
regions[i][0] = x;
regions[i][1] = y;
witch.map_[x+1][y+1] = i;
}
// Put Regions Printed Here:
// TODO: FIX 2 cases of possible failure
// 1 circumcenter with no adjacent circumcenters
/*
* Fix: Find the largest angle between the 3 regions.
* Go from the circumcenter to the nearest edge in the opposite direction of that region.
* Then follow 1 adjacent circumcenter rules.
*/
/*
regions[0] = new int[] {18,31};
regions[1] = new int[] {15,29};
regions[2] = new int[] {9,1};
regions[3] = new int[] {10,31};
regions[4] = new int[] {9,27};
regions[5] = new int[] {14,11};
regions[6] = new int[] {23,32};
regions[7] = new int[] {20,26};
regions[8] = new int[] {13,6};
regions[9] = new int[] {24,20};
*/
// circumcenter on border line
// regions[0] = new int[] {21,44};
// regions[1] = new int[] {19,14};
// regions[2] = new int[] {19,38};
// regions[3] = new int[] {0,5};
// regions[4] = new int[] {1,17};
// regions[5] = new int[] {16,30};
// regions[6] = new int[] {22,32};
// regions[7] = new int[] {9,22};
// regions[8] = new int[] {1,34};
// regions[9] = new int[] {16,9};
// End Region Printed Out
for (int x = 0; x < witch.map_.length; x++) {
for (int y = 0; y < witch.map_[0].length; y++) {
double dMin = 99;
for (int r = 0; r < regions.length; r++) {
// System.out.println("X:" + r[0] + " Y:" + r[1]);
double d = Math.pow(Math.pow(regions[r][0] - x, 2) + Math.pow(regions[r][1] - y, 2), .5);
if (d < dMin) {
dMin = d;
witch.map_[x][y] = r;
}
}
}
}
}
// for (int r = 0; r < regions.length; r++) {
// System.out.println("regions[" + r + "] = new int[] {" + regions[r][0] + "," + regions[r][1] + "};");
// }
for (int x = 0; x < witch.map.length; x++) {
witch.map[x] = Arrays.copyOfRange(witch.map_[x+1], 1, witch.map[x].length+1);
// Arrays.asList(Arrays.copyOfRange(circPos,2,5))
// for (int y = 0; y < witch.map[x].length; y++) {
// witch.map[x][y] = witch.map_[x+1][y+1];
// }
}
// witch.printMap();
for (int x = 0; x < witch.map.length; x++) {
for (int y = 0; y < witch.map[0].length; y++) {
int dMin = 99;
for (int r = 0; r < regions.length; r++) {
// System.out.println("X:" + r[0] + " Y:" + r[1]);
int d = (int) Math.pow(Math.pow(regions[r][0] - x, 2) + Math.pow(regions[r][1] - y, 2), .5);
if (d < dMin) {
dMin = d;
witch.map[x][y] = r;
}
}
}
}
// Map Printing
if (showMap) {
JFrame frame = new JFrame("Map");
// Graphics shapesToDraw = new ArrayList<mapSections>();
frame.setSize(966, 589); // Check this out later
frame.setLocation(900,400);
MapSections draw = new MapSections(regions, Color.RED);
frame.add(draw);
frame.setVisible(true);
for (int x = 0; x < witch.map.length; x++) {
for (int y = 0; y < witch.map[0].length; y++) {
System.out.print(witch.map[x][y]);
}
System.out.println();
}
}
// ContinuousSpell testContSpell = new ContinuousSpell("contSpell");
// ----------------------------------------------------------------------------------------------
// Pre-Fighting Spell Selection
// ----------------------------------------------------------------------------------------------
Scanner scan = new Scanner(System.in);
// System.out.println("Spell Indexes: ");
// for (int i = 0; i < witch.spellIndex.size(); i++) {
// System.out.println((i < 9 ? "0" : "") + (i + 1) + "- " + witch.spellIndex.get(i).getName());
// }
// System.out.println();
System.out.println("\n\n\n");
// for (Spell s : witch.spellIndex) {
// witch.spellbook.add(s);
// }
witch.addSpell(0, 0);
witch.addSpell(0, 0);
witch.addSpell(1, 1);
// witch.addSpell(2,3);
// witch.addSpell(3,3);
// ----------------------------------------------------------------------------------------------
// Random Fighting Generator
// ----------------------------------------------------------------------------------------------
witch.addRandomEnemies();
// System.out.println(witch.enemies.get(0).getHealth());
// System.out.println(witch.enemies.get(1).getHealth());
witch.showHealth();
while (witch.game == 1) {
System.out.println("What do you do?");
String input = scan.nextLine();
Object in = getInput(input.replaceAll(" ", "").toLowerCase());
if (in != null) {
for (int i = 0; i < witch.enemies.size(); i++) {
Enemy e = witch.enemies.get(i);
boolean death = e.handleConditions();
if (death) {
e.deathMessage();
i--;
}
}
System.out.println();
// for (Enemy e: witch.enemies) {
// e.handleConditions();
// if (e.getHealth() < 1) {
// witch.score += e.getXP();
// witch.enemies.remove(e);
// }
// }
for (Enemy e : witch.enemies) {
e.attack();
}
System.out.println();
}
if (witch.enemies.isEmpty()) {
witch.adjustLevel();
witch.addSpell(0, (witch.level+1)/2);
witch.addRandomEnemies();
}
witch.showHealth();
if (witch.playerHealth < 1) {
witch.game = 0;
}
}
scan.close();
System.out.println("You lost! Your final score was: " + witch.score);
}
}
// DamageSpell spell = new DamageSpell("Spell", 0, 100, 1, 10, 0, false, 0, false, 1, 4);
//name
//speed
//accuracy
//numberDice
//numberSides
//damage
//secondaryDamage
//manaCost
//areaDamage
//numberHits
//damageType