require "Foraging/forageSystem"
require "Foraging/forageDefinitions"

function berriesForagingRemove()

	local removedBerries = {
		"WinterBerry",
		"HollyBerry",
		"BeautyBerry",
		"BerryBlack",
		"BerryBlue",
		"BerryGeneric1",
		"BerryGeneric2",
		"BerryGeneric3",
		"BerryGeneric4",
		"BerryGeneric5",
	}
	
	for i = #forageSystem, 1, -1 do
		for j = 1, #removedBerries do
			if forageSystem[i].name == removedBerries[j] then
				table.remove(forageSystem, i)
				break
			end
		end
	end	
end

function berriesForagingAdd()

local berriesItems = {
	normal = {
		chance = 60,
		xp = 2,
		items = {
			Bearberry = "Base.Bearberry",
			Blackcurrant = "Base.Blackcurrant",
			BlackHuckleberry = "BlackHuckleberry",
			Blackberry = "Base.Blackberry",
			Blueberry = "Base.Blueberry",
			Bunchberry = "Base.Bunchberry",
			Chokecherry = "Chokecherry",
			Cloudberry = "Base.Cloudberry",
			Cranberry = "Base.Cranberry",
			Crowberry = "Crowberry",
			Gooseberry = "Base.Gooseberry",
			Hawberry = "Base.Hawberry",
			Lingonberry = "Base.Lingonberry",
			Raspberry = "Raspberry",
			ClammyGroundCherry = "Base.ClammyGroundCherry",
			TwistedStalk = "Base.TwistedStalk",
			Sumac = "Base.Sumac",
			Juneberry = "Base.Juneberry",
			Redcurrant = "Base.Redcurrant",
			Elderberry = "Base.Elderberry",		
		},
	},
	
};
for _, spawnTable in pairs(berriesItems) do
	for itemName, itemFullName in pairs(spawnTable.items) do
		forageSystem.addItemDef({
			type = itemFullName,
			skill = 2,
			xp = spawnTable.xp,
			snowChance = -20,
			rainChance = 2,
			hasRainedChance = 20, 
			maxCount = 9,
			minCount = 1,
			categories = { "Berries" },
			zones = {
				Forest      = 70,
				DeepForest  = 90,
				Vegitation  = 65,
				FarmLand    = 40,
				Farm        = 40,
				TrailerPark = 5,
				TownZone    = 1,
				Nav         = 1,
			},
			months = { 6, 7, 8, 9, 10, },
			bonusMonths = {  6, 7, 8 },
			malusMonths = { 9, 10 },
			spawnFuncs = { doWildFoodSpawn },
			canBeAboveFloor = true,
			poisonDetectionLevel    = 6, 
			itemSizeModifier = 0.5,
			isItemOverrideSize = true,
		});
	end;
end;

end

Events.onAddForageDefs.Add(berriesForagingAdd);


