cleaned up formatting:

- removed trailing whitespace
- changed all leading whitespace to tabs
- removed IDE created author comments
This commit is contained in:
Evan Debenham
2015-06-12 16:22:26 -04:00
parent baa83b7e43
commit cebdff0221
335 changed files with 8555 additions and 8714 deletions
@@ -50,7 +50,7 @@ public class Generator {
SCROLL ( 400, Scroll.class ),
WAND ( 40, Wand.class ),
RING ( 15, Ring.class ),
ARTIFACT( 15, Artifact.class),
ARTIFACT( 15, Artifact.class),
SEED ( 50, Plant.Seed.class ),
FOOD ( 0, Food.class ),
GOLD ( 500, Gold.class );
@@ -81,14 +81,14 @@ public class Generator {
static {
Category.GOLD.classes = new Class<?>[]{
Category.GOLD.classes = new Class<?>[]{
Gold.class };
Category.GOLD.probs = new float[]{ 1 };
Category.SCROLL.classes = new Class<?>[]{
ScrollOfIdentify.class,
ScrollOfTeleportation.class,
ScrollOfRemoveCurse.class,
Category.SCROLL.classes = new Class<?>[]{
ScrollOfIdentify.class,
ScrollOfTeleportation.class,
ScrollOfRemoveCurse.class,
ScrollOfUpgrade.class,
ScrollOfRecharging.class,
ScrollOfMagicMapping.class,
@@ -100,10 +100,10 @@ public class Generator {
ScrollOfMirrorImage.class };
Category.SCROLL.probs = new float[]{ 30, 10, 15, 0, 15, 15, 12, 8, 8, 0, 4, 10 };
Category.POTION.classes = new Class<?>[]{
PotionOfHealing.class,
Category.POTION.classes = new Class<?>[]{
PotionOfHealing.class,
PotionOfExperience.class,
PotionOfToxicGas.class,
PotionOfToxicGas.class,
PotionOfParalyticGas.class,
PotionOfLiquidFlame.class,
PotionOfLevitation.class,
@@ -132,16 +132,16 @@ public class Generator {
WandOfRegrowth.class };
Category.WAND.probs = new float[]{ 4, 4, 4, 4, 4, 3, /*3,*/ 3, 3, /*3,*/ 3, 3, 3 };
Category.WEAPON.classes = new Class<?>[]{
Dagger.class,
Category.WEAPON.classes = new Class<?>[]{
Dagger.class,
Knuckles.class,
Quarterstaff.class,
Spear.class,
Mace.class,
Sword.class,
Quarterstaff.class,
Spear.class,
Mace.class,
Sword.class,
Longsword.class,
BattleAxe.class,
WarHammer.class,
WarHammer.class,
Glaive.class,
ShortSword.class,
Dart.class,
@@ -153,52 +153,52 @@ public class Generator {
Tamahawk.class };
Category.WEAPON.probs = new float[]{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1 };
Category.ARMOR.classes = new Class<?>[]{
ClothArmor.class,
LeatherArmor.class,
MailArmor.class,
ScaleArmor.class,
Category.ARMOR.classes = new Class<?>[]{
ClothArmor.class,
LeatherArmor.class,
MailArmor.class,
ScaleArmor.class,
PlateArmor.class };
Category.ARMOR.probs = new float[]{ 1, 1, 1, 1, 1 };
Category.FOOD.classes = new Class<?>[]{
Food.class,
Category.FOOD.classes = new Class<?>[]{
Food.class,
Pasty.class,
MysteryMeat.class };
Category.FOOD.probs = new float[]{ 4, 1, 0 };
Category.RING.classes = new Class<?>[]{
RingOfAccuracy.class,
RingOfEvasion.class,
RingOfElements.class,
RingOfForce.class,
RingOfFuror.class,
RingOfHaste.class,
RingOfMagic.class, //currently removed from drop tables, pending rework
RingOfMight.class,
RingOfSharpshooting.class,
RingOfTenacity.class,
RingOfWealth.class};
RingOfAccuracy.class,
RingOfEvasion.class,
RingOfElements.class,
RingOfForce.class,
RingOfFuror.class,
RingOfHaste.class,
RingOfMagic.class, //currently removed from drop tables, pending rework
RingOfMight.class,
RingOfSharpshooting.class,
RingOfTenacity.class,
RingOfWealth.class};
Category.RING.probs = new float[]{ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 };
Category.ARTIFACT.classes = new Class<?>[]{
CapeOfThorns.class,
ChaliceOfBlood.class,
CloakOfShadows.class,
HornOfPlenty.class,
MasterThievesArmband.class,
SandalsOfNature.class,
TalismanOfForesight.class,
TimekeepersHourglass.class,
UnstableSpellbook.class,
AlchemistsToolkit.class, //currently removed from drop tables, pending rework.
DriedRose.class, //starts with no chance of spawning, chance is set directly after beating ghost quest.
LloydsBeacon.class,
EtherealChains.class
};
Category.ARTIFACT.probs = new float[]{ 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1};
Category.ARTIFACT.classes = new Class<?>[]{
CapeOfThorns.class,
ChaliceOfBlood.class,
CloakOfShadows.class,
HornOfPlenty.class,
MasterThievesArmband.class,
SandalsOfNature.class,
TalismanOfForesight.class,
TimekeepersHourglass.class,
UnstableSpellbook.class,
AlchemistsToolkit.class, //currently removed from drop tables, pending rework.
DriedRose.class, //starts with no chance of spawning, chance is set directly after beating ghost quest.
LloydsBeacon.class,
EtherealChains.class
};
Category.ARTIFACT.probs = new float[]{ 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1};
Category.SEED.classes = new Class<?>[]{
Category.SEED.classes = new Class<?>[]{
Firebloom.Seed.class,
Icecap.Seed.class,
Sorrowmoss.Seed.class,
@@ -206,10 +206,10 @@ public class Generator {
Sungrass.Seed.class,
Earthroot.Seed.class,
Fadeleaf.Seed.class,
Rotberry.Seed.class,
Rotberry.Seed.class,
BlandfruitBush.Seed.class,
Dreamfoil.Seed.class,
Stormvine.Seed.class,
Dreamfoil.Seed.class,
Stormvine.Seed.class,
Starflower.Seed.class};
Category.SEED.probs = new float[]{ 12, 12, 12, 12, 12, 12, 12, 0, 4, 12, 12, 1 };
}
@@ -234,10 +234,10 @@ public class Generator {
return randomArmor();
case WEAPON:
return randomWeapon();
case ARTIFACT:
Item item = randomArtifact();
//if we're out of artifacts, return a ring instead.
return item != null ? item : random(Category.RING);
case ARTIFACT:
Item item = randomArtifact();
//if we're out of artifacts, return a ring instead.
return item != null ? item : random(Category.RING);
default:
return ((Item)cat.classes[Random.chances( cat.probs )].newInstance()).random();
}
@@ -261,124 +261,124 @@ public class Generator {
}
}
public static Armor randomArmor(){
int curStr = Hero.STARTING_STR + Dungeon.limitedDrops.strengthPotions.count;
public static Armor randomArmor(){
int curStr = Hero.STARTING_STR + Dungeon.limitedDrops.strengthPotions.count;
return randomArmor(curStr);
}
return randomArmor(curStr);
}
public static Armor randomArmor(int targetStr) {
Category cat = Category.ARMOR;
try {
Armor a1 = (Armor) cat.classes[Random.chances(cat.probs)].newInstance();
Armor a2 = (Armor) cat.classes[Random.chances(cat.probs)].newInstance();
try {
Armor a1 = (Armor) cat.classes[Random.chances(cat.probs)].newInstance();
Armor a2 = (Armor) cat.classes[Random.chances(cat.probs)].newInstance();
a1.random();
a2.random();
a1.random();
a2.random();
return Math.abs(targetStr - a1.STR) < Math.abs(targetStr - a2.STR) ? a1 : a2;
} catch (Exception e) {
return null;
}
return Math.abs(targetStr - a1.STR) < Math.abs(targetStr - a2.STR) ? a1 : a2;
} catch (Exception e) {
return null;
}
}
public static Weapon randomWeapon(){
int curStr = Hero.STARTING_STR + Dungeon.limitedDrops.strengthPotions.count;
public static Weapon randomWeapon(){
int curStr = Hero.STARTING_STR + Dungeon.limitedDrops.strengthPotions.count;
return randomWeapon(curStr);
}
return randomWeapon(curStr);
}
public static Weapon randomWeapon(int targetStr) {
try {
Category cat = Category.WEAPON;
try {
Category cat = Category.WEAPON;
Weapon w1 = (Weapon)cat.classes[Random.chances( cat.probs )].newInstance();
Weapon w2 = (Weapon)cat.classes[Random.chances( cat.probs )].newInstance();
Weapon w1 = (Weapon)cat.classes[Random.chances( cat.probs )].newInstance();
Weapon w2 = (Weapon)cat.classes[Random.chances( cat.probs )].newInstance();
w1.random();
w2.random();
w1.random();
w2.random();
return Math.abs( targetStr - w1.STR ) < Math.abs( targetStr - w2.STR ) ? w1 : w2;
} catch (Exception e) {
return null;
}
return Math.abs( targetStr - w1.STR ) < Math.abs( targetStr - w2.STR ) ? w1 : w2;
} catch (Exception e) {
return null;
}
}
//enforces uniqueness of artifacts throughout a run.
public static Artifact randomArtifact() {
//enforces uniqueness of artifacts throughout a run.
public static Artifact randomArtifact() {
try {
Category cat = Category.ARTIFACT;
int i = Random.chances( cat.probs );
try {
Category cat = Category.ARTIFACT;
int i = Random.chances( cat.probs );
//if no artifacts are left, return null
if (i == -1){
return null;
}
//if no artifacts are left, return null
if (i == -1){
return null;
}
Artifact artifact = (Artifact)cat.classes[i].newInstance();
Artifact artifact = (Artifact)cat.classes[i].newInstance();
//remove the chance of spawning this artifact.
cat.probs[i] = 0;
spawnedArtifacts.add(cat.classes[i].getSimpleName());
//remove the chance of spawning this artifact.
cat.probs[i] = 0;
spawnedArtifacts.add(cat.classes[i].getSimpleName());
artifact.random();
artifact.random();
return artifact;
return artifact;
} catch (Exception e) {
return null;
}
}
} catch (Exception e) {
return null;
}
}
public static boolean removeArtifact(Artifact artifact) {
if (spawnedArtifacts.contains(artifact.getClass().getSimpleName()))
return false;
public static boolean removeArtifact(Artifact artifact) {
if (spawnedArtifacts.contains(artifact.getClass().getSimpleName()))
return false;
Category cat = Category.ARTIFACT;
for (int i = 0; i < cat.classes.length; i++)
if (cat.classes[i].equals(artifact.getClass())) {
if (cat.probs[i] == 1){
Category cat = Category.ARTIFACT;
for (int i = 0; i < cat.classes.length; i++)
if (cat.classes[i].equals(artifact.getClass())) {
if (cat.probs[i] == 1){
cat.probs[i] = 0;
spawnedArtifacts.add(artifact.getClass().getSimpleName());
return true;
} else
return false;
}
}
return false;
}
return false;
}
//resets artifact probabilities, for new dungeons
public static void initArtifacts() {
//FIXME: the duplicated logic here has caused 1 bug so far, should refactor.
Category.ARTIFACT.probs = new float[]{ 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1};
spawnedArtifacts = new ArrayList<String>();
}
//resets artifact probabilities, for new dungeons
public static void initArtifacts() {
//FIXME: the duplicated logic here has caused 1 bug so far, should refactor.
Category.ARTIFACT.probs = new float[]{ 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1};
spawnedArtifacts = new ArrayList<String>();
}
private static ArrayList<String> spawnedArtifacts = new ArrayList<String>();
private static ArrayList<String> spawnedArtifacts = new ArrayList<String>();
private static final String ARTIFACTS = "artifacts";
private static final String ARTIFACTS = "artifacts";
//used to store information on which artifacts have been spawned.
public static void storeInBundle(Bundle bundle) {
bundle.put( ARTIFACTS, spawnedArtifacts.toArray(new String[spawnedArtifacts.size()]));
}
//used to store information on which artifacts have been spawned.
public static void storeInBundle(Bundle bundle) {
bundle.put( ARTIFACTS, spawnedArtifacts.toArray(new String[spawnedArtifacts.size()]));
}
public static void restoreFromBundle(Bundle bundle) {
initArtifacts();
public static void restoreFromBundle(Bundle bundle) {
initArtifacts();
if (bundle.contains(ARTIFACTS)) {
Collections.addAll(spawnedArtifacts, bundle.getStringArray(ARTIFACTS));
Category cat = Category.ARTIFACT;
if (bundle.contains(ARTIFACTS)) {
Collections.addAll(spawnedArtifacts, bundle.getStringArray(ARTIFACTS));
Category cat = Category.ARTIFACT;
for (String artifact : spawnedArtifacts)
for (int i = 0; i < cat.classes.length; i++)
if (cat.classes[i].getSimpleName().equals(artifact))
cat.probs[i] = 0;
}
}
for (String artifact : spawnedArtifacts)
for (int i = 0; i < cat.classes.length; i++)
if (cat.classes[i].getSimpleName().equals(artifact))
cat.probs[i] = 0;
}
}
}