Cannibalism = Cannibalism or {}
local CannibalismUtils = {}

local function initializeReqs()
    CannibalismUtils = require("Cannibalism_Utils")
end

Events.OnInitGlobalModData.Add(initializeReqs)


function Cannibalism.OnEat_Meat(food, character, percent)
    if isServer() then return end
    local vars = SandboxVars.Cannibalism
    local isZombieMeat = food:getType() == "ZombieMeat"
    local isRaw = not food:isCooked()

    local currentInsanityPoints = CannibalismUtils.getPlayerInsanityPoints(character)
    local newInsanityPoints

    if isZombieMeat then
        if isRaw then
            newInsanityPoints = currentInsanityPoints + vars.RawZombieMeatInsanityPointsGain
        else
            newInsanityPoints = currentInsanityPoints + vars.CookedZombieMeatInsanityPointsGain
        end
    else
        if isRaw then
            newInsanityPoints = currentInsanityPoints + vars.RawHumanMeatInsanityPointsGain
        else
            newInsanityPoints = currentInsanityPoints + vars.CookedHumanMeatInsanityPointsGain
        end
    end

    character:getModData().Cannibalism_InsanityPoints = newInsanityPoints
    local insanityStage = CannibalismUtils.getPlayerInsanityStage(character)
    MF.getMoodle("insane", character:getPlayerNum()):setValue(insanityStage) --float

    character:getModData().Cannibalism_hasCannibalisedToday = true
end

--MF.getMoodle("insane", getPlayer():getPlayerNum()):setValue(1) --float
--print(getPlayer():getModData().Cannibalism_InsanityPoints)
