Skip to content

Commit f621b71

Browse files
committed
refactor: 🚧 Seperated Inventory-Types
Seperated general Inventory to: (Abstract)<Inventory>, <TurtleInventory>, <ChestInventory>
1 parent 095cdd2 commit f621b71

File tree

9 files changed

+460
-380
lines changed

9 files changed

+460
-380
lines changed

TestSuite-lib

inventory.lua

Lines changed: 0 additions & 314 deletions
This file was deleted.

inventory/chestInventory.lua

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
local class = require("./TestSuite-lib/ccClass/ccClass")
2+
local inventory = require("../inventory/inventory")
3+
---@class ChestInventory : Inventory
4+
local chestInventory = class(inventory)
5+
6+
--- ### Description:
7+
--- List all items in this inventory.
8+
--- This returns a table, with an entry for each slot.
9+
function chestInventory:list()
10+
---todo: implement
11+
local items = {}
12+
for i = 1, inventory.inventorySize do
13+
table.insert(items, inventory:getItemDetail(i))
14+
end
15+
return items
16+
end
17+
18+
function chestInventory:getItemLimit(slot)
19+
return self[slot].maxcount or self.defaultMaxSlotSize
20+
end
21+
22+
function chestInventory:getType()
23+
return "inventory"
24+
end
25+
26+
27+
function chestInventory:pushItems(toName, fromSlot, limit, toSlot)
28+
error("TODO")
29+
end
30+
31+
function chestInventory:pullItems(fromName, fromSlot, limit, toSlot)
32+
error("TODO")
33+
end
34+
35+
function getMethods()
36+
return {
37+
"list",
38+
"getType",
39+
"pushItems",
40+
"pullItems"
41+
}
42+
end
43+
44+
return chestInventory

0 commit comments

Comments
 (0)