local window = require('window')
local entity = require('entity')
-- item prototype
-- name
-- image
-- description

local m = entity:from{
    _t = 'item',
    width = 60,
    height = 60,
    name = "item",
    description = "sample description",
}

--[[ Item  ]]--

function m:pickupMode()
    self.mousepressed = window.mousepressed(function (self, x, y, button)
        self:itemMode()
        self.room:remove(self)
        inventory:pickup(self)
    end)
end

function m:itemMode()
    self.mousepressed = window.mousepressed(function (self, x, y, button)
        log:info(self)
        inventory.selected_item = self
        log:format("selected idx : %s", inventory.selected_item.idx)
    end)
end

function m:install(room, x, y)
    local i = self:new()
    i.room = room
    i:pickupMode()
    i:setpos(x, y)
    room:insert(i)
end

return m