Skip to content

Commit

Permalink
Fix boss room sometimes being placed in the wrong keylevel when !boss…
Browse files Browse the repository at this point in the history
…RoomLocked.
  • Loading branch information
tcoxon committed Jan 18, 2017
1 parent 931e94d commit c5b1812
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/net/bytten/metazelda/generators/DungeonGenerator.java
Expand Up @@ -39,7 +39,7 @@ public class DungeonGenerator implements IDungeonGenerator, ILogger {
/**
* Creates a DungeonGenerator with a given random seed and places
* specific constraints on {@link IDungeon}s it generates.
*
*
* @param seed the random seed to use
* @param constraints the constraints to place on generation
* @see net.bytten.metazelda.constraints.IDungeonConstraints
Expand Down Expand Up @@ -68,7 +68,7 @@ public void log(String msg) {
/**
* Randomly chooses a {@link Room} within the given collection that has at
* least one adjacent empty space.
*
*
* @param roomCollection the collection of rooms to choose from
* @return the room that was chosen, or null if there are no rooms with
* adjacent empty spaces
Expand All @@ -92,7 +92,7 @@ protected Room chooseRoomWithFreeEdge(Collection<Room> roomCollection,
/**
* Randomly chooses a {@link Direction} in which the given {@link Room} has
* an adjacent empty space.
*
*
* @param room the room
* @return the Direction of the empty space chosen adjacent to the Room or
* null if there are no adjacent empty spaces
Expand Down Expand Up @@ -155,7 +155,7 @@ protected static class OutOfRoomsException extends Exception {
* Comparator objects for sorting {@link Room}s in a couple of different
* ways. These are used to determine in which rooms of a given keyLevel it
* is best to place the next key.
*
*
* @see #placeKeys
*/
protected static final Comparator<Room>
Expand All @@ -176,9 +176,9 @@ public int compare(Room arg0, Room arg1) {

/**
* Sets up the dungeon's entrance room.
*
*
* @param levels the keyLevel -> room-set mapping to update
* @see KeyLevelRoomMapping
* @see KeyLevelRoomMapping
*/
protected void initEntranceRoom(KeyLevelRoomMapping levels)
throws RetryException {
Expand Down Expand Up @@ -215,7 +215,7 @@ protected boolean shouldAddNewLock(int keyLevel, int numRooms, int targetRoomsPe
/**
* Fill the dungeon's space with rooms and doors (some locked).
* Keys are not inserted at this point.
*
*
* @param levels the keyLevel -> room-set mapping to update
* @throws RetryException if it fails
* @see KeyLevelRoomMapping
Expand Down Expand Up @@ -277,7 +277,7 @@ protected void placeRooms(KeyLevelRoomMapping levels, int roomsPerLock)
/**
* Places the BOSS and GOAL rooms within the dungeon, in existing rooms.
* These rooms are moved into the next keyLevel.
*
*
* @param levels the keyLevel -> room-set mapping to update
* @throws RetryException if it fails
* @see KeyLevelRoomMapping
Expand Down Expand Up @@ -322,10 +322,10 @@ protected void placeBossGoalRooms(KeyLevelRoomMapping levels)
if (goalRoom != null) goalRoom.setItem(goalSym);
bossRoom.setItem(bossSym);

if (isBossRoomLocked()) {
int oldKeyLevel = bossRoom.getPrecond().getKeyLevel(),
newKeyLevel = Math.min(levels.keyCount(), constraints.getMaxKeys());
int oldKeyLevel = bossRoom.getPrecond().getKeyLevel(),
newKeyLevel = Math.min(levels.keyCount(), constraints.getMaxKeys());

if (oldKeyLevel != newKeyLevel) {
List<Room> oklRooms = levels.getRooms(oldKeyLevel);
if (goalRoom != null) oklRooms.remove(goalRoom);
oklRooms.remove(bossRoom);
Expand All @@ -350,10 +350,10 @@ protected void placeBossGoalRooms(KeyLevelRoomMapping levels)
/**
* Removes the given {@link Room} and all its descendants from the given
* list.
*
*
* @param rooms the list of Rooms to remove nodes from
* @param room the Room whose descendants to remove from the list
*/
*/
protected void removeDescendantsFromList(List<Room> rooms, Room room) {
rooms.remove(room);
for (Room child: room.getChildren()) {
Expand All @@ -364,7 +364,7 @@ protected void removeDescendantsFromList(List<Room> rooms, Room room) {
/**
* Adds extra conditions to the given {@link Room}'s preconditions and all
* of its descendants.
*
*
* @param room the Room to add extra preconditions to
* @param cond the extra preconditions to add
*/
Expand All @@ -380,7 +380,7 @@ protected void addPrecond(Room room, Condition cond) {
* {@link Edge}s that require the switch to be in the given state.
* <p>
* If the given state is EITHER, the required states will be random.
*
*
* @param room the room whose child to lock
* @param givenState the state to require the switch to be in for the
* child rooms to be accessible
Expand Down Expand Up @@ -422,7 +422,7 @@ protected boolean switchLockChildRooms(Room room,
/**
* Returns a path from the goal to the dungeon entrance, along the 'parent'
* relations.
*
*
* @return a list of linked {@link Room}s starting with the goal room and
* ending with the start room.
*/
Expand All @@ -440,7 +440,7 @@ protected List<Room> getSolutionPath() {
* Makes some {@link Edge}s within the dungeon require the dungeon's switch
* to be in a particular state, and places the switch in a room in the
* dungeon.
*
*
* @throws RetryException if it fails
*/
protected void placeSwitches() throws RetryException {
Expand Down Expand Up @@ -494,7 +494,7 @@ protected void placeSwitches() throws RetryException {
/**
* Randomly links up some adjacent rooms to make the dungeon graph less of
* a tree.
*
*
* @throws RetryException if it fails
*/
protected void graphify() throws RetryException {
Expand Down Expand Up @@ -538,7 +538,7 @@ protected void graphify() throws RetryException {
/**
* Places keys within the dungeon in such a way that the dungeon is
* guaranteed to be solvable.
*
*
* @param levels the keyLevel -> room-set mapping to use
* @throws RetryException if it fails
* @see KeyLevelRoomMapping
Expand Down Expand Up @@ -584,7 +584,7 @@ protected void placeKeys(KeyLevelRoomMapping levels) throws RetryException {
* <p>
* Intensities set by this method may (will) be outside of the normal range
* from 0.0 to 1.0. See {@link #normalizeIntensity} to correct this.
*
*
* @param room the room to set the intensity of
* @param intensity the value to set intensity to (some randomn variance is
* added)
Expand All @@ -610,7 +610,7 @@ protected double applyIntensity(Room room, double intensity) {
/**
* Scales intensities within the dungeon down so that they all fit within
* the range 0 <= intensity < 1.0.
*
*
* @see Room
*/
protected void normalizeIntensity() {
Expand All @@ -626,7 +626,7 @@ protected void normalizeIntensity() {
/**
* Computes the 'intensity' of each {@link Room}. Rooms generally get more
* intense the deeper they are into the dungeon.
*
*
* @param levels the keyLevel -> room-set mapping to update
* @throws RetryException if it fails
* @see KeyLevelRoomMapping
Expand Down Expand Up @@ -664,7 +664,7 @@ protected void computeIntensity(KeyLevelRoomMapping levels)
* Checks with the
* {@link net.bytten.metazelda.constraints.IDungeonConstraints} that the
* dungeon is OK to use.
*
*
* @throws RetryException if the IDungeonConstraints decided generation must
* be re-attempted
* @see net.bytten.metazelda.constraints.IDungeonConstraints
Expand Down

0 comments on commit c5b1812

Please sign in to comment.