class EntityA(Entity):
    position = Component(Position, 1, 2)

    def __init__(self, x=None, y=None):
        if x is not None:
            self.position.x = x
        if y is not None:
            self.position.y = y
예제 #2
0
class DeepSubclassTest2(DeepSubclassTest):
    position2 = Component(Position)

    def test_deeper_subclass(self):
        assert self.direction
        assert self.position
        assert self.position2
        assert self.position.x == self.position2.x and self.position.y == self.position2.y
        self.position.x += 1
        assert self.position.x == self.position2.x and self.position.y == self.position2.y
예제 #3
0
class AssignTest(Entity):
    position = Component(Position)

    def __init__(self):
        assert self.entity.id.index == 0
        assert self.entity.id.version == 1

    def test_assign_create(self):
        assert self.entity.id.index == 0
        assert self.entity.id.version == 1
        assert self.position.x == 0.0, ("%d != 0.0") % self.position.x
        assert self.position.y == 0.0, ("%d != 0.0") % self.position.y
        self.position.x = 1
        self.position.y = 2

    def test_assign_existing(self):
        direction = self.Component(Direction)
        assert self.entity.id.index == 0
        assert self.entity.id.version == 1
        assert direction.x == 2, ("%d != 2") % direction.x
        assert direction.y == 3, ("%d != 3") % direction.y
        direction.x += 1
        direction.y += 1
예제 #4
0
class ConstructorTest(Entity):
    position = Component(Position)

    def __init__(self, x, y):
        self.position.x = x
        self.position.y = y
예제 #5
0
class JsonTest(Entity):
    position = Component(Position)
    direction = Component(Direction)
    py_array = [1, 2, 3]
예제 #6
0
class DeepSubclassTest(BaseEntity):
    position = Component(Position)

    def test_deep_subclass(self):
        assert self.direction
        assert self.position
예제 #7
0
class BaseEntity(Entity):
    direction = Component(Direction)