Feature - Implemented Pumpkin Problems

Banana Lord

Member
I have my breakfast settings configured to harvest pumpkins (regular ones). Since I had a period of inactivity not too long ago there was a ginormous pumpkin in my pumpkin patch, but mafia didn't harvest it because my settings told it not to (meaning that I've missed quite a lot of pumpkin harvests since I started playing again). Wouldn't it make sense for mafia to harvest the contents of your pumpkin patch if there was a pumpkin in there bigger than the size set in your breakfast preferences?
 

Alhifar

Member
I'll repost the patch I made here, so it's with the feature request. Same caveats as before, being untested and unsure.
 

Attachments

  • pumpkins.diff
    802 bytes · Views: 23

slyz

Developer
I don't think that will work : i is the index of an item in KoLConstants.campground. I think we should be going through CROPS, not through KoLConstants.campground.
 

slyz

Developer
Here is my tentative patch. I'm pretty sure someone with a better knowledge of Java can do better, though.
 

Attachments

  • pumpkins_slyz.diff
    2.2 KB · Views: 26

Veracity

Developer
Staff member
I don't think you can use == to compare what you find in the campground array with what you find in CROPS; they are both AdventureResults, but I don't think they are the same objects.

How about this?
Code:
	public static boolean hasCropOrBetter( final String crop )
	{
		// Get current crop, if any
		AdventureResult current = CampgroundRequest.getCrop();
		if ( current == null || current.getCount() == 0 )
		{
			// Nothing in your garden or no garden.
			return false;
		}

		// If it equals the desired crop, peachy. Or is it pumpkiny?
		String currentName = current.getName();
		if ( crop.equals( currentName )  )
		{
			return true;
		}

		// Iterate through CROPS. If we find the current crop before we
		// find the desired crop, no good.
		for ( int i = 0; i < CROPS.length; ++i )
		{
			String cropName = CROPS[ i ].getName();
			// We found the current crop before we found the
			// desired crop. Not good enough.
			if ( cropName.equals( currentName ) )
			{
				return false;
			}
			// We found the desired crop before we found the
			// current crop - which must be better. Cool.
			if ( cropName.equals( crop ) )
			{
				return true;
			}
		}

		// Shouldn't get here - didn't find either the current or the desired crop
		return false;
	}
(and, of course, make BreakfastManager.harvestGarden() call that function, rather than simply hasCrop().
 

slyz

Developer
I was waiting another couple of days to test this with a huge pumpkin. I'll tell you how it goes.
 
Top