v1.1.0: improved the distribution of special rooms, & items from armorys

This commit is contained in:
Evan Debenham 2021-09-13 22:38:23 -04:00
parent 4fd1fa6e54
commit 5d53ac5944
2 changed files with 41 additions and 20 deletions

View File

@ -55,6 +55,7 @@ public class ArmoryRoom extends SpecialRoom {
}
int n = Random.IntRange( 2, 3 );
prizeCats = new float[]{1,1,1,1};
for (int i=0; i < n; i++) {
int pos;
do {
@ -67,8 +68,12 @@ public class ArmoryRoom extends SpecialRoom {
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
}
//only a max of 1 prize from each category can be dropped at a time
private static float[] prizeCats;
private static Item prize( Level level ) {
switch (Random.Int( 4 )){
int index = Random.chances(prizeCats);
prizeCats[index] = 0;
switch (index){
case 0:
return new Bomb().random();
case 1:

View File

@ -79,9 +79,15 @@ public abstract class SpecialRoom extends Room {
}
}
private static final ArrayList<Class<? extends SpecialRoom>> ALL_SPEC = new ArrayList<>( Arrays.asList(
WeakFloorRoom.class, MagicWellRoom.class, CryptRoom.class, PoolRoom.class, GardenRoom.class, LibraryRoom.class, ArmoryRoom.class,
TreasuryRoom.class, TrapsRoom.class, StorageRoom.class, StatueRoom.class, VaultRoom.class, RunestoneRoom.class
//special rooms which give an equipment reward
private static final ArrayList<Class<? extends SpecialRoom>> EQUIP_SPECIALS = new ArrayList<>( Arrays.asList(
ArmoryRoom.class, ArmoryRoom.class, ArmoryRoom.class, ArmoryRoom.class, ArmoryRoom.class, ArmoryRoom.class, ArmoryRoom.class
));
//special rooms which give a consumable reward
//note that alchemy rooms are spawned separately
private static final ArrayList<Class<? extends SpecialRoom>> CONSUMABLES_SPECIALS = new ArrayList<>( Arrays.asList(
RunestoneRoom.class, GardenRoom.class, LibraryRoom.class, StorageRoom.class, TreasuryRoom.class, MagicWellRoom.class
) );
public static ArrayList<Class<? extends Room>> runSpecials = new ArrayList<>();
@ -90,10 +96,25 @@ public abstract class SpecialRoom extends Room {
private static int pitNeededDepth = -1;
public static void initForRun() {
runSpecials = (ArrayList<Class<?extends Room>>)ALL_SPEC.clone();
runSpecials = new ArrayList<>();
ArrayList<Class<?extends Room>> runEquipSpecials = (ArrayList<Class<?extends Room>>)EQUIP_SPECIALS.clone();
ArrayList<Class<?extends Room>> runConsSpecials = (ArrayList<Class<?extends Room>>)CONSUMABLES_SPECIALS.clone();
Random.shuffle(runEquipSpecials);
Random.shuffle(runConsSpecials);
// TODO currently always an equip special first as there's 1 more of them, adjust as needed if adding more
/*if (Random.Int(2) == 0){
runSpecials.add(runConsSpecials.remove(0));
}*/
while (!runEquipSpecials.isEmpty() || !runConsSpecials.isEmpty()){
if (!runEquipSpecials.isEmpty()) runSpecials.add(runEquipSpecials.remove(0));
if (!runConsSpecials.isEmpty()) runSpecials.add(runConsSpecials.remove(0));
}
pitNeededDepth = -1;
Random.shuffle(runSpecials);
}
public static void initForFloor(){
@ -142,14 +163,9 @@ public abstract class SpecialRoom extends Room {
floorSpecials.remove(WeakFloorRoom.class);
}
Room r = null;
int index = floorSpecials.size();
for (int i = 0; i < 4; i++){
int newidx = Random.Int( floorSpecials.size() );
if (newidx < index) index = newidx;
}
r = Reflection.newInstance(floorSpecials.get( index ));
//60% chance for front of queue, 30% chance for next, 10% for one after that
int index = Random.chances(new float[]{6, 3, 1});
Room r = Reflection.newInstance(floorSpecials.get( index ));
if (r instanceof WeakFloorRoom){
pitNeededDepth = Dungeon.depth + 1;