from sqlalchemy import Column, Integer, String, Boolean, ForeignKey

from components.component import Component, component_repr


class Usable(Component):
    """Represents a script reference to activate an object on the map or in inventory."""
    __tablename__ = 'usable'
    id = Column(Integer, primary_key=True)
    entity = Column(Integer, ForeignKey('entity.id', ondelete='CASCADE'), unique=True, index=True, nullable=False)
    on_use = Column(String(50), nullable=False)

    def __repr__(self):
        return component_repr(self)
