[go: up one dir, main page]

File: stores.lua

package info (click to toggle)
tome 2.3.11-ah-2
  • links: PTS, VCS
  • area: non-free
  • in suites: jessie, jessie-kfreebsd
  • size: 18,976 kB
  • ctags: 12,278
  • sloc: ansic: 145,042; sh: 212; makefile: 70
file content (32 lines) | stat: -rw-r--r-- 767 bytes parent folder | download | duplicates (5)
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
-- Take care of all concerning stores
function store_buy_list(t)
	assert(type(t) == "table", "store_buy_list got no table")
	add_hooks
	{
		[HOOK_STORE_BUY] = function (index, name, obj)
			local tbl = %t
			local elt = tbl[index]
			if not elt then
				elt = tbl[name]
			end
			if elt then
				if elt then
					if type(elt) == "function" then
						return TRUE, elt(obj)
					elseif type(elt) == "table" then
						local k, e
						for k, e in elt do
							if type(e) == "number" then
								if obj.tval == e then return TRUE, TRUE end
							else
								if (obj.tval == e[1]) and (obj.sval >= e[2])  and (obj.sval <= e[3]) then return TRUE, TRUE end
							end
						end
					elseif elt == -1 then
						return TRUE, FALSE
					end
				end
			end
		end,
	}
end