Skip to content

Commit

Permalink
Add lord_web_api mod skeleton. Relates to #1401 #1333
Browse files Browse the repository at this point in the history
  • Loading branch information
alek13 committed May 31, 2024
1 parent 0d6ab25 commit b965578
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mods/lord/Game/lord_web_api/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local DS = os.DIRECTORY_SEPARATOR
local mod_path = minetest.get_modpath(minetest.get_current_modname())
local old_require = require
require = function(name) return dofile(mod_path .. DS .. "src" .. DS .. name:gsub("%.", DS) .. ".lua") end


require("lord_web_api").init()


require = old_require
1 change: 1 addition & 0 deletions mods/lord/Game/lord_web_api/mod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name = lord_web_api
22 changes: 22 additions & 0 deletions mods/lord/Game/lord_web_api/src/lord_web_api.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local Api = require("lord_web_api.Api")


--- @return http_client.Client
local function init_client()
return http_client.Client:new(
-- TODO
)
end

--- @param client http_client.Client
local function register_api(client)
_G.lord_web_api = Api:new(client)
end


return {
init = function()
local client = init_client()
register_api(client)
end,
}
25 changes: 25 additions & 0 deletions mods/lord/Game/lord_web_api/src/lord_web_api/Api.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
local Players = require("lord_web_api.api.Players")
local Clans = require("lord_web_api.api.Plans")


--- @class lord_web_api.Api
local Api = {
--- @type lord_web_api.api.Players
players = nil,
--- @type lord_web_api.api.Clans
clans = nil,
}

--- @param client http_client.Client
function Api:new(client)
local class = self
self = {}

self.players = Players:new(client)
self.clans = Clans:new(client)

return setmetatable(self, {__index = class})
end


return Api
39 changes: 39 additions & 0 deletions mods/lord/Game/lord_web_api/src/lord_web_api/api/Clans.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

--- @class lord_web_api.api.Clans
local Clans = {
--- @type http_client.Client
client = nil,
}

--- @param client http_client.Client
function Clans:new(client)
local class = self
self = {}

self.client = client

return setmetatable(self, {__index = class})
end

function Clans:list()
-- TODO
end

function Clans:get()
-- TODO
end

function Clans:create()
-- TODO
end

function Clans:update()
-- TODO
end

function Clans:delete()
-- TODO
end


return Clans
39 changes: 39 additions & 0 deletions mods/lord/Game/lord_web_api/src/lord_web_api/api/Players.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

--- @class lord_web_api.api.Players
local Players = {
--- @type http_client.Client
client = nil,
}

--- @param client http_client.Client
function Players:new(client)
local class = self
self = {}

self.client = client

return setmetatable(self, {__index = class})
end

function Players:list()
-- TODO
end

function Players:get()
-- TODO
end

function Players:create()
-- TODO
end

function Players:update()
-- TODO
end

function Players:delete()
-- TODO
end


return Players

0 comments on commit b965578

Please sign in to comment.