# Path: commands/core.py
# class Resolvable(metaclass=abc.ABCMeta):
# 
#     @abc.abstractmethod
#     def resolve(self, scope):
#         pass
# 
# class EntityRef(Resolvable, metaclass=abc.ABCMeta):
# 
#     @abc.abstractmethod
#     def is_single_entity(self, scope):
#         pass
# 
#     @property
#     def ref(self):
#         from .nbt import EntityReference
#         return EntityReference(self)
# 
# Path: commands/scoreboard.py
# class ObjectiveRef(Resolvable):
# 
#     def __init__(self, name):
#         assert type(name) == str
#         self.objective = name
# 
#     def resolve(self, scope):
#         return scope.objective(self.objective)


from .core import Resolvable, EntityRef
from .scoreboard import ObjectiveRef
        for key, value in items:
            if type(value) == dict:
                value = '{%s}' % str_pairs(value.items())
            output.append('%s=%s' % (key, value))
        return ','.join(output)

    return '%s[%s]' % (output, str_pairs(kwargs.items()))

class Selector(EntityRef):

    def __init__(self, type, args=None):
        assert type in 'aespr'
        self.type = type
        assert args is None or isinstance(args, SelectorArgs)
        self.args = args

    def resolve_params(self, scope):
        if not self.args:
            return {}
        return self.args.resolve(scope)

    def is_single_entity(self, scope):
        if self.type in 'spr':
            return True
        params = self.resolve_params(scope)
        return 'limit' in params and params['limit'] == '1'

    def resolve(self, scope):
        return make_selector(self.type, **self.resolve_params(scope))


# Path: commands/core.py
# class Resolvable(metaclass=abc.ABCMeta):
# 
#     @abc.abstractmethod
#     def resolve(self, scope):
#         pass
# 
# class EntityRef(Resolvable, metaclass=abc.ABCMeta):
# 
#     @abc.abstractmethod
#     def is_single_entity(self, scope):
#         pass
# 
#     @property
#     def ref(self):
#         from .nbt import EntityReference
#         return EntityReference(self)
# 
# Path: commands/scoreboard.py
# class ObjectiveRef(Resolvable):
# 
#     def __init__(self, name):
#         assert type(name) == str
#         self.objective = name
# 
#     def resolve(self, scope):
#         return scope.objective(self.objective)


# Path: commands/selector.py
from .core import Resolvable, EntityRef
from .scoreboard import ObjectiveRef

        for key, value in items:
            if type(value) == dict:
                value = '{%s}' % str_pairs(value.items())
            output.append('%s=%s' % (key, value))
        return ','.join(output)

    return '%s[%s]' % (output, str_pairs(kwargs.items()))

class Selector(EntityRef):

    def __init__(self, type, args=None):
        assert type in 'aespr'
        self.type = type
        assert args is None or isinstance(args, SelectorArgs)
        self.args = args

    def resolve_params(self, scope):
        if not self.args:
            return {}
        return self.args.resolve(scope)

    def is_single_entity(self, scope):
        if self.type in 'spr':
            return True
        params = self.resolve_params(scope)
        return 'limit' in params and params['limit'] == '1'

    def resolve(self, scope):
        return make_selector(self.type, **self.resolve_params(scope))


class SelectorArgs(Resolvable):