public final void descend() { if (area.getType().equals(AreaType.CAVE)) { final CaveLevel newLevel = ((Cave) area).getLevelBelow((CaveLevel) location); final Tile newTile = newLevel.getStairsUpTile(); System.out.println(newTile); move(newLevel, newTile); } else { throw new IllegalStateException(); } }
/** * Move to a given floor. * * @param l level */ public final void goToFloor(final int l) { if (area.getType().equals(AreaType.CAVE)) { final CaveLevel newFloor = ((Cave) area).getLevel(l); Tile newTile; CaveLevel currentLevel = (CaveLevel) getLocation(); if (currentLevel.getLevel() < l) { newTile = newFloor.getStairsUpTile(); } else if (currentLevel.getLevel() < l) { newTile = newFloor.getStairsDownTile(); } else { return; } move(newFloor, newTile); } else { throw new IllegalStateException( "Unexpected goToFloor() when in area of type:" + area.getType()); } }