Esempio n. 1
0
    def setUp(self):
        self.world = World()
        self.world.add_system(duel.ContainerSystem)
        self.world.add_system(duel.EquipmentSystem)

        room = self.world.make_entity(duel.room_factory, name="duel room", description="test room")
        self.player = self.world.make_entity(
            duel.player_factory,
            name="you",
            description="You are a test",
            location=room)
        self.wand = self.world.make_entity(
            duel.wand_factory,
            description="Surprisingly swishy.",
            location=self.player,
            name="your wand",
            owner=self.player)
        self.other_wand = self.world.make_entity(
            duel.wand_factory,
            description="Yep, that Elder Wand",
            location=room,
            name="elder wand")

        self.world.systems[duel.EquipmentSystem].auto_update = True
        self.world.systems[duel.EquipmentSystem].equip(self.player, self.wand)
        self.world.refresh()
Esempio n. 2
0
def make_toy_world():
    world = World()
    name_system = NameSystem(world)
    player = world.make_entity(Assemblage(components=[Location]))
    for direction_name, direction_shorthand in [('north', 'n'), ('south', 's'),
                                                ('east', 'e'), ('west', 'w'),
                                                ('up', 'u'), ('down', 'd')]:
        direction_entity = world.make_entity(
            Assemblage(components=[Direction, Name]), name=direction_name)
        name_system.add_name(direction_name, direction_entity)
        name_system.add_name(direction_shorthand, direction_entity)

        if direction_name == 'north':
            north = direction_entity
        if direction_name == 'south':
            south = direction_entity

    room_one = world.make_entity(room_factory,
                                 description="You are in room one.")
    room_two = world.make_entity(room_factory,
                                 description="You are in room two.")
    room_one.paths = {north: room_two}
    room_two.paths = {south: room_one}

    player.location = room_one

    return world, name_system, player, room_one, room_two
Esempio n. 3
0
    def setUp(self):
        self.world = World()
        self.player = self.world.make_entity(
            Assemblage([duel.EquipmentBearing]))

        self.wand_factory = Assemblage([duel.Equipment], equipment_type='wand')
        self.wand = self.world.make_entity(self.wand_factory)
Esempio n. 4
0
    def setUp(self):
        self.world = World()

        self.human = Entity()
        self.human.components.add(Container())

        self.food = Entity()
        self.food.components.add(Portable())
Esempio n. 5
0
def setUp():
    # Make World
    duel_world = World()
    duel_world.add_system(duel.ContainerSystem)
    duel_world.add_system(duel.EquipmentSystem)
    duel_world.add_system(NameSystem)

    # Make room
    duel_room = duel_world.make_entity(
        duel.room_factory,
        description=
        "You are in a large, dusty room, standing at one end of a long wooden table. Someone has placed a sign on an easel that says 'Duelling club'. There is a door in the southwest corner.",
        name='Duel Room')

    # Make duellers
    player = duel_world.make_entity(
        duel.player_factory,
        description=
        "You stare trepidously down the table at Justin Finch-Fletchley.",
        location=duel_room,
        name="you")

    justin = duel_world.make_entity(
        duel.player_factory,
        description=
        "Justin Finch-Fletchley stares at you bullishly from the other end of the table.",
        location=duel_room,
        name="justin finch-fletchley")

    # Make wands
    player_wand = duel_world.make_entity(duel.wand_factory,
                                         description="Surprisingly swishy.",
                                         location=player,
                                         name="your wand",
                                         owner=player)

    justin_wand = duel_world.make_entity(duel.wand_factory,
                                         description="Heavy but brittle.",
                                         location=justin,
                                         name="justin's wand",
                                         owner=justin)

    duel_world.systems[duel.EquipmentSystem].equip(player, player_wand)
    duel_world.systems[duel.EquipmentSystem].equip(justin, justin_wand)
    duel_world.systems[duel.EquipmentSystem].update()

    duel_world.systems[NameSystem].update()
    duel_world.systems[duel.ContainerSystem].update()

    parser = Parser(duel_world, duel_world.systems[NameSystem], player,
                    commands)
    parser.name_system.add_name('you', player)
    parser.name_system.add_name("my wand", player_wand)
    parser.name_system.add_name("his wand", justin_wand)
    parser.name_system.add_name("justin's wand", justin_wand)
    parser.name_system.add_name("justin", justin)

    return parser
Esempio n. 6
0
    def test_child_methods_are_decorated(self):
        world = World()
        system = System(world)

        @system
        def child_method(arg_one, kwarg_two=False):
            pass

        self.assertIn('run_hooks', system.child_method.__code__.co_names)
Esempio n. 7
0
    def setUp(self):
        self.world = World()
        bucket_factory = Assemblage(components=[Container])
        self.bucket_one = self.world.make_entity(bucket_factory)
        self.bucket_two = self.world.make_entity(bucket_factory)

        self.thing_factory = Assemblage(components=[Moveable])
        self.thing = self.world.make_entity(self.thing_factory, location=self.bucket_one)

        self.container_system = ContainerSystem(world=self.world)
Esempio n. 8
0
    def setUp(self):
        self.world = World()
        bucket_factory = Assemblage(components=[duel.Container])
        self.bucket_one = self.world.make_entity(bucket_factory)
        self.bucket_two = self.world.make_entity(bucket_factory)

        self.thing_factory = Assemblage(components=[duel.Moveable])
        self.thing = self.world.make_entity(self.thing_factory,
                                            location=self.bucket_one)
        self.bucket_one.inventory.add(self.thing)
Esempio n. 9
0
    def test_child_methods_look_for_after_hooks(self, callback_mock):
        world = World()
        system = System(world)

        @system
        def child_method(arg_one, kwarg_two=False):
            pass

        world.subscribe(system,
                        'child_method',
                        after_child_method_runs,
                        after=True)

        system.child_method('first_arg', kwarg_two='keyword_arg')

        callback_mock.assert_called_once_with('first_arg',
                                              kwarg_two='keyword_arg')
Esempio n. 10
0
 def setUp(self):
     self.world = World()
    def setUp(self):
        self.world = World()
        self.item_factory = Assemblage(components=[Name])
        self.item = self.world.make_entity(self.item_factory, name='item one')

        self.name_system = NameSystem(world=self.world)