# Path: commands/core.py
# class Command(Resolvable):
#     pass
# 
# 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)
# 
# class GlobalEntity(EntityRef):
# 
#     def __init__(self, namespace):
#         self.namespace = namespace
#     
#     def is_single_entity(self, scope):
#         return True
# 
#     def resolve(self, scope):
#         return scope.global_entity(self.namespace)


from .core import Command, Resolvable, EntityRef, GlobalEntity
class OpMul(Operation): op = '*='
class OpDiv(Operation): op = '/='
class OpMod(Operation): op = '%='
class OpIfLt(Operation): op = '<'
class OpIfGt(Operation): op = '>'
class OpSwap(Operation): op = '><'

class ObjectiveRef(Resolvable):

    def __init__(self, name):
        assert type(name) == str
        self.objective = name

    def resolve(self, scope):
        return scope.objective(self.objective)

class ScoreRef(Resolvable):

    def __init__(self, target, objective):
        assert isinstance(target, EntityRef)
        assert isinstance(objective, ObjectiveRef)
        self.target = target
        self.objective = objective

    def resolve(self, scope):
        return '%s %s' % (self.target.resolve(scope),
                          self.objective.resolve(scope))

class Var(ScoreRef):
    def __init__(self, nameref, namespace=None):

# Path: commands/core.py
# class Command(Resolvable):
#     pass
# 
# 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)
# 
# class GlobalEntity(EntityRef):
# 
#     def __init__(self, namespace):
#         self.namespace = namespace
#     
#     def is_single_entity(self, scope):
#         return True
# 
#     def resolve(self, scope):
#         return scope.global_entity(self.namespace)


# Path: commands/scoreboard.py
from .core import Command, Resolvable, EntityRef, GlobalEntity

class OpMul(Operation): op = '*='
class OpDiv(Operation): op = '/='
class OpMod(Operation): op = '%='
class OpIfLt(Operation): op = '<'
class OpIfGt(Operation): op = '>'
class OpSwap(Operation): op = '><'

class ObjectiveRef(Resolvable):

    def __init__(self, name):
        assert type(name) == str
        self.objective = name

    def resolve(self, scope):
        return scope.objective(self.objective)

class ScoreRef(Resolvable):

    def __init__(self, target, objective):
        assert isinstance(target, EntityRef)
        assert isinstance(objective, ObjectiveRef)
        self.target = target
        self.objective = objective

    def resolve(self, scope):
        return '%s %s' % (self.target.resolve(scope),
                          self.objective.resolve(scope))

class Var(ScoreRef):
    def __init__(self, nameref, namespace=None):

        super().__init__(GlobalEntity(namespace), ObjectiveRef(nameref))