local save = require("#Celeste.Mod.CrossoverCollab.Code.PointsStuff.PointsModule")

-- Returns if a flag exists, if it does, returns true, if it doesn't returns false
function isflagtrue(flag)
    return save.SaveData:IsFlagTrue(flag)
end

-- Adds a flag with the name inside the function
function addflag(flag)
    save.SaveData:AddFlag(flag)
end

-- Removes a flag
function removeflag(flag)
    save.SaveData:RemoveFlag(flag)
end

function onBegin()
	wait()
	-- Time of the day
	for i=0,23 do
		if i == os.date("*t").hour then
			setFlag("currentHour"..i,true)
		else
			setFlag("currentHour"..i,false)
		end
	end
	if os.date("*t").hour >= 7 and os.date("*t").hour <= 21 then
		setFlag("isNight",false)
		setFlag("isDay",true)
		setDarkness(0.1)
		setBloomStrength(0.6)
	else
		setFlag("isNight",true)
		setFlag("isDay",false)
		setDarkness(0.2)
		setBloomStrength(0.8)
	end
	
	if isflagtrue("quest_orangejuice") then
		setFlag("quest_orangejuice",true)
	end
	if isflagtrue("quest_apple") then
		setFlag("quest_apple",true)
		setFlag("quest_orangejuice",false)
		removeflag("quest_orangejuice")
	end
	if isflagtrue("quest_arcadecoupon") then
		setFlag("quest_arcadecoupon",true)
		setFlag("quest_apple",false)
		setFlag("quest_orangejuice",false)
		removeflag("quest_apple")
		removeflag("quest_orangejuice")
	end
	if isflagtrue("quest_comic") then
		setFlag("quest_comic",true)
		setFlag("quest_arcadecoupon",false)
		setFlag("quest_apple",false)
		setFlag("quest_orangejuice",false)
		removeflag("quest_arcadecoupon")
		removeflag("quest_apple")
		removeflag("quest_orangejuice")
	end
	if isflagtrue("quest_computer") then
		setFlag("quest_computer",true)
		setFlag("quest_comic",false)
		setFlag("quest_arcadecoupon",false)
		setFlag("quest_apple",false)
		setFlag("quest_orangejuice",false)
		removeflag("quest_comic")
		removeflag("quest_arcadecoupon")
		removeflag("quest_apple")
		removeflag("quest_orangejuice")
	end
end