mtmock = {}
mtmock.mod_storage = {}
dofile('mtmock.conf')
dofile('mocks/settings.lua')
dofile('mocks/inventory.lua')
dofile('mocks/player.lua')

mtmock.settings = SettingsMock:new()

-- bind minetest and core aliases and
-- work with minetest alias from here on
minetest = mtmock
core = mtmock

--[[ //////////////////// CORE STUBS -- BEGIN \\\\\\\\\\\\\\\\\\\\ ]]--

function core.get_builtin_path()
    return core.SCRIPTDIR
end

function core.register_on_joinplayer(join_fun)
end

function core.register_on_leaveplayer(leave_fun)
end

--[[ \\\\\\\\\\\\\\\\\\\\ CORE STUBS --  END  //////////////////// ]]--


--[[ //////////////////// MTMOCK API -- BEGIN \\\\\\\\\\\\\\\\\\\\ ]]--

function mtmock.add_player(pl_name, is_builder)
    player = PlayerMock:new(pl_name, is_builder)
    minetest.connected_players[pl_name] = player
    return player
end

--[[ \\\\\\\\\\\\\\\\\\\\ MTMOCK API --  END  //////////////////// ]]--


-- load MT's serialize functions
dofile(core.get_builtin_path() .. 'common/serialize.lua')
dofile(core.get_builtin_path() .. 'game/misc.lua')

minetest.connected_players = {}
minetest.worldpath = mtmock.WORLDDIR

function minetest.get_worldpath()
    return minetest.worldpath
end

function minetest.get_connected_players()
    return minetest.connected_players
end

function minetest.log(type, msg)
end

function minetest.register_on_chat_message(fun)
end

function minetest.register_chatcommand(cmd, def)
end

function minetest.setting_get_pos(setting)
    if mtmock.settings[setting] then
        return mtmock.settings[setting]
    else
        return nil
    end
end

function minetest.get_mod_storage()
    return mtmock.mod_storage
end

function minetest.get_player_privs(pl_name)
    if pl_name == nil or minetest.privs == nil then return nil end
    return minetest.privs[pl_name]
end

function minetest.set_player_privs(pl_name, pl_privs)
    if pl_name ~= nil and minetest.privs ~= nil then
        minetest.privs[pl_name] = pl_privs
    end
end


return mtmock
