"""Container — a Thing that can hold other Things."""

from __future__ import annotations

from dataclasses import dataclass

from mudlib.object import Object
from mudlib.thing import Thing


@dataclass(eq=False)
class Container(Thing):
    """A container that can hold other items.

    Containers are Things with capacity limits and open/closed state.
    The locked flag is for command-layer logic (unlock/lock commands).
    """

    capacity: int = 10
    closed: bool = False
    locked: bool = False

    def can_accept(self, obj: Object) -> bool:
        """Accept Things when open and below capacity."""
        if not isinstance(obj, Thing):
            return False
        if self.closed:
            return False
        return len(self._contents) < self.capacity
