v2.4.0: fixed very rare cases of hourglass affecting levelgen
This commit is contained in:
+1
-1
@@ -366,7 +366,7 @@ public class CityBossLevel extends Level {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void spawnShop(){
|
private void spawnShop(){
|
||||||
while (impShop.itemCount() >= 7*(impShop.height()-2)){
|
while (impShop.spacesNeeded() >= 7*(impShop.height()-2)){
|
||||||
impShop.bottom++;
|
impShop.bottom++;
|
||||||
}
|
}
|
||||||
impShop.spawnShop(this);
|
impShop.spawnShop(this);
|
||||||
|
|||||||
+18
-4
@@ -68,17 +68,31 @@ public class ShopRoom extends SpecialRoom {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int minWidth() {
|
public int minWidth() {
|
||||||
return Math.max(7, (int)(Math.sqrt(itemCount())+3));
|
return Math.max(7, (int)(Math.sqrt(spacesNeeded())+3));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int minHeight() {
|
public int minHeight() {
|
||||||
return Math.max(7, (int)(Math.sqrt(itemCount())+3));
|
return Math.max(7, (int)(Math.sqrt(spacesNeeded())+3));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int itemCount(){
|
public int spacesNeeded(){
|
||||||
if (itemsToSpawn == null) itemsToSpawn = generateItems();
|
if (itemsToSpawn == null) itemsToSpawn = generateItems();
|
||||||
return itemsToSpawn.size();
|
|
||||||
|
//sandbags spawn based on current level of an hourglass the player may be holding
|
||||||
|
// so, to avoid rare cases of min sizes differing based on that, we ignore all sandbags
|
||||||
|
// and then add 4 items in all cases, which is max number of sandbags that can be in the shop
|
||||||
|
int spacesNeeded = itemsToSpawn.size();
|
||||||
|
for (Item i : itemsToSpawn){
|
||||||
|
if (i instanceof TimekeepersHourglass.sandBag){
|
||||||
|
spacesNeeded--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spacesNeeded += 4;
|
||||||
|
|
||||||
|
//we also add 1 more space, for the shopkeeper
|
||||||
|
spacesNeeded++;
|
||||||
|
return spacesNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paint( Level level ) {
|
public void paint( Level level ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user