---------------------------------------------------------------------------
-- Voxelis - Voxel survival sandbox for Luanti
-- Copyright (C) 2024 Mad Star Studio LLC
-- 
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, see <http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------

-- Includes

dofile(core.get_modpath(core.get_current_modname()) .. "/survival.lua")
dofile(core.get_modpath(core.get_current_modname()) .. "/creative.lua")

-- Utility functions

function core.creative_enabled_for(name)
    assert(type(name) == "string", "core.creative_enabled_for requires an argument - a player name")
    local player = core.get_player_by_name(name)
    if player then
        return player:get_meta():get_string("gamemode") == "creative"
    end
    core.log("warning", "core.creative_enabled_for: player not found: " .. name)
    return false
end

function core.survival_enabled_for(name)
    assert(type(name) == "string", "core.survival_enabled_for requires an argument - a player name")
    local player = core.get_player_by_name(name)
    if player then
        return player:get_meta():get_string("gamemode") == "survival"
    end
    core.log("warning", "core.survival_enabled_for: player not found: " .. name)
    return false
end