-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.lua2p
44 lines (36 loc) · 913 Bytes
/
notes.lua2p
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
local Log = require("modules.log.log")
local Notes = {}
local list = require("data.notes")
local acquired = {}
local function get_note(id)
@@assert(type(id) == "string")
@@assert(list[id], "no " .. id .. " in data.notes")
for _, note in ipairs(acquired) do
if note.id == id then
return note
end
end
return nil
end
function Notes.add(id)
@@assert(type(id) == "string")
@@assert(list[id], "no " .. id .. " in data.notes")
@@assert(Notes.has(id) == false, id .. " was already added")
table.insert(acquired, tablex.copy(list[id]))
Log.info("note:", id, "was added")
end
function Notes.get_info(id)
@@assert(type(id) == "string")
@@assert(list[id])
return list[id]
end
function Notes.has(id)
@@assert(type(id) == "string")
@@assert(list[id], "no " .. id .. " in data.notes")
local has = get_note(id)
return has ~= nil
end
function Notes.get_acquired()
return acquired
end
return Notes