/// <summary> /// /// </summary> /// <param name="crop"></param> /// <returns></returns> public bool CanPlantCrop(VegObjectController crop) { // Here are a few notes to try and get your head around the logic here. // First of all check to see if we leave left sufficient gap between this new // rotation and the previous rotation of this crop. // Case 1: // First test to see if this is the CurrentCrop. // If so, then make sure that we HAVENT exceeded max rotation count. Then we must // see if actually meet the planting criteria. If any of these fail, then return // "false" so that we can test another crop. Otherwise return "true" to tell the // sim to replant the CurrentCrop // Case 2: // If this is NOT the CurrentCrop - we had better first check that the CurrentCrop // is still expected to be in rotation. Then check to see that the sowing criteria // has been met. Return "true" if all good, otherwise return "false" so we can test // another crop. If we run out of crops, then the CurrentCrop stays in fallow. if (crop.IsSequenceCorrect() && crop.DoesCropMeetSowingCriteria()) { if (crop == CurrentCrop) { return(crop.IsCropUnderMaxContinuousRotations()); } else if (CurrentCrop.HasCropHadSufficientContinuousRotations()) { return(crop.HasCropBeenAbsentForSufficientYears(sim.today)); } } return(false); }