diff --git a/SPD-classes/src/main/java/com/watabou/utils/Rect.java b/SPD-classes/src/main/java/com/watabou/utils/Rect.java
index ce789296c..edd5d2ad2 100644
--- a/SPD-classes/src/main/java/com/watabou/utils/Rect.java
+++ b/SPD-classes/src/main/java/com/watabou/utils/Rect.java
@@ -54,7 +54,7 @@ public class Rect {
}
public int square() {
- return (right - left) * (bottom - top);
+ return width() * height();
}
public Rect set( int left, int top, int right, int bottom ) {
@@ -69,6 +69,18 @@ public class Rect {
return set( rect.left, rect.top, rect.right, rect.bottom );
}
+ public Rect setPos( int x, int y ) {
+ return set( x, y, x + (right - left), y + (bottom - top));
+ }
+
+ public Rect shift( int x, int y ) {
+ return set( left+x, top+y, right+x, bottom+y );
+ }
+
+ public Rect resize( int w, int h ){
+ return set( left, top, left+w, top+h);
+ }
+
public boolean isEmpty() {
return right <= left || bottom <= top;
}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/Builder.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/Builder.java
index 13ad59fcc..91fa7bd53 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/Builder.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/Builder.java
@@ -1,3 +1,24 @@
+/*
+ * Pixel Dungeon
+ * Copyright (C) 2012-2015 Oleg Dolya
+ *
+ * Shattered Pixel Dungeon
+ * Copyright (C) 2014-2017 Evan Debenham
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ */
+
package com.shatteredpixel.shatteredpixeldungeon.levels.builders;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LegacyBuilder.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LegacyBuilder.java
index 4ff363d0f..31a5a5465 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LegacyBuilder.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LegacyBuilder.java
@@ -1,3 +1,24 @@
+/*
+ * Pixel Dungeon
+ * Copyright (C) 2012-2015 Oleg Dolya
+ *
+ * Shattered Pixel Dungeon
+ * Copyright (C) 2014-2017 Evan Debenham
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ */
+
package com.shatteredpixel.shatteredpixeldungeon.levels.builders;
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
@@ -240,7 +261,7 @@ public class LegacyBuilder extends Builder {
} while (!(curRoom.getClass().equals(Room.class)) || distance != 3 || curRoom.neigbours.contains(roomEntrance));
temp = curRoom;
- curRoom = new StandardRoom().set(temp);
+ curRoom = StandardRoom.createRoom().set(temp);
rooms.set(rooms.indexOf(temp), curRoom);
//otherwise, we're on the last iteration.
@@ -382,7 +403,7 @@ public class LegacyBuilder extends Builder {
return null;
} else {
temp = roomShop;
- roomShop = Imp.Quest.isCompleted() ? new ShopRoom().set(temp) : new StandardRoom().set(temp);
+ roomShop = Imp.Quest.isCompleted() ? new ShopRoom().set(temp) : StandardRoom.createRoom().set(temp);
rooms.set(rooms.indexOf(temp), roomShop);
}
@@ -550,7 +571,7 @@ public class LegacyBuilder extends Builder {
if (connections == 0) {
} else if (Random.Int( connections * connections ) == 0) {
- it.set(new StandardRoom().set(r));
+ it.set(StandardRoom.createRoom().set(r));
count++;
} else {
if (tunnelType == TunnelRoom.class){
@@ -565,7 +586,7 @@ public class LegacyBuilder extends Builder {
while (count < 6) {
Room r = randomRoom( tunnelType, 20 );
if (r != null) {
- rooms.set(rooms.indexOf(r), new StandardRoom().set(r));
+ rooms.set(rooms.indexOf(r), StandardRoom.createRoom().set(r));
count++;
} else {
return false;
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/RegularPainter.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/RegularPainter.java
index bcf04c884..97147966d 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/RegularPainter.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/RegularPainter.java
@@ -1,3 +1,24 @@
+/*
+ * Pixel Dungeon
+ * Copyright (C) 2012-2015 Oleg Dolya
+ *
+ * Shattered Pixel Dungeon
+ * Copyright (C) 2014-2017 Evan Debenham
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ */
+
package com.shatteredpixel.shatteredpixeldungeon.levels.painters;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/Room.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/Room.java
index e3208bb77..16a7547da 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/Room.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/Room.java
@@ -35,6 +35,7 @@ import java.util.LinkedHashMap;
//Note that this class should be treated as if it were abstract
// it is currently not abstract to maintain compatibility with pre-0.6.0 saves
+// TODO make this class abstract after dropping support for pre-0.6.0 saves
public class Room extends Rect implements Graph.Node, Bundlable {
public ArrayList neigbours = new ArrayList();
@@ -67,12 +68,37 @@ public class Room extends Rect implements Graph.Node, Bundlable {
return this;
}
- public int minDimension(){
+ //Note: when overriding these it is STRONGLY ADVISED to store any randomly decided values.
+ //With the same room and the same parameters these should always return
+ //the same value over multiple calls, even if there's some randomness initially.
+ public int minWidth(){
return -1;
}
+ public int maxWidth() { return -1; }
- public int maxDimension(){
- return -1;
+ public int minHeight() { return -1; }
+ public int maxHeight() { return -1; }
+
+ public boolean setSize(){
+ return setSize(minWidth(), maxWidth(), minHeight(), maxHeight());
+ }
+
+ public boolean setSize( int w, int h){
+ return setSize( w, w, h, h );
+ }
+
+ public boolean setSize(int minW, int maxW, int minH, int maxH) {
+ if (minW < minWidth()
+ || maxW > maxWidth()
+ || minH < minHeight()
+ || maxH > maxHeight()){
+ return false;
+ } else {
+ //subtract one because rooms are inclusive to their right and bottom sides
+ resize(left + Random.NormalIntRange(minW, maxW) - 1,
+ top + Random.NormalIntRange(minH, maxH) - 1);
+ return true;
+ }
}
//Width and height are increased by 1 because rooms are inclusive to their right and bottom sides
@@ -86,11 +112,6 @@ public class Room extends Rect implements Graph.Node, Bundlable {
return super.height()+1;
}
- @Override
- public int square() {
- return width()*height();
- }
-
public void paint(Level level){ }
public Point random() {
@@ -126,8 +147,8 @@ public class Room extends Rect implements Graph.Node, Bundlable {
public Point center() {
return new Point(
- (left + right) / 2 + (((right - left) & 1) == 1 ? Random.Int( 2 ) : 0),
- (top + bottom) / 2 + (((bottom - top) & 1) == 1 ? Random.Int( 2 ) : 0) );
+ (left + right) / 2 + (((right - left) % 2) == 1 ? Random.Int( 2 ) : 0),
+ (top + bottom) / 2 + (((bottom - top) % 2) == 1 ? Random.Int( 2 ) : 0) );
}
// **** Graph.Node interface ****
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MassGraveRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MassGraveRoom.java
index fef63a63b..66f6cedcf 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MassGraveRoom.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MassGraveRoom.java
@@ -40,8 +40,14 @@ import com.watabou.utils.Random;
import java.util.ArrayList;
public class MassGraveRoom extends SpecialRoom {
-
- public void paint( Level level){
+
+ @Override
+ public int minWidth() { return 7; }
+
+ @Override
+ public int minHeight() { return 7; }
+
+ public void paint(Level level){
Door entrance = entrance();
entrance.set(Door.Type.BARRICADE);
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/RotGardenRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/RotGardenRoom.java
index 30412123f..4b9bad810 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/RotGardenRoom.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/RotGardenRoom.java
@@ -33,6 +33,12 @@ import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
public class RotGardenRoom extends SpecialRoom {
+
+ @Override
+ public int minWidth() { return 7; }
+
+ @Override
+ public int minHeight() { return 7; }
public void paint( Level level ) {
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ShopRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ShopRoom.java
index 66cd9df83..effb3cb52 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ShopRoom.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ShopRoom.java
@@ -86,6 +86,18 @@ public class ShopRoom extends SpecialRoom {
private static ArrayList- itemsToSpawn;
+ @Override
+ public int minWidth() {
+ if (itemsToSpawn == null) generateItems();
+ return Math.max(7, (int)(Math.sqrt(itemsToSpawn.size())+3));
+ }
+
+ @Override
+ public int minHeight() {
+ if (itemsToSpawn == null) generateItems();
+ return Math.max(7, (int)(Math.sqrt(itemsToSpawn.size())+3));
+ }
+
public void paint( Level level ) {
Painter.fill( level, this, Terrain.WALL );
@@ -252,9 +264,9 @@ public class ShopRoom extends SpecialRoom {
rare.cursed = rare.cursedKnown = false;
itemsToSpawn.add( rare );
- //this is a hard limit, level gen allows for at most an 8x5 room, can't fit more than 39 items + 1 shopkeeper.
- if (itemsToSpawn.size() > 39)
- throw new RuntimeException("Shop attempted to carry more than 39 items!");
+ //hard limit is 63 items + 1 shopkeeper, as shops can't be bigger than 8x8=64 internally
+ if (itemsToSpawn.size() > 63)
+ throw new RuntimeException("Shop attempted to carry more than 63 items!");
Collections.shuffle(itemsToSpawn);
}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java
index 8267c9f50..bef6e8e87 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java
@@ -1,3 +1,24 @@
+/*
+ * Pixel Dungeon
+ * Copyright (C) 2012-2015 Oleg Dolya
+ *
+ * Shattered Pixel Dungeon
+ * Copyright (C) 2014-2017 Evan Debenham
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ */
+
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
@@ -10,14 +31,14 @@ import java.util.Arrays;
public class SpecialRoom extends Room {
@Override
- public int minDimension() {
- return 5;
- }
+ public int minWidth() { return 5; }
+ public int maxWidth() { return 10; }
@Override
- public int maxDimension() {
- return 10;
+ public int minHeight() {
+ return 5;
}
+ public int maxHeight() { return 10; }
public Door entrance() {
return connected.values().iterator().next();
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/BridgeRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/BridgeRoom.java
new file mode 100644
index 000000000..afda4f4a7
--- /dev/null
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/BridgeRoom.java
@@ -0,0 +1,100 @@
+/*
+ * Pixel Dungeon
+ * Copyright (C) 2012-2015 Oleg Dolya
+ *
+ * Shattered Pixel Dungeon
+ * Copyright (C) 2014-2017 Evan Debenham
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ */
+
+package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
+
+import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
+import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
+import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
+import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
+import com.watabou.utils.Point;
+import com.watabou.utils.Random;
+
+//TODO honestly this might work better as a type of tunnel room
+public class BridgeRoom extends StandardRoom {
+
+ @Override
+ public void paint(Level level) {
+
+ Painter.fill( level, this, Terrain.WALL );
+ for (Door door : connected.values()) {
+ door.set( Door.Type.REGULAR );
+ }
+
+ Painter.fill( level, this, 1,
+ !Dungeon.bossLevel() && !Dungeon.bossLevel( Dungeon.depth + 1 ) && Random.Int( 3 ) == 0 ?
+ Terrain.CHASM :
+ Terrain.WATER );
+
+ Point door1 = null;
+ Point door2 = null;
+ for (Point p : connected.values()) {
+ if (door1 == null) {
+ door1 = p;
+ } else {
+ door2 = p;
+ }
+ }
+
+ if ((door1.x == left && door2.x == right) ||
+ (door1.x == right && door2.x == left)) {
+
+ int s = width() / 2;
+
+ Painter.drawInside( level, this, door1, s, Terrain.EMPTY_SP );
+ Painter.drawInside( level, this, door2, s, Terrain.EMPTY_SP );
+ Painter.fill( level, center().x, Math.min( door1.y, door2.y ), 1, Math.abs( door1.y - door2.y ) + 1, Terrain.EMPTY_SP );
+
+ } else
+ if ((door1.y == top && door2.y == bottom) ||
+ (door1.y == bottom && door2.y == top)) {
+
+ int s = height() / 2;
+
+ Painter.drawInside( level, this, door1, s, Terrain.EMPTY_SP );
+ Painter.drawInside( level, this, door2, s, Terrain.EMPTY_SP );
+ Painter.fill( level, Math.min( door1.x, door2.x ), center().y, Math.abs( door1.x - door2.x ) + 1, 1, Terrain.EMPTY_SP );
+
+ } else
+ if (door1.x == door2.x) {
+
+ Painter.fill( level, door1.x == left ? left + 1 : right - 1, Math.min( door1.y, door2.y ), 1, Math.abs( door1.y - door2.y ) + 1, Terrain.EMPTY_SP );
+
+ } else
+ if (door1.y == door2.y) {
+
+ Painter.fill( level, Math.min( door1.x, door2.x ), door1.y == top ? top + 1 : bottom - 1, Math.abs( door1.x - door2.x ) + 1, 1, Terrain.EMPTY_SP );
+
+ } else
+ if (door1.y == top || door1.y == bottom) {
+
+ Painter.drawInside( level, this, door1, Math.abs( door1.y - door2.y ), Terrain.EMPTY_SP );
+ Painter.drawInside( level, this, door2, Math.abs( door1.x - door2.x ), Terrain.EMPTY_SP );
+
+ } else
+ if (door1.x == left || door1.x == right) {
+
+ Painter.drawInside( level, this, door1, Math.abs( door1.x - door2.x ), Terrain.EMPTY_SP );
+ Painter.drawInside( level, this, door2, Math.abs( door1.y - door2.y ), Terrain.EMPTY_SP );
+
+ }
+ }
+}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/BurnedRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/BurnedRoom.java
new file mode 100644
index 000000000..5c37bacc9
--- /dev/null
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/BurnedRoom.java
@@ -0,0 +1,66 @@
+/*
+ * Pixel Dungeon
+ * Copyright (C) 2012-2015 Oleg Dolya
+ *
+ * Shattered Pixel Dungeon
+ * Copyright (C) 2014-2017 Evan Debenham
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ */
+
+package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
+
+import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
+import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
+import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
+import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap;
+import com.watabou.utils.Random;
+
+public class BurnedRoom extends StandardRoom {
+
+ @Override
+ public void paint(Level level) {
+ Painter.fill( level, this, Terrain.WALL );
+ for (Door door : connected.values()) {
+ door.set( Door.Type.REGULAR );
+ }
+
+ for (int i=top + 1; i < bottom; i++) {
+ for (int j=left + 1; j < right; j++) {
+ int cell = i * level.width() + j;
+ int t = Terrain.EMBERS;
+ switch (Random.Int( 5 )) {
+ case 0:
+ t = Terrain.EMPTY;
+ break;
+ case 1:
+ t = Terrain.TRAP;
+ level.setTrap(new FireTrap().reveal(), cell);
+ break;
+ case 2:
+ t = Terrain.SECRET_TRAP;
+ level.setTrap(new FireTrap().hide(), cell);
+ break;
+ case 3:
+ t = Terrain.INACTIVE_TRAP;
+ FireTrap trap = new FireTrap();
+ trap.reveal().active = false;
+ level.setTrap(trap, cell);
+ break;
+ }
+ level.map[cell] = t;
+ }
+ }
+ }
+}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EmptyRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EmptyRoom.java
new file mode 100644
index 000000000..03a22d24c
--- /dev/null
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EmptyRoom.java
@@ -0,0 +1,37 @@
+/*
+ * Pixel Dungeon
+ * Copyright (C) 2012-2015 Oleg Dolya
+ *
+ * Shattered Pixel Dungeon
+ * Copyright (C) 2014-2017 Evan Debenham
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ */
+
+package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
+
+import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
+import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
+import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
+
+public class EmptyRoom extends StandardRoom {
+
+ @Override
+ public void paint(Level level) {
+ Painter.fill( level, this, Terrain.WALL );
+ for (Door door : connected.values()) {
+ door.set( Door.Type.REGULAR );
+ }Painter.fill( level, this, 1 , Terrain.EMPTY );
+ }
+}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EntranceRoom.java
index ceda85155..b04f0383d 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EntranceRoom.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EntranceRoom.java
@@ -27,6 +27,16 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
public class EntranceRoom extends StandardRoom {
+
+ @Override
+ public int minWidth() {
+ return Math.max(super.minWidth(), 5);
+ }
+
+ @Override
+ public int minHeight() {
+ return Math.max(super.minHeight(), 5);
+ }
public void paint( Level level ) {
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ExitRoom.java
index 8ceda38c7..763fac94a 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ExitRoom.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ExitRoom.java
@@ -27,8 +27,18 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
public class ExitRoom extends StandardRoom {
-
- public void paint( Level level) {
+
+ @Override
+ public int minWidth() {
+ return Math.max(super.minWidth(), 5);
+ }
+
+ @Override
+ public int minHeight() {
+ return Math.max(super.minHeight(), 5);
+ }
+
+ public void paint(Level level) {
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY );
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/FissureRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/FissureRoom.java
new file mode 100644
index 000000000..08830cd8b
--- /dev/null
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/FissureRoom.java
@@ -0,0 +1,45 @@
+package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
+
+import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
+import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
+import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
+import com.watabou.utils.Point;
+import com.watabou.utils.Random;
+
+public class FissureRoom extends StandardRoom {
+
+ @Override
+ public void paint(Level level) {
+ Painter.fill( level, this, Terrain.WALL );
+ for (Door door : connected.values()) {
+ door.set( Door.Type.REGULAR );
+ }
+ Painter.fill( level, this, 1, Terrain.EMPTY );
+
+ if (square() <= 25){
+ //just fill in one tile if the room is tiny
+ Point p = center();
+ Painter.set( level, p.x, p.y, Terrain.CHASM);
+
+ } else {
+ int smallestDim = Math.min(width(), height());
+ int floorW = (int)Math.sqrt(smallestDim);
+ //chance for a tile at the edge of the floor to remain a floor tile
+ float edgeFloorChance = (float)Math.sqrt(smallestDim) % 1;
+ //the wider the floor the more edge chances tend toward 50%
+ edgeFloorChance = (edgeFloorChance + (floorW-1)*0.5f) / (float)floorW;
+
+ for (int i=top + 2; i <= bottom - 2; i++) {
+ for (int j=left + 2; j <= right - 2; j++) {
+ int v = Math.min( i - top, bottom - i );
+ int h = Math.min( j - left, right - j );
+ if (Math.min( v, h ) > floorW
+ || (Math.min( v, h ) == floorW && Random.Float() > edgeFloorChance)) {
+ Painter.set( level, j, i, Terrain.CHASM );
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/GrassyGraveRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/GrassyGraveRoom.java
new file mode 100644
index 000000000..d15c6d204
--- /dev/null
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/GrassyGraveRoom.java
@@ -0,0 +1,58 @@
+/*
+ * Pixel Dungeon
+ * Copyright (C) 2012-2015 Oleg Dolya
+ *
+ * Shattered Pixel Dungeon
+ * Copyright (C) 2014-2017 Evan Debenham
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ */
+
+package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
+
+import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
+import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
+import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
+import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
+import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
+import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
+import com.watabou.utils.Random;
+
+public class GrassyGraveRoom extends StandardRoom {
+
+ @Override
+ public void paint(Level level) {
+
+ Painter.fill( level, this, Terrain.WALL );
+ for (Door door : connected.values()) {
+ door.set( Door.Type.REGULAR );
+ }
+
+ Painter.fill( level, this, 1 , Terrain.GRASS );
+
+ int w = width() - 2;
+ int h = height() - 2;
+ int nGraves = Math.max( w, h ) / 2;
+
+ int index = Random.Int( nGraves );
+
+ int shift = Random.Int( 2 );
+ for (int i=0; i < nGraves; i++) {
+ int pos = w > h ?
+ left + 1 + shift + i * 2 + (top + 2 + Random.Int( h-2 )) * level.width() :
+ (left + 2 + Random.Int( w-2 )) + (top + 1 + shift + i * 2) * level.width();
+ level.drop( i == index ? Generator.random() : new Gold().random(), pos ).type = Heap.Type.TOMB;
+ }
+ }
+}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RitualSiteRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RitualSiteRoom.java
index 88fd4bd6f..c5a3d91e8 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RitualSiteRoom.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RitualSiteRoom.java
@@ -31,6 +31,16 @@ import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual;
import com.watabou.utils.Point;
public class RitualSiteRoom extends StandardRoom {
+
+ @Override
+ public int minWidth() {
+ return Math.max(super.minWidth(), 5);
+ }
+
+ @Override
+ public int minHeight() {
+ return Math.max(super.minHeight(), 5);
+ }
public void paint( Level level ) {
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java
index 11bd21057..4a0aa16ea 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java
@@ -21,255 +21,59 @@
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
-import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
-import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
-import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
-import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
-import com.shatteredpixel.shatteredpixeldungeon.items.Item;
-import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
-import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
-import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
+import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
-import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap;
-import com.watabou.utils.Point;
import com.watabou.utils.Random;
-public class StandardRoom extends Room {
+import java.util.HashMap;
+
+public abstract class StandardRoom extends Room {
+
+ public enum SizeCategories{
+
+ NORMAL(4, 10),
+ LARGE(10, 14),
+ GIANT(14, 18);
+
+ public final int minDim, maxDim;
+
+ SizeCategories(int min, int max){
+ minDim = min;
+ maxDim = max;
+ }
+
+ }
+
+ public SizeCategories sizeCat = SizeCategories.NORMAL;
@Override
- public int minDimension() {
- return 4;
- }
+ public int minWidth() { return sizeCat.minDim; }
+ public int maxWidth() { return sizeCat.maxDim; }
@Override
- public int maxDimension() {
- return 10;
+ public int minHeight() { return sizeCat.minDim; }
+ public int maxHeight() { return sizeCat.maxDim; }
+
+ private static HashMap, Float> chances = new HashMap<>();
+
+ static {
+ chances.put(EmptyRoom.class, 24f);
+
+ chances.put(BridgeRoom.class, 1f);
+ chances.put(BurnedRoom.class, 1f);
+ chances.put(FissureRoom.class, 1f);
+ chances.put(GrassyGraveRoom.class, 1f);
+ chances.put(StripedRoom.class, 1f);
+ chances.put(StudyRoom.class, 1f);
}
- public void paint( Level level ) {
-
- Painter.fill( level, this, Terrain.WALL );
- for (Door door : connected.values()) {
- door.set( Door.Type.REGULAR );
- }
-
- if (!Dungeon.bossLevel() && Random.Int( 5 ) == 0) {
- switch (Random.Int( 6 )) {
- case 0:
- if (level.feeling != Level.Feeling.GRASS) {
- if (Math.min( width(), height() ) > 4 && Math.max( width(), height() ) > 6) {
- paintGraveyard( level, this );
- return;
- }
- break;
- } else {
- // Burned room
- }
- case 1:
- if (Dungeon.depth > 1) {
- paintBurned( level, this );
- return;
- }
- break;
- case 2:
- if (Math.max( width(), height() ) > 4) {
- paintStriped( level, this );
- return;
- }
- break;
- case 3:
- if (width() > 6 && height() > 6) {
- paintStudy( level, this );
- return;
- }
- break;
- case 4:
- if (level.feeling != Level.Feeling.WATER) {
- if (connected.size() == 2 && width() > 4 && height() > 4) {
- paintBridge( level, this );
- return;
- }
- break;
- } else {
- // Fissure
- }
- case 5:
- if (!Dungeon.bossLevel() && !Dungeon.bossLevel( Dungeon.depth + 1 ) &&
- Math.min( width(), height() ) > 5) {
- paintFissure( level, this );
- return;
- }
- break;
- }
- }
-
- Painter.fill( level, this, 1, Terrain.EMPTY );
- }
-
- private static void paintBurned( Level level, Room room ) {
- for (int i=room.top + 1; i < room.bottom; i++) {
- for (int j=room.left + 1; j < room.right; j++) {
- int cell = i * level.width() + j;
- int t = Terrain.EMBERS;
- switch (Random.Int( 5 )) {
- case 0:
- t = Terrain.EMPTY;
- break;
- case 1:
- t = Terrain.TRAP;
- level.setTrap(new FireTrap().reveal(), cell);
- break;
- case 2:
- t = Terrain.SECRET_TRAP;
- level.setTrap(new FireTrap().hide(), cell);
- break;
- case 3:
- t = Terrain.INACTIVE_TRAP;
- FireTrap trap = new FireTrap();
- trap.reveal().active = false;
- level.setTrap(trap, cell);
- break;
- }
- level.map[cell] = t;
- }
+ public static StandardRoom createRoom(){
+ try{
+ return Random.chances(chances).newInstance();
+ } catch (Exception e) {
+ ShatteredPixelDungeon.reportException(e);
+ return null;
}
}
- private static void paintGraveyard( Level level, Room room ) {
- Painter.fill( level, room , 1 , Terrain.GRASS );
-
- int w = room.width() - 2;
- int h = room.height() - 2;
- int nGraves = Math.max( w, h ) / 2;
-
- int index = Random.Int( nGraves );
-
- int shift = Random.Int( 2 );
- for (int i=0; i < nGraves; i++) {
- int pos = w > h ?
- room.left + 1 + shift + i * 2 + (room.top + 2 + Random.Int( h-2 )) * level.width() :
- (room.left + 2 + Random.Int( w-2 )) + (room.top + 1 + shift + i * 2) * level.width();
- level.drop( i == index ? Generator.random() : new Gold().random(), pos ).type = Heap.Type.TOMB;
- }
- }
-
- private static void paintStriped( Level level, Room room ) {
- Painter.fill( level, room, 1 , Terrain.EMPTY_SP );
-
- if (room.width() > room.height()) {
- for (int i=room.left + 2; i < room.right; i += 2) {
- Painter.fill( level, i, room.top + 1, 1, room.height() - 2, Terrain.HIGH_GRASS );
- }
- } else {
- for (int i=room.top + 2; i < room.bottom; i += 2) {
- Painter.fill( level, room.left + 1, i, room.width() - 2, 1, Terrain.HIGH_GRASS );
- }
- }
- }
-
- //TODO: this is almost a special room type now, consider moving this into its own painter if/when you address room gen significantly.
- private static void paintStudy( Level level, Room room ) {
- Painter.fill( level, room, 1 , Terrain.BOOKSHELF );
- Painter.fill( level, room, 2 , Terrain.EMPTY_SP );
-
- for (Point door : room.connected.values()) {
- if (door.x == room.left) {
- Painter.set( level, door.x + 1, door.y, Terrain.EMPTY );
- } else if (door.x == room.right) {
- Painter.set( level, door.x - 1, door.y, Terrain.EMPTY );
- } else if (door.y == room.top) {
- Painter.set( level, door.x, door.y + 1, Terrain.EMPTY );
- } else if (door.y == room.bottom) {
- Painter.set( level, door.x , door.y - 1, Terrain.EMPTY );
- }
- }
- Point center = room.center();
- Painter.set( level, center, Terrain.PEDESTAL );
- if (Random.Int(2) != 0){
- Item prize = level.findPrizeItem();
- if (prize != null) {
- level.drop(prize, (room.center().x + center.y * level.width()));
- return;
- }
- }
-
- level.drop(Generator.random( Random.oneOf(
- Generator.Category.POTION,
- Generator.Category.SCROLL)), (room.center().x + center.y * level.width()));
- }
-
- private static void paintBridge( Level level, Room room ) {
-
- Painter.fill( level, room, 1,
- !Dungeon.bossLevel() && !Dungeon.bossLevel( Dungeon.depth + 1 ) && Random.Int( 3 ) == 0 ?
- Terrain.CHASM :
- Terrain.WATER );
-
- Point door1 = null;
- Point door2 = null;
- for (Point p : room.connected.values()) {
- if (door1 == null) {
- door1 = p;
- } else {
- door2 = p;
- }
- }
-
- if ((door1.x == room.left && door2.x == room.right) ||
- (door1.x == room.right && door2.x == room.left)) {
-
- int s = room.width() / 2;
-
- Painter.drawInside( level, room, door1, s, Terrain.EMPTY_SP );
- Painter.drawInside( level, room, door2, s, Terrain.EMPTY_SP );
- Painter.fill( level, room.center().x, Math.min( door1.y, door2.y ), 1, Math.abs( door1.y - door2.y ) + 1, Terrain.EMPTY_SP );
-
- } else
- if ((door1.y == room.top && door2.y == room.bottom) ||
- (door1.y == room.bottom && door2.y == room.top)) {
-
- int s = room.height() / 2;
-
- Painter.drawInside( level, room, door1, s, Terrain.EMPTY_SP );
- Painter.drawInside( level, room, door2, s, Terrain.EMPTY_SP );
- Painter.fill( level, Math.min( door1.x, door2.x ), room.center().y, Math.abs( door1.x - door2.x ) + 1, 1, Terrain.EMPTY_SP );
-
- } else
- if (door1.x == door2.x) {
-
- Painter.fill( level, door1.x == room.left ? room.left + 1 : room.right - 1, Math.min( door1.y, door2.y ), 1, Math.abs( door1.y - door2.y ) + 1, Terrain.EMPTY_SP );
-
- } else
- if (door1.y == door2.y) {
-
- Painter.fill( level, Math.min( door1.x, door2.x ), door1.y == room.top ? room.top + 1 : room.bottom - 1, Math.abs( door1.x - door2.x ) + 1, 1, Terrain.EMPTY_SP );
-
- } else
- if (door1.y == room.top || door1.y == room.bottom) {
-
- Painter.drawInside( level, room, door1, Math.abs( door1.y - door2.y ), Terrain.EMPTY_SP );
- Painter.drawInside( level, room, door2, Math.abs( door1.x - door2.x ), Terrain.EMPTY_SP );
-
- } else
- if (door1.x == room.left || door1.x == room.right) {
-
- Painter.drawInside( level, room, door1, Math.abs( door1.x - door2.x ), Terrain.EMPTY_SP );
- Painter.drawInside( level, room, door2, Math.abs( door1.y - door2.y ), Terrain.EMPTY_SP );
-
- }
- }
-
- private static void paintFissure( Level level, Room room ) {
- Painter.fill( level, room, 1, Terrain.EMPTY );
-
- for (int i=room.top + 2; i < room.bottom - 1; i++) {
- for (int j=room.left + 2; j < room.right - 1; j++) {
- int v = Math.min( i - room.top, room.bottom - i );
- int h = Math.min( j - room.left, room.right - j );
- if (Math.min( v, h ) > 2 || Random.Int( 2 ) == 0) {
- Painter.set( level, j, i, Terrain.CHASM );
- }
- }
- }
- }
}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StripedRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StripedRoom.java
new file mode 100644
index 000000000..11ba65ac0
--- /dev/null
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StripedRoom.java
@@ -0,0 +1,50 @@
+/*
+ * Pixel Dungeon
+ * Copyright (C) 2012-2015 Oleg Dolya
+ *
+ * Shattered Pixel Dungeon
+ * Copyright (C) 2014-2017 Evan Debenham
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ */
+
+package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
+
+import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
+import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
+import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
+import com.watabou.utils.Random;
+
+public class StripedRoom extends StandardRoom {
+
+ @Override
+ public void paint(Level level) {
+ Painter.fill( level, this, Terrain.WALL );
+ for (Door door : connected.values()) {
+ door.set( Door.Type.REGULAR );
+ }
+
+ Painter.fill( level, this, 1 , Terrain.EMPTY_SP );
+
+ if (width() > height() || (width() == height() && Random.Int(2) == 0)) {
+ for (int i=left + 2; i < right; i += 2) {
+ Painter.fill( level, i, top + 1, 1, height() - 2, Terrain.HIGH_GRASS );
+ }
+ } else {
+ for (int i=top + 2; i < bottom; i += 2) {
+ Painter.fill( level, left + 1, i, width() - 2, 1, Terrain.HIGH_GRASS );
+ }
+ }
+ }
+}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StudyRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StudyRoom.java
new file mode 100644
index 000000000..01c9c337c
--- /dev/null
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StudyRoom.java
@@ -0,0 +1,79 @@
+/*
+ * Pixel Dungeon
+ * Copyright (C) 2012-2015 Oleg Dolya
+ *
+ * Shattered Pixel Dungeon
+ * Copyright (C) 2014-2017 Evan Debenham
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ */
+
+package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
+
+import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
+import com.shatteredpixel.shatteredpixeldungeon.items.Item;
+import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
+import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
+import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
+import com.watabou.utils.Point;
+import com.watabou.utils.Random;
+
+public class StudyRoom extends StandardRoom {
+
+ @Override
+ public int minWidth() {
+ return Math.max(super.minWidth(), 7);
+ }
+
+ @Override
+ public int minHeight() {
+ return Math.max(super.minHeight(), 7);
+ }
+
+ @Override
+ public void paint(Level level) {
+ Painter.fill( level, this, Terrain.WALL );
+ for (Door door : connected.values()) {
+ door.set( Door.Type.REGULAR );
+ }
+
+ Painter.fill( level, this, 1 , Terrain.BOOKSHELF );
+ Painter.fill( level, this, 2 , Terrain.EMPTY_SP );
+
+ for (Point door : connected.values()) {
+ if (door.x == left) {
+ Painter.set( level, door.x + 1, door.y, Terrain.EMPTY );
+ } else if (door.x == right) {
+ Painter.set( level, door.x - 1, door.y, Terrain.EMPTY );
+ } else if (door.y == top) {
+ Painter.set( level, door.x, door.y + 1, Terrain.EMPTY );
+ } else if (door.y == bottom) {
+ Painter.set( level, door.x , door.y - 1, Terrain.EMPTY );
+ }
+ }
+ Point center = center();
+ Painter.set( level, center, Terrain.PEDESTAL );
+ if (Random.Int(2) != 0){
+ Item prize = level.findPrizeItem();
+ if (prize != null) {
+ level.drop(prize, (center.x + center.y * level.width()));
+ return;
+ }
+ }
+
+ level.drop(Generator.random( Random.oneOf(
+ Generator.Category.POTION,
+ Generator.Category.SCROLL)), (center.x + center.y * level.width()));
+ }
+}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/tunnel/TunnelRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/tunnel/TunnelRoom.java
index 299ac3c25..d644eb598 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/tunnel/TunnelRoom.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/tunnel/TunnelRoom.java
@@ -30,14 +30,12 @@ import com.watabou.utils.Random;
public class TunnelRoom extends Room {
@Override
- public int minDimension() {
- return 3;
- }
+ public int minWidth() { return 3; }
+ public int maxWidth() { return 10; }
@Override
- public int maxDimension() {
- return 10;
- }
+ public int minHeight() { return 3; }
+ public int maxHeight() { return 10; }
public void paint(Level level) {