public final void ascend() { if (area.getType().equals(AreaType.CAVE)) { final CaveLevel newLevel = ((Cave) area).getLevelAbove((CaveLevel) location); final Tile newTile = newLevel.getStairsDownTile(); move(newLevel, newTile); } else { throw new IllegalStateException("Not expecting ascend in area type:" + area.getType()); } }
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()); } }