World implements Tickable { public void adjustMoisture(int change) throws Exception { if ((change < MIN_MOISTURE) || (change > MAX_MOISTURE)) { throw new Exception("change out of range"); } for (int y = 0; y < this.getWidth(); y++) { for (int x = 0; x < this.getHeight(); x++) { Tile tile = this.getTile(x, y); double moisture = (double) tile .getProperty(TileProperty.MOISTURE); moisture += change; if (moisture > MAX_MOISTURE) { moisture = MAX_MOISTURE; } else if (moisture < MIN_MOISTURE) { moisture = MIN_MOISTURE; } tile.setProperty(TileProperty.MOISTURE, moisture); } } } World(String name, int width, int height,
                    int baseTileType, long seed);  World(String name, int width, int height); String getName(); long getSeed(); Tile getTile(int x, int y); Tile getTile(Point point); Set<AbstractBuilding> getBuildings(); int getWidth(); int getHeight(); ReadOnlyIntegerProperty widthProperty(); ReadOnlyIntegerProperty heightProperty(); @Override void tick(); void initialise(); void initialise(int minX, int minY, int maxX, int maxY); void setTile(int x, int y, int tileType); void setTile(Point point, int tileType); void setTileEntity(int x, int y, TileEntity tileEntity); void setDimensions(int width, int height); void updateLakes(int height); void setPassibility(); void adjustMoisture(int change); void addBuilding(AbstractBuilding building); void removeBuilding(AbstractBuilding building); boolean containsBuilding(AbstractBuilding building); ModifierManager getModifierManager(); WeatherType getWeatherType(); String getWeatherName(); Map<String, Integer> getWeatherComponents(); Boolean setWeather(WeatherType weather); String getSeason(); void setTileObserver(Observer observer); void setSeasonObserver(Observer observer); void setWeatherObserver(Observer observer); Season getSeasonObject(); String getSeasonIconStyle(SeasonName season, Boolean large); String getWeatherIconStyle(WeatherType weather); String getForecastIconStyle(WeatherType weather); int getSeasonEndDay(); void updateForecast(); List<WeatherQueue.Element> getForecast(); FireManager getFireManager(); DayNight getTimeManager(); WeatherManager getWeatherManager(); SeasonManager getSeasonManager(); Money getMoneyHandler(); BuildingPlacer getBuildingPlacer(); void startBulldozing(); ContractHandler getContractHandler(); ContractGenerator getContractGenerator(); StorageManager getStorageManager(); PredatorManager getPredatorManager(); ContractHandler getActiveContracts(); ContractHandler getAvailableContracts(); void setAvailableContracts(ContractHandler availableContracts); void resetAvailableContracts(); Point getStaffHouseLocation(); static final int BASE_USABLE_SIZE; static final int MIN_ELEVATION; static final int MAX_ELEVATION; static final int LAKE_ELEVATION_CUTOFF; static final double MIN_MOISTURE; static final double MAX_MOISTURE; }
@Test(expected = Exception.class) public void testAdjustMoistureBelowBounds() throws Exception { world.adjustMoisture((int) (World.MIN_MOISTURE - 1)); }
@Test(expected = Exception.class) public void testAdjustMoistureAboveBounds() throws Exception { world.adjustMoisture((int) (World.MAX_MOISTURE + 1)); }
@Test public void testAdjustMoisture() throws Exception { world.getTile(4, 5).setProperty(TileProperty.MOISTURE, World.MAX_MOISTURE - 4); for (int y = 0; y < world.getHeight(); y++) { for (int x = 0; x < world.getWidth(); x++) { world.getTile(x, y).setProperty(TileProperty.MOISTURE, World.MAX_MOISTURE - 4); } } world.adjustMoisture(3); assertEquals(World.MAX_MOISTURE - 1, world.getTile(4, 5).getProperty(TileProperty.MOISTURE)); }