Upload files to "WitchGame"
This commit is contained in:
commit
26d2e105b7
32
WitchGame/AttackType.java
Normal file
32
WitchGame/AttackType.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package witchGame;
|
||||||
|
|
||||||
|
public enum AttackType {
|
||||||
|
StrengthSave,
|
||||||
|
DexteritySave,
|
||||||
|
ConstitutionSave,
|
||||||
|
IntelligenceSave,
|
||||||
|
WisdomSave,
|
||||||
|
CharismaSave,
|
||||||
|
|
||||||
|
MeleeSpellAttack,
|
||||||
|
RangedSpellAttack,
|
||||||
|
|
||||||
|
MeleeWeaponAttack,
|
||||||
|
RangedWeaponAttack,
|
||||||
|
|
||||||
|
AutoHit,
|
||||||
|
AutoMiss,
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String name = name();
|
||||||
|
for (int c = 1; c < name.length(); c++) {
|
||||||
|
if (Character.isUpperCase(name.charAt(c))) {
|
||||||
|
name = name.substring(0,c)+ " " + name.substring(c++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
111
WitchGame/Condition.java
Normal file
111
WitchGame/Condition.java
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package witchGame;
|
||||||
|
|
||||||
|
public class Condition implements Cloneable {
|
||||||
|
private ConditionType conditionType;
|
||||||
|
private int nTurns;
|
||||||
|
private DamageType damageType;
|
||||||
|
private int savingThrow;
|
||||||
|
private int saveDC;
|
||||||
|
private int amount;
|
||||||
|
private int num = 0;
|
||||||
|
private int of = 1;
|
||||||
|
|
||||||
|
public Condition(ConditionType conditionType, int nTurns, DamageType damageType, int num, int of) {
|
||||||
|
super();
|
||||||
|
this.conditionType = conditionType;
|
||||||
|
this.nTurns = nTurns;
|
||||||
|
this.damageType = damageType;
|
||||||
|
this.savingThrow = 0;
|
||||||
|
this.num = num;
|
||||||
|
this.of = of;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Condition(ConditionType conditionType, int nTurns) {
|
||||||
|
super();
|
||||||
|
this.conditionType = conditionType;
|
||||||
|
this.nTurns = nTurns;
|
||||||
|
this.damageType = DamageType.None;
|
||||||
|
this.num = 0;
|
||||||
|
this.of = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Condition(ConditionType conditionType, int nTurns, int amount) {
|
||||||
|
super();
|
||||||
|
this.conditionType = conditionType;
|
||||||
|
this.nTurns = nTurns;
|
||||||
|
this.damageType = DamageType.None;
|
||||||
|
this.savingThrow = 0;
|
||||||
|
this.saveDC = 0;
|
||||||
|
this.setAmount(amount);
|
||||||
|
this.num = 0;
|
||||||
|
this.of = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Condition(ConditionType conditionType, int nTurns, int savingThrow, int saveDC) {
|
||||||
|
super();
|
||||||
|
this.conditionType = conditionType;
|
||||||
|
this.nTurns = nTurns;
|
||||||
|
this.damageType = DamageType.None;
|
||||||
|
this.savingThrow = savingThrow;
|
||||||
|
this.saveDC = saveDC;
|
||||||
|
this.num = 0;
|
||||||
|
this.of = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConditionType getConditionType() {
|
||||||
|
return conditionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConditionType(ConditionType conditionType) {
|
||||||
|
this.conditionType = conditionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getnTurns() {
|
||||||
|
return nTurns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setnTurns(int nTurns) {
|
||||||
|
this.nTurns = nTurns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DamageType getDamageType() {
|
||||||
|
return damageType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNum() {
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOf() {
|
||||||
|
return of;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSavingThrow() {
|
||||||
|
return savingThrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDC() {
|
||||||
|
return saveDC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(int amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object clone() {
|
||||||
|
return new Condition(this.conditionType, this.nTurns, this.damageType, this.num, this.of);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Condition [conditionType=" + conditionType + ", nTurns=" + nTurns + ", damageType=" + damageType
|
||||||
|
+ ", savingThrow=" + savingThrow + ", saveDC=" + saveDC + ", num=" + num + ", of=" + of + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
46
WitchGame/ConditionType.java
Normal file
46
WitchGame/ConditionType.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package witchGame;
|
||||||
|
|
||||||
|
public enum ConditionType {
|
||||||
|
DamagePerRound,
|
||||||
|
|
||||||
|
Blinded,
|
||||||
|
Charmed,
|
||||||
|
Deafened,
|
||||||
|
Frightened,
|
||||||
|
Grappled,
|
||||||
|
Incapacitated,
|
||||||
|
Invisible,
|
||||||
|
Paralyzed,
|
||||||
|
Petrified,
|
||||||
|
Poisoned,
|
||||||
|
Prone,
|
||||||
|
Restrained,
|
||||||
|
Stunned,
|
||||||
|
Unconscious,
|
||||||
|
Exhausted1,
|
||||||
|
Exhausted2,
|
||||||
|
Exhausted3,
|
||||||
|
Exhausted4,
|
||||||
|
Exhausted5,
|
||||||
|
|
||||||
|
CantHeal,
|
||||||
|
CantAttack,
|
||||||
|
CantUseItems,
|
||||||
|
CantTakeReactions,
|
||||||
|
|
||||||
|
AdvantageOnAttacks,
|
||||||
|
DisadvantageOnAttacks,
|
||||||
|
AttackersGainAdvantage,
|
||||||
|
AttackersGainDisadvantage,
|
||||||
|
AttackersTakeDamage,
|
||||||
|
|
||||||
|
ModifierOnAttacks,
|
||||||
|
ModifierOnDamage,
|
||||||
|
ModifierOnAC,
|
||||||
|
|
||||||
|
CantPursue,
|
||||||
|
Light,
|
||||||
|
|
||||||
|
PackTactics,
|
||||||
|
Lifesteal,
|
||||||
|
}
|
||||||
32
WitchGame/ContinuousSpell.java
Normal file
32
WitchGame/ContinuousSpell.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package witchGame;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class ContinuousSpell extends Spell {
|
||||||
|
|
||||||
|
private int accuracy = 100;
|
||||||
|
private int numberDice = 1;
|
||||||
|
private int numberSides = 6;
|
||||||
|
private int damage = 0;
|
||||||
|
private boolean areaDamage = false;
|
||||||
|
private int manaCost = 0;
|
||||||
|
private boolean secondaryDamage = false;
|
||||||
|
private int numberHits = 1;
|
||||||
|
private int damageType = 4;
|
||||||
|
|
||||||
|
public ContinuousSpell(String name) {
|
||||||
|
super(name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContinuousSpell() {
|
||||||
|
super("new Name");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int cast() {
|
||||||
|
System.out.println("Spell Cast!");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
253
WitchGame/DamageSpell.java
Normal file
253
WitchGame/DamageSpell.java
Normal file
@ -0,0 +1,253 @@
|
|||||||
|
package witchGame;
|
||||||
|
|
||||||
|
//import java.sql.Array;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
//import java.util.Arrays;
|
||||||
|
//import java.util.Random;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
//@SuppressWarnings("unused")
|
||||||
|
public class DamageSpell extends Spell {
|
||||||
|
// Random rand = new Random();
|
||||||
|
|
||||||
|
// public int witchRunner.playerMana = 100;
|
||||||
|
|
||||||
|
// private int accuracy = 20;
|
||||||
|
private AttackType attackType = AttackType.RangedSpellAttack;
|
||||||
|
private int numberDice = 1;
|
||||||
|
private int numberSides = 6;
|
||||||
|
private int damage = 0;
|
||||||
|
private boolean areaDamage = false; //TODO: Change to # of surrounding enemies
|
||||||
|
private int manaCost = 0;
|
||||||
|
private boolean secondaryDamage = false;
|
||||||
|
private int numberHits = 1;
|
||||||
|
private DamageType damageType = DamageType.Force;
|
||||||
|
private Condition appliedCondition;
|
||||||
|
|
||||||
|
public static int[] hitNumber = new int[5];
|
||||||
|
public static ArrayList<Integer> targets = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
public DamageSpell(String name, AttackType attackType, int numberDice, int numberSides, int damage, boolean areaDamage, int manaCost, boolean secondaryDamage, int numberHits, DamageType damageType, Condition appliedCondition) {
|
||||||
|
super(name);
|
||||||
|
this.attackType = attackType;
|
||||||
|
this.numberDice = numberDice;
|
||||||
|
this.numberSides = numberSides;
|
||||||
|
this.damage = damage;
|
||||||
|
this.areaDamage = areaDamage;
|
||||||
|
this.manaCost = manaCost;
|
||||||
|
this.secondaryDamage = secondaryDamage;
|
||||||
|
this.numberHits = numberHits;
|
||||||
|
this.damageType = damageType;
|
||||||
|
this.appliedCondition = appliedCondition;
|
||||||
|
}
|
||||||
|
|
||||||
|
Scanner scan = new Scanner(System.in);
|
||||||
|
public int cast() {
|
||||||
|
if (witch.playerMana >= manaCost) {
|
||||||
|
witch.playerMana -= manaCost;
|
||||||
|
// witchRunner.setMana(witchRunner.playerMana-manaCost);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
targets.clear();
|
||||||
|
// System.out.println(targets.size());
|
||||||
|
if (!areaDamage) { // Not area damage
|
||||||
|
if (witch.enemies.size() > 1) { // Multiple possible targets
|
||||||
|
while (targets.size() < numberHits) {
|
||||||
|
if (numberHits > 1)
|
||||||
|
System.out.println("Target #" + (targets.size()+1) + ": ");
|
||||||
|
else
|
||||||
|
System.out.println("Target: ");
|
||||||
|
selectEnemy(scan.nextLine());
|
||||||
|
}
|
||||||
|
} else if (witch.enemies.size() == 1) { // Only one viable target
|
||||||
|
while (targets.size() < numberHits) {
|
||||||
|
targets.add(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < witch.enemies.size(); i++) {
|
||||||
|
targets.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("You cast " + name + "!\n");
|
||||||
|
hitNumber = new int[5];
|
||||||
|
for (int t: targets) {
|
||||||
|
if (determineHit(t)) {
|
||||||
|
hitNumber[t] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int t = 0; t < hitNumber.length; t++) {
|
||||||
|
if (hitNumber[t] != 0) {
|
||||||
|
Enemy target = witch.enemies.get(t);
|
||||||
|
int hitDamage = dice((numberDice * hitNumber[t]), numberSides) + (damage * hitNumber[t]);
|
||||||
|
|
||||||
|
System.out.println("You hit the " + witch.enemies.get(t).getName() + (numberHits > 1 ? (" " + hitNumber[t]) + " time" + (hitNumber[t] != 1 ? "s" : "") : "") + " for " + hitDamage + " " + damageType.toString() + " damage.");
|
||||||
|
|
||||||
|
target.dealDamage(hitDamage, damageType);
|
||||||
|
if (appliedCondition != null) {
|
||||||
|
target.addCondition(appliedCondition);
|
||||||
|
}
|
||||||
|
} else if (targets.contains(t)) {
|
||||||
|
if (secondaryDamage) {
|
||||||
|
System.out.print("You glanced the " + witch.enemies.get(t).getName());
|
||||||
|
Enemy target = witch.enemies.get(t);
|
||||||
|
int hitDamage = (dice((numberDice * numberHits), numberSides) + (damage * hitNumber[t]) + 1) / 2;
|
||||||
|
System.out.println(" for " + hitDamage + " " + damageType.toString() + " damage.");
|
||||||
|
target.dealDamage(hitDamage, damageType);
|
||||||
|
} else {
|
||||||
|
if (attackType.compareTo(AttackType.MeleeSpellAttack) == 0 || attackType.compareTo(AttackType.RangedSpellAttack) == 0) {
|
||||||
|
if (targets.indexOf(t) == targets.lastIndexOf(t)) {
|
||||||
|
System.out.println("You missed the " + witch.enemies.get(t).getName() + ".");
|
||||||
|
} else {
|
||||||
|
System.out.println("You missed every strike at the " + witch.enemies.get(t).getName() + ".");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
System.out.println("You don't have enough mana. \nCasting " + name.toLowerCase() + " costs " + manaCost + " mana. You have " + witch.playerMana + " mana.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
for (int e = 0; e < witch.enemies.size(); e++) {
|
||||||
|
if (witch.enemies.get(e).getHealth() < 1) {
|
||||||
|
witch.removeEnemy(witch.enemies.get(e));
|
||||||
|
e--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("\nYou " + (manaCost != 0 ? "now " : "") + "have " + witch.playerMana + " mana."); //TODO: Check this message and the no mana message
|
||||||
|
|
||||||
|
|
||||||
|
// for (Enemy e : witch.enemies) {
|
||||||
|
// if (e.getHealth() < 1) {
|
||||||
|
// witch.score += e.getXP();
|
||||||
|
// System.out.println(witch.enemies.indexOf(e));
|
||||||
|
// witch.enemies.remove(witch.enemies.indexOf(e));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
return 1;
|
||||||
|
// return witch.spellIndex(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// witch.enemies.get(t).getName()
|
||||||
|
public static void selectEnemy(String input) {
|
||||||
|
for (Enemy k: witch.enemies) {
|
||||||
|
if ((input.replaceAll("[^A-z]", "")).compareToIgnoreCase(k.getName().replaceAll(" ", "")) == 0) {
|
||||||
|
targets.add(witch.enemies.indexOf(k));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Integer.parseInt("0" + input.replaceAll("[^0-9]", "")) > 0 && Integer.parseInt("0" + input.replaceAll("[^0-9]", "")) <= witch.enemies.size()) {
|
||||||
|
targets.add(Integer.parseInt("0" + input.replaceAll("[^0-9]", "")) - 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean determineHit(int target) {
|
||||||
|
|
||||||
|
switch (this.attackType) {
|
||||||
|
case MeleeSpellAttack:
|
||||||
|
case RangedSpellAttack:
|
||||||
|
int acc1 = rand.nextInt(20)+1;
|
||||||
|
return (witch.enemies.get(target).getAC() <= acc1);
|
||||||
|
case MeleeWeaponAttack:
|
||||||
|
case RangedWeaponAttack:
|
||||||
|
int acc2 = rand.nextInt(20)+1;
|
||||||
|
return (witch.enemies.get(target).getAC() <= acc2);
|
||||||
|
|
||||||
|
case StrengthSave:
|
||||||
|
int strCheck = rand.nextInt(20)+1;
|
||||||
|
return (strCheck + witch.enemies.get(target).getStrength() < witch.saveDC);
|
||||||
|
|
||||||
|
case DexteritySave:
|
||||||
|
int dexCheck = rand.nextInt(20)+1;
|
||||||
|
return (dexCheck + witch.enemies.get(target).getDexterity() < witch.saveDC);
|
||||||
|
|
||||||
|
case ConstitutionSave:
|
||||||
|
int conCheck = rand.nextInt(20)+1;
|
||||||
|
return (conCheck + witch.enemies.get(target).getConstitution() < witch.saveDC);
|
||||||
|
|
||||||
|
case IntelligenceSave:
|
||||||
|
int intCheck = rand.nextInt(20)+1;
|
||||||
|
return (intCheck + witch.enemies.get(target).getIntelligence() < witch.saveDC);
|
||||||
|
|
||||||
|
case WisdomSave:
|
||||||
|
int wisCheck = rand.nextInt(20)+1;
|
||||||
|
return (wisCheck + witch.enemies.get(target).getWisdom() < witch.saveDC);
|
||||||
|
|
||||||
|
case CharismaSave:
|
||||||
|
int chaCheck = rand.nextInt(20)+1;
|
||||||
|
return (chaCheck + witch.enemies.get(target).getCharisma() < witch.saveDC);
|
||||||
|
|
||||||
|
|
||||||
|
case AutoHit:
|
||||||
|
return true;
|
||||||
|
case AutoMiss:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AttackType getAttackType() {
|
||||||
|
return attackType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumberDice() {
|
||||||
|
return numberDice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumberSides() {
|
||||||
|
return numberSides;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDamage() {
|
||||||
|
return damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAreaDamage() {
|
||||||
|
return areaDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getManaCost() {
|
||||||
|
return manaCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSecondaryDamage() {
|
||||||
|
return secondaryDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumberHits() {
|
||||||
|
return numberHits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DamageType getDamageType() {
|
||||||
|
return damageType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DamageSpell() {
|
||||||
|
super("spell");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name + "\nDamage Spell" + "\nMana Cost = " + manaCost + "\nAttack Type = " + attackType.toString() + (numberHits > 1 ? ("\nNumber of Attacks = " + numberHits) : "")+ "\nDeals " + numberDice + "d" + numberSides
|
||||||
|
+ (damage > 0 ? (" + " + damage) : "") + " " + damageType.toString() + " damage" + (areaDamage ? "\nDeals Area Damage" : "") + (secondaryDamage ? "\nDeals Half Damage on a Successful Save" : "") + (appliedCondition!=null ? "\nApplies Condition: " + appliedCondition.toString() : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user