V0.2.1: Updated generator exception handling to always be internal.
This commit is contained in:
parent
960f39b56b
commit
ba8d158ba7
|
@ -243,33 +243,38 @@ public class Generator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Armor randomArmor() throws Exception {
|
public static Armor randomArmor(){
|
||||||
int curStr = Hero.STARTING_STR + Dungeon.potionOfStrength;
|
int curStr = Hero.STARTING_STR + Dungeon.potionOfStrength;
|
||||||
|
|
||||||
return randomArmor(curStr);
|
return randomArmor(curStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Armor randomArmor(int targetStr) throws Exception {
|
public static Armor randomArmor(int targetStr) {
|
||||||
|
|
||||||
Category cat = Category.ARMOR;
|
Category cat = Category.ARMOR;
|
||||||
|
|
||||||
Armor a1 = (Armor)cat.classes[Random.chances( cat.probs )].newInstance();
|
try {
|
||||||
Armor a2 = (Armor)cat.classes[Random.chances( cat.probs )].newInstance();
|
Armor a1 = (Armor) cat.classes[Random.chances(cat.probs)].newInstance();
|
||||||
|
Armor a2 = (Armor) cat.classes[Random.chances(cat.probs)].newInstance();
|
||||||
|
|
||||||
a1.random();
|
a1.random();
|
||||||
a2.random();
|
a2.random();
|
||||||
|
|
||||||
return Math.abs( targetStr - a1.STR ) < Math.abs( targetStr - a2.STR ) ? a1 : a2;
|
return Math.abs(targetStr - a1.STR) < Math.abs(targetStr - a2.STR) ? a1 : a2;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Weapon randomWeapon() throws Exception {
|
public static Weapon randomWeapon(){
|
||||||
int curStr = Hero.STARTING_STR + Dungeon.potionOfStrength;
|
int curStr = Hero.STARTING_STR + Dungeon.potionOfStrength;
|
||||||
|
|
||||||
return randomWeapon(curStr);
|
return randomWeapon(curStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Weapon randomWeapon(int targetStr) throws Exception {
|
public static Weapon randomWeapon(int targetStr) {
|
||||||
|
|
||||||
|
try {
|
||||||
Category cat = Category.WEAPON;
|
Category cat = Category.WEAPON;
|
||||||
|
|
||||||
Weapon w1 = (Weapon)cat.classes[Random.chances( cat.probs )].newInstance();
|
Weapon w1 = (Weapon)cat.classes[Random.chances( cat.probs )].newInstance();
|
||||||
|
@ -279,5 +284,8 @@ public class Generator {
|
||||||
w2.random();
|
w2.random();
|
||||||
|
|
||||||
return Math.abs( targetStr - w1.STR ) < Math.abs( targetStr - w2.STR ) ? w1 : w2;
|
return Math.abs( targetStr - w1.STR ) < Math.abs( targetStr - w2.STR ) ? w1 : w2;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user