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

function mushroomForagingRemove()

	local removedMushrooms = {
		"Mushrooms",
		"MushroomGeneric1",
		"MushroomGeneric2",
		"MushroomGeneric3",
		"MushroomGeneric4",
		"MushroomGeneric5",
		"MushroomGeneric6",
		"MushroomGeneric7",
	}
	
	for i = #forageSystem, 1, -1 do
		for j = 1, #removedMushrooms do
			if forageSystem[i].name == removedMushrooms[j] then
				table.remove(forageSystem, i)
				break
			end
		end
	end	
end

function mushroomForagingAdd()

local mushroomItems = {
	normal = {
		chance = 65,
		xp = 2,
		items = {
			AgaricusArvensis = "Base.lp_AgaricusArvensis",
				AgaricusCampestris = "Base.lp_AgaricusCampestris",
				AmanitaBisporigera = "Base.lp_AmanitaBisporigera",
				AmanitaBrunnescens = "Base.lp_AmanitaBrunnescens",
				AmanitaMuscaria = "Base.lp_AmanitaMuscaria",
				AmanitaPhalloides = "Base.lp_AmanitaPhalloides",
				AmanitaVirosa = "Base.lp_AmanitaVirosa",
				AuriculariaAuricula = "Base.lp_AuriculariaAuricula",
				BoletusEdulis = "Base.lp_BoletusEdulis",
				CalvatiaGigantea = "Base.lp_CalvatiaGigantea",
				CantharellulaUmbonata = "Base.lp_CantharellulaUmbonata",
				CantharellusCibarius = "Base.lp_CantharellusCibarius",
				ChlorophyllumRhacodes = "Base.lp_ChlorophyllumRhacodes",
				CollybiaNuda = "Base.lp_CollybiaNuda",
				ConocybeTenera = "Base.lp_ConocybeTenera",
				CoprinellusMicaceus = "Base.lp_CoprinellusMicaceus",
				CoprinopsisAtramentaria = "Base.lp_CoprinopsisAtramentaria",
				CoprinusComatus = "Base.lp_CoprinusComatus",
				CortinariusEvernius = "Base.lp_CortinariusEvernius",
				CortinariusMucosus = "Base.lp_CortinariusMucosus",
				CraterellusCornucopioides = "Base.lp_CraterellusCornucopioides",
				CrepidotusCesatii = "Base.lp_CrepidotusCesatii",
				CyptotramaChrysopepla = "Base.lp_CyptotramaChrysopepla",
				FomesExcavatus = "Base.lp_FomesExcavatus",
				FomitopsisBetulina = "Base.lp_FomitopsisBetulina",
				FomitopsisMounceae = "Base.lp_FomitopsisMounceae",
				GalerinaMarginata = "Base.lp_GalerinaMarginata",
				GanodermaApplanatum = "Base.lp_GanodermaApplanatum",
				GanodermaTsugae = "Base.lp_GanodermaTsugae",
				GenusGliophorus = "Base.lp_GenusGliophorus",
				GomphidiusGlutinosus = "Base.lp_GomphidiusGlutinosus",
				GomphidiusSubroseus = "Base.lp_GomphidiusSubroseus",
				GrifolaFondosa = "Base.lp_GrifolaFondosa",
				GuepiniaHelvelloides = "Base.lp_GuepiniaHelvelloides",
				HericiumAmericanum = "Base.lp_HericiumAmericanum",
				HericiumCoralloides = "Base.lp_HericiumCoralloides",
				HericiumErinaceus = "Base.lp_HericiumErinaceus",
				HydnumRepandum = "Base.lp_HydnumRepandum",
				HypholomaFasciculare = "Base.lp_HypholomaFasciculare",
				HypomycesLactifluorum = "Base.lp_HypomycesLactifluorum",
				InonotusObliquus = "Base.lp_InonotusObliquus",
				IrpexLacteus = "Base.lp_IrpexLacteus",
				LaccariaLaccata = "Base.lp_LaccariaLaccata",
				LacrymariaLacrymabunda = "Base.lp_LacrymariaLacrymabunda",
				LactariusDeliciosus = "Base.lp_LactariusDeliciosus",
				LactariusTabidus = "Base.lp_LactariusTabidus",
				LaetiporusSulphureus = "Base.lp_LaetiporusSulphureus",
				LepiotaBrunneoincarnata = "Base.lp_LepiotaBrunneoincarnata",
				LepiotaClypeolaria = "Base.lp_LepiotaClypeolaria",
				LycogalaEpidendrum = "Base.lp_LycogalaEpidendrum",
				LycoperdonPerlatum = "Base.lp_LycoperdonPerlatum",
				MacrolepiotaProcera = "Base.lp_MacrolepiotaProcera",
				MarasmiusOreades = "Base.lp_MarasmiusOreades",
				MorchellaElata = "Base.lp_MorchellaElata",
				MycenaGalopus = "Base.lp_MycenaGalopus",
				OmphalotusIlludens = "Base.lp_OmphalotusIlludens",
				PanellusStipticus = "Base.lp_PanellusStipticus",
				PhaeolusSchweinitzii = "Base.lp_PhaeolusSchweinitzii",
				PhaeotremellaFoliacea = "Base.lp_PhaeotremellaFoliacea",
				PleurotusLevis = "Base.lp_PleurotusLevis",
				PsilocybeSemilanceata = "Base.lp_PsilocybeSemilanceata",
				RussulaClaroflava = "Base.lp_RussulaClaroflava",
				RussulaEmetica = "Base.lp_RussulaEmetica",
				RussulaLutea = "Base.lp_RussulaLutea",
				RussulaXerampelina = "Base.lp_RussulaXerampelina",
				SarcodonImbricatus = "Base.lp_SarcodonImbricatus",
				SclerodermaCitrinum = "Base.lp_SclerodermaCitrinum",
				SuillusGrevillei = "Base.lp_SuillusGrevillei",
				TrametesOchracea = "Base.lp_TrametesOchracea",
				TrametesVersicolor = "Base.lp_TrametesVersicolor",
				TremellaMesenterica = "Base.lp_TremellaMesenterica",
				TricholomopsisDecora = "Base.lp_TricholomopsisDecora",
				TubariaFurfuracea = "Base.lp_TubariaFurfuracea",
		},
	},
	
};
for _, spawnTable in pairs(mushroomItems) do
	for itemName, itemFullName in pairs(spawnTable.items) do
		forageSystem.addItemDef({
			type = itemFullName,
			skill = 2,
			xp = spawnTable.xp,
			snowChance = -20,
			rainChance = 5,
			hasRainedChance = 80, 
			maxCount = 2,
			minCount = 1,
			categories = { "Mushrooms" },
			zones = {
				Forest      = 70,
				DeepForest  = 100,
				Vegitation  = 30,
				FarmLand    = 30,
				Farm        = 20,
				TrailerPark = 5,
				TownZone    = 1,
				Nav         = 1,
			},
			months = { 3, 4, 5, 6, 7, 8, 9, 10, 11 },
			bonusMonths = {  8, 9, 10 },
			malusMonths = { 1, 2, 10, 11, 12 },
			spawnFuncs = { doWildFoodSpawn },
			canBeAboveFloor = true,
			poisonDetectionLevel    = 6, 
			itemSizeModifier = 0.5,
			isItemOverrideSize = true,
		});
	end;
end;

end

Events.onAddForageDefs.Add(mushroomForagingAdd);


