from sqlalchemy import Column, Integer, ForeignKey

from components.component import Component, component_repr


class Getable(Component):
    """Flag this entity as an object that can be picked up."""
    __tablename__ = 'getable'
    id = Column(Integer, primary_key=True)
    entity = Column(Integer, ForeignKey('entity.id', ondelete='CASCADE'), unique=True, index=True, nullable=False)
    held_by = Column(Integer, index=True)  # when not null, entity is being carried by the given entity

    def __repr__(self):
        return component_repr(self)
