public void allZeroReturnsDrysOut() { double[] volume = new double[WorldDate.DAYS_PER_YEAR]; DailyVolume dailyVolume = new DailyVolume(1, volume); Assert.True(dailyVolume.doesItDryOut()); }
public void allHaveValueDoesntDryOut() { double[] volume = new double[WorldDate.DAYS_PER_YEAR]; for (int d = 0; d < WorldDate.DAYS_PER_YEAR; d++) { volume[d] = 1.5; } DailyVolume dailyVolume = new DailyVolume(1, volume); Assert.False(dailyVolume.doesItDryOut()); }
public void OneZeroDrysOut() { double[] volume = new double[WorldDate.DAYS_PER_YEAR]; for (int d = 0; d < WorldDate.DAYS_PER_YEAR; d++) { volume[d] = 1.5; } volume[94] = 0.0; DailyVolume dailyVolume = new DailyVolume(1, volume); Assert.True(dailyVolume.doesItDryOut()); }
// NOTE *************** // So far the crops can't grow early in the year because for that they need access to information from the previous year. // Implementation of that will be a bit tricky so I am saving it for later. // Also, these represent the number of new crops that grew today. A scavenger would have access to the last x days worth of crops. // Calculate how much of a crop is present upon request public double[] getYearOfCrop(double habitatPercentage, DailyTemps dailyTemps, DailyRain dailyRain, DailyVolume dailyVolume) { double[] currentCrop = new double[WorldDate.DAYS_PER_YEAR]; double percentGrowable = 1.0; // For each of the crops // If the crop can grow in the region return the crops store the crops returned value in the current crop array for today. int lastInvalidDay = -1; double rainSum = 0.0; bool isSomeCrop = false; for (int day = 0; day < WorldDate.DAYS_PER_YEAR; day++) { if (!dayTempAllowCrop(day, dailyTemps.days)) { lastInvalidDay = day; } if (day - lastInvalidDay >= growthPeriod - 1 && dayRainAllowCrop(day, dailyRain.precip, dailyVolume.volume, out rainSum, out percentGrowable)) { double cropMultiplier = (1.0 / ((80 - growthPeriod) * 100.0)) * 400.0 * habitatPercentage; currentCrop[day] = Math.Round(calculateCropQuality(day, rainSum, dailyTemps.days) * cropMultiplier * unitPerHarvest * percentGrowable, World.ROUND_TO); if (!isSomeCrop && !currentCrop[day].Equals(0.0)) { isSomeCrop = true; } } } if (isSomeCrop) { return(currentCrop); } else { return(null); } }