v1.1.0: item generator now uses 2x35 item decks, instead of 1x70
This commit is contained in:
parent
3a4ada7812
commit
4fd1fa6e54
|
@ -177,35 +177,35 @@ import java.util.LinkedHashMap;
|
||||||
public class Generator {
|
public class Generator {
|
||||||
|
|
||||||
public enum Category {
|
public enum Category {
|
||||||
WEAPON ( 4, MeleeWeapon.class),
|
WEAPON ( 2, 2, MeleeWeapon.class),
|
||||||
WEP_T1 ( 0, MeleeWeapon.class),
|
WEP_T1 ( 0, 0, MeleeWeapon.class),
|
||||||
WEP_T2 ( 0, MeleeWeapon.class),
|
WEP_T2 ( 0, 0, MeleeWeapon.class),
|
||||||
WEP_T3 ( 0, MeleeWeapon.class),
|
WEP_T3 ( 0, 0, MeleeWeapon.class),
|
||||||
WEP_T4 ( 0, MeleeWeapon.class),
|
WEP_T4 ( 0, 0, MeleeWeapon.class),
|
||||||
WEP_T5 ( 0, MeleeWeapon.class),
|
WEP_T5 ( 0, 0, MeleeWeapon.class),
|
||||||
|
|
||||||
ARMOR ( 3, Armor.class ),
|
ARMOR ( 2, 1, Armor.class ),
|
||||||
|
|
||||||
MISSILE ( 3, MissileWeapon.class ),
|
MISSILE ( 1, 2, MissileWeapon.class ),
|
||||||
MIS_T1 ( 0, MissileWeapon.class ),
|
MIS_T1 ( 0, 0, MissileWeapon.class ),
|
||||||
MIS_T2 ( 0, MissileWeapon.class ),
|
MIS_T2 ( 0, 0, MissileWeapon.class ),
|
||||||
MIS_T3 ( 0, MissileWeapon.class ),
|
MIS_T3 ( 0, 0, MissileWeapon.class ),
|
||||||
MIS_T4 ( 0, MissileWeapon.class ),
|
MIS_T4 ( 0, 0, MissileWeapon.class ),
|
||||||
MIS_T5 ( 0, MissileWeapon.class ),
|
MIS_T5 ( 0, 0, MissileWeapon.class ),
|
||||||
|
|
||||||
WAND ( 2, Wand.class ),
|
WAND ( 1, 1, Wand.class ),
|
||||||
RING ( 1, Ring.class ),
|
RING ( 1, 0, Ring.class ),
|
||||||
ARTIFACT( 1, Artifact.class),
|
ARTIFACT( 0, 1, Artifact.class),
|
||||||
|
|
||||||
FOOD ( 0, Food.class ),
|
FOOD ( 0, 0, Food.class ),
|
||||||
|
|
||||||
POTION ( 16, Potion.class ),
|
POTION ( 8, 8, Potion.class ),
|
||||||
SEED ( 2, Plant.Seed.class ),
|
SEED ( 1, 1, Plant.Seed.class ),
|
||||||
|
|
||||||
SCROLL ( 16, Scroll.class ),
|
SCROLL ( 8, 8, Scroll.class ),
|
||||||
STONE ( 2, Runestone.class),
|
STONE ( 1, 1, Runestone.class),
|
||||||
|
|
||||||
GOLD ( 20, Gold.class );
|
GOLD ( 10, 10, Gold.class );
|
||||||
|
|
||||||
public Class<?>[] classes;
|
public Class<?>[] classes;
|
||||||
|
|
||||||
|
@ -215,12 +215,16 @@ public class Generator {
|
||||||
//Artifacts in particular don't reset, no duplicates!
|
//Artifacts in particular don't reset, no duplicates!
|
||||||
public float[] probs;
|
public float[] probs;
|
||||||
public float[] defaultProbs = null;
|
public float[] defaultProbs = null;
|
||||||
|
|
||||||
public float prob;
|
//game has two decks of 35 items for overall category probs
|
||||||
|
//one deck has a ring and extra armor, the other has an artifact and extra thrown weapon
|
||||||
|
public float firstProb;
|
||||||
|
public float secondProb;
|
||||||
public Class<? extends Item> superClass;
|
public Class<? extends Item> superClass;
|
||||||
|
|
||||||
private Category( float prob, Class<? extends Item> superClass ) {
|
private Category( float firstProb, float secondProb, Class<? extends Item> superClass ) {
|
||||||
this.prob = prob;
|
this.firstProb = firstProb;
|
||||||
|
this.secondProb = secondProb;
|
||||||
this.superClass = superClass;
|
this.superClass = superClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,10 +471,12 @@ public class Generator {
|
||||||
{0, 0, 20, 40, 40},
|
{0, 0, 20, 40, 40},
|
||||||
{0, 0, 0, 20, 80}
|
{0, 0, 0, 20, 80}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static boolean usingFirstDeck = false;
|
||||||
private static HashMap<Category,Float> categoryProbs = new LinkedHashMap<>();
|
private static HashMap<Category,Float> categoryProbs = new LinkedHashMap<>();
|
||||||
|
|
||||||
public static void fullReset() {
|
public static void fullReset() {
|
||||||
|
usingFirstDeck = Random.Int(2) == 0;
|
||||||
generalReset();
|
generalReset();
|
||||||
for (Category cat : Category.values()) {
|
for (Category cat : Category.values()) {
|
||||||
reset(cat);
|
reset(cat);
|
||||||
|
@ -479,7 +485,7 @@ public class Generator {
|
||||||
|
|
||||||
public static void generalReset(){
|
public static void generalReset(){
|
||||||
for (Category cat : Category.values()) {
|
for (Category cat : Category.values()) {
|
||||||
categoryProbs.put( cat, cat.prob );
|
categoryProbs.put( cat, usingFirstDeck ? cat.firstProb : cat.secondProb );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,6 +496,7 @@ public class Generator {
|
||||||
public static Item random() {
|
public static Item random() {
|
||||||
Category cat = Random.chances( categoryProbs );
|
Category cat = Random.chances( categoryProbs );
|
||||||
if (cat == null){
|
if (cat == null){
|
||||||
|
usingFirstDeck = !usingFirstDeck;
|
||||||
generalReset();
|
generalReset();
|
||||||
cat = Random.chances( categoryProbs );
|
cat = Random.chances( categoryProbs );
|
||||||
}
|
}
|
||||||
|
@ -617,10 +624,13 @@ public class Generator {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String FIRST_DECK = "first_deck";
|
||||||
private static final String GENERAL_PROBS = "general_probs";
|
private static final String GENERAL_PROBS = "general_probs";
|
||||||
private static final String CATEGORY_PROBS = "_probs";
|
private static final String CATEGORY_PROBS = "_probs";
|
||||||
|
|
||||||
public static void storeInBundle(Bundle bundle) {
|
public static void storeInBundle(Bundle bundle) {
|
||||||
|
bundle.put(FIRST_DECK, usingFirstDeck);
|
||||||
|
|
||||||
Float[] genProbs = categoryProbs.values().toArray(new Float[0]);
|
Float[] genProbs = categoryProbs.values().toArray(new Float[0]);
|
||||||
float[] storeProbs = new float[genProbs.length];
|
float[] storeProbs = new float[genProbs.length];
|
||||||
for (int i = 0; i < storeProbs.length; i++){
|
for (int i = 0; i < storeProbs.length; i++){
|
||||||
|
@ -647,6 +657,8 @@ public class Generator {
|
||||||
public static void restoreFromBundle(Bundle bundle) {
|
public static void restoreFromBundle(Bundle bundle) {
|
||||||
fullReset();
|
fullReset();
|
||||||
|
|
||||||
|
usingFirstDeck = bundle.getBoolean(FIRST_DECK);
|
||||||
|
|
||||||
if (bundle.contains(GENERAL_PROBS)){
|
if (bundle.contains(GENERAL_PROBS)){
|
||||||
float[] probs = bundle.getFloatArray(GENERAL_PROBS);
|
float[] probs = bundle.getFloatArray(GENERAL_PROBS);
|
||||||
for (int i = 0; i < probs.length; i++){
|
for (int i = 0; i < probs.length; i++){
|
||||||
|
|
Loading…
Reference in New Issue
Block a user