Beispiel #1
0
    def test_stair_linking(self):
        """
        Test that stairs can be linked
        """
        level1 = (LevelBuilder()
                  .with_size((20, 20))
                  .with_floor_tile(self.floor_rock)
                  .with_wall_tile(self.wall_empty)
                  .build())

        level2 = (LevelBuilder()
                  .with_size((20, 20))
                  .with_floor_tile(self.floor_rock)
                  .with_wall_tile(self.wall_empty)
                  .build())

        stairs1 = Portal((None, None), None)

        stairs1.icon = 'stairs'
        add_portal(level1, (10, 10), stairs1)

        stairs2 = Portal((None, None), None)
        add_portal(level2, (5, 5), stairs2, stairs1)

        assert(stairs1.level == level1)
        assert(stairs1.location == (10, 10))
        assert(stairs1.get_other_end() == stairs2)

        assert(stairs2.level == level2)
        assert(stairs2.location == (5, 5))
        assert(stairs2.get_other_end() == stairs1)

        assert get_portal(level1, (10, 10)) == stairs1
        assert get_portal(level2, (5, 5)) == stairs2
    def test_that_convoluted_case_works(self):
        """
        Test a convoluted case with 3 open areas and 2 of them being connected
        to border
        """
        self.level = (LevelBuilder().with_size((10, 10)).with_floor_tile(
            self.floor_rock).with_wall_tile(self.wall_ground).build())

        wall_tile(self.level, (2, 5), self.wall_empty)
        wall_tile(self.level, (2, 6), self.wall_empty)
        wall_tile(self.level, (2, 7), self.wall_empty)
        wall_tile(self.level, (2, 8), self.wall_empty)
        wall_tile(self.level, (2, 9), self.wall_empty)
        wall_tile(self.level, (2, 10), self.wall_empty)

        wall_tile(self.level, (5, 8), self.wall_empty)

        wall_tile(self.level, (5, 2), self.wall_empty)
        wall_tile(self.level, (6, 2), self.wall_empty)
        wall_tile(self.level, (7, 2), self.wall_empty)
        wall_tile(self.level, (8, 2), self.wall_empty)
        wall_tile(self.level, (9, 2), self.wall_empty)
        wall_tile(self.level, (10, 2), self.wall_empty)

        all_points = self.matcher.get_all_points(self.level, self.wall_empty)
        connected_points = self.matcher.get_connected_points(
            self.level, all_points[0], self.wall_empty, [])

        assert_that(self.matcher._matches(self.level), is_(equal_to(False)))
Beispiel #3
0
    def setup(self):
        """
        Setup the test case
        """
        self.action_factory = ActionFactoryBuilder().with_move_factory().build()

        self.character = (CharacterBuilder()
                                .with_action_factory(self.action_factory)
                                .build())

        self.level1 = (LevelBuilder()
                            .with_wall_at((1, 0))
                            .build())

        self.level2 = LevelBuilder().build()
        self.portal1 = Portal((None, None), None)

        self.portal1.icon = 1
        self.portal2 = Portal((None, None), None)
        self.portal2 = Portal((None, None), None)

        self.level1.add_portal(self.portal1, (5, 5))
        self.level2.add_portal(self.portal2, (10, 10), self.portal1)

        self.level1.add_creature(self.character, (5, 5))
    def setup(self):
        """
        Setup test case
        """
        self.effect = (EffectBuilder()
                       .with_duration(None)
                       .with_frequency(None)
                       .with_tick(None)
                       .build())

        self.model = Model()

        self.character1 = (CharacterBuilder()
                           .as_player_character()
                           .with_model(self.model)
                           .with_tick(10)
                           .build())

        self.character2 = (CharacterBuilder()
                           .with_model(self.model)
                           .with_tick(8)
                           .with_effect(self.effect)
                           .build())

        (LevelBuilder().with_character(self.character1, (2, 2))
                       .with_character(self.character2, (5, 5))
                       .build())

        self.model.player = self.character1
    def test_portal_has_icons(self):
        """
        Test that portal created by adder has two icons set
        One to display and another to be used by opposite end
        """
        level = (LevelBuilder().with_size((20, 20)).with_floor_tile(
            self.floor_rock).with_wall_tile(self.wall_empty).build())

        level_generator = mock()

        for loc_y in range(8, 12):
            for loc_x in range(8, 12):
                add_location_tag(level, (loc_x, loc_y), 'room')

        portal_adder = PortalAdder((1, 2), 'room', level_generator, False,
                                   self.rng)

        portal_adder.add_portal(level)

        portals = []
        for loc_y in range(8, 12):
            for loc_x in range(8, 12):
                temp = get_portal(level, (loc_x, loc_y))
                if temp:
                    portals.append(temp)
        portal = portals[0]

        assert_that(portal.icon, is_(equal_to(1)))
        assert_that(portal.other_end_icon, is_(equal_to(2)))
    def test_add_stairs_to_room(self):
        """
        Test that stairs can be added to a room
        """
        level = (LevelBuilder().with_size((20, 20)).with_floor_tile(
            self.floor_rock).with_wall_tile(self.wall_empty).build())

        for loc_y in range(8, 12):
            for loc_x in range(8, 12):
                add_location_tag(level, (loc_x, loc_y), 'room')

        portal_adder = PortalAdder((1, 2), 'room', mock(), False, self.rng)

        portal_adder.add_portal(level)

        portals = []
        for loc_y in range(8, 12):
            for loc_x in range(8, 12):
                temp = get_portal(level, (loc_x, loc_y))
                if temp:
                    portals.append(temp)

        assert_that(portals, has_length(1))
        portal = portals[0]
        assert_that(located_in_room(portal), is_(True))
 def setup(self):
     """
     Setup tests
     """
     self.level = (LevelBuilder().with_size((20, 20)).build())
     self.rng = random.Random()
     self.partitioner = grid_partitioning((20, 20), 2, 1, self.rng)
 def setup(self):
     """
     Setup the test cases
     """
     self.rng = random.Random()
     self.connector = RandomConnector(self.rng)
     self.level = (LevelBuilder().build())
    def setup(self):
        """
        Setup test cases
        """
        self.model = Model()
        self.listener = mock()
        self.level = LevelBuilder().build()

        self.model.register_event_listener(self.listener)
Beispiel #10
0
def Level():
    """
    Creates a level

    :returns: fully initialised level
    :rtype: Level
    """
    level = (LevelBuilder().build())
    return level
 def setup(self):
     """
     Setup the tests
     """
     self.wall_empty = None
     self.floor_rock = 2
     self.wall_ground = 3
     self.level = (LevelBuilder().with_size((20, 10)).with_floor_tile(
         self.floor_rock).with_wall_tile(self.wall_ground).build())
     self.matcher = MapConnectivity()
Beispiel #12
0
    def setup(self):
        """
        Setup the test case
        """
        self.level = (LevelBuilder().with_size((20, 20)).with_floor_tile(
            self.floor_rock).with_wall_tile(self.wall_ground).build())

        self.section = new_section((5, 5), (15, 15), self.level, self.rng)
        self.generator = SquareRoomGenerator(self.floor_rock, self.wall_empty,
                                             self.floor_rock, ['crypt'])
Beispiel #13
0
    def setup(self):
        """
        Setup the test case
        """
        self.floor_rock = 1
        self.wall_empty = None
        self.rng = Random()
        self.level = (LevelBuilder().with_size((60, 40)).with_floor_tile(
            self.floor_rock).with_wall_tile(self.wall_empty).build())
        add_location_tag(self.level, (10, 10), 'room')

        for x_loc in range(11, 30):
            add_location_tag(self.level, (x_loc, 10), 'corridor')

        item_config = ItemConfigurations(Random())

        item_config.add_item(
            ItemConfiguration(
                name='dagger',
                cost=2,
                weight=1,
                icons=[500],
                types=['weapon', 'light weapon', 'melee', 'simple weapon'],
                rarity='common',
                weapon_configration=WeaponConfiguration(
                    damage=[(2, 'piercing'), (2, 'slashing')],
                    critical_range=11,
                    critical_damage=2,
                    weapon_class='simple')))

        item_config.add_item(
            ItemConfiguration(name='red potion',
                              cost=150,
                              weight=1,
                              icons=[100],
                              types=['potion'],
                              rarity='rare',
                              effect_handles=[
                                  EffectHandle(trigger='on drink',
                                               effect='cure medium wounds',
                                               parameters=None,
                                               charges=1)
                              ]))

        self.item_generator = ItemGenerator(item_config)

        self.configuration = [
            item_by_name(3, 4, 'dagger'),
            item_by_type(1, 1, 'potion')
        ]

        self.item_adder = ItemAdder(self.item_generator, self.configuration,
                                    self.rng)

        self.item_adder.add_items(self.level)
    def setup(self):
        """
        Setup test cases
        """
        self.empty_wall = None
        self.empty_floor = None
        self.wall = 'wall'
        self.floor = 'floor'
        self.ornamentation = 'candles'

        self.level = (LevelBuilder().with_size((10, 10)).with_floor_tile(
            self.floor).with_wall_tile(self.empty_wall).build())
Beispiel #15
0
    def setup(self):
        """
        Setup test cases
        """
        self.level = LevelBuilder().build()

        self.character = (CharacterBuilder()
                                .with_level(self.level)
                                .with_location((5, 5))
                                .build())

        self.spell_generator = SpellGeneratorBuilder().build()
Beispiel #16
0
    def test_simple_level_creation(self):
        """
        Test that simple level creation works
        """
        level = (LevelBuilder()
                 .with_size((20, 20))
                 .with_floor_tile(self.floor_rock)
                 .with_wall_tile(self.wall_empty)
                 .build())

        assert not (level is None)
        assert(floor_tile(level, (5, 5)) == self.floor_rock)
        assert(wall_tile(level, (0, 0)) == self.wall_empty)
    def setup(self):
        """
        Setup the test case
        """
        self.character = (CharacterBuilder().with_model(Model()).build())

        self.level1 = (LevelBuilder().with_floor_tile("floor").with_wall_at(
            (1, 0)).build())

        self.level2 = (LevelBuilder().with_floor_tile("floor").build())
        self.portal1 = Portal((None, None), None)

        self.portal1.icon = 1
        self.portal2 = Portal(("stairs", "stairs"), None)
        self.portal2 = Portal(("stairs", "stairs"), None)

        add_portal(self.level1, (5, 5), self.portal1)
        add_portal(self.level2, (10, 10), self.portal2, self.portal1)

        add_character(self.level1, (5, 5), self.character)

        set_action_factory(ActionFactoryBuilder().build())
    def test_simple_path(self):
        """
        Test that a simple path can be found
        """
        level = (LevelBuilder().with_floor_tile(FLOOR_TILE).with_wall_tile(
            EMPTY_TILE).with_solid_wall_tile(WALL_TILE).build())

        path, connections, updated = a_star(
            start=(1, 1),
            goal=(5, 1),
            a_map=level,
            adjacent_nodes=free_locations_around)

        assert_that(path, contains((1, 1), (2, 1), (3, 1), (4, 1), (5, 1)))
Beispiel #19
0
    def setup(self):
        """
        Setup test cases
        """
        self.caster = (
            CharacterBuilder().with_name('Carth the Caster').build())

        self.target1 = (
            CharacterBuilder().with_name('Tammy the Target1').build())

        self.level = (LevelBuilder().with_character(
            self.caster, (10, 5)).with_character(
                self.target1, (5, 5)).with_floor_tile(FLOOR).with_wall_tile(
                    EMPTY_WALL).with_solid_wall_tile(SOLID_WALL).with_size(
                        (20, 20)).build())
Beispiel #20
0
    def test_translating_to_section(self):
        """
        Test that Connection can be translated to section coordinates
        """
        level = LevelBuilder().build()
        section = new_section((10, 10), (20, 20), level, random.Random())

        connection = Connection(connection=None,
                                location=(20, 20),
                                direction="right",
                                section=section)

        translated_connection = connection.translate_to_section()

        assert_that(translated_connection.location, is_(equal_to((10, 10))))
    def setup(self):
        """
        Setup the test case
        """
        self.wall_empty = 1
        self.level = (LevelBuilder().with_size((10, 15)).with_floor_tile(
            FLOOR_NATURAL).with_wall_tile(WALL_NATURAL).build())

        for loc_y in range(2, 8):
            for loc_x in range(2, 8):
                wall_tile(self.level, (loc_x, loc_y), self.wall_empty)

        self.config = WallBuilderDecoratorConfig(
            ['crypt'], {WALL_NATURAL: WALL_CONSTRUCTED}, self.wall_empty)

        self.decorator = WallBuilderDecorator(self.config)
    def setup(self):
        """
        Setup test case
        """
        self.model = Model()

        self.character = (CharacterBuilder().with_model(
            self.model).with_location((1, 1)).build())

        self.model.dungeon = (LevelBuilder().with_character(
            self.character).build())

        self.listener = mock()

        self.model.register_event_listener(self.listener)

        set_action_factory(ActionFactoryBuilder().build())
    def setup(self):
        """
        Test setup
        """
        self.level = LevelBuilder().build()

        self.monster_1 = (CharacterBuilder().with_name('Pete').build())

        self.monster_2 = (CharacterBuilder().with_name('Uglak').build())

        self.monster_1.artificial_intelligence = lambda: None
        self.monster_2.artificial_intelligence = lambda: None

        add_character(self.level, (5, 5), self.monster_1)
        add_character(self.level, (6, 5), self.monster_2)

        set_action_factory(ActionFactoryBuilder().build())
Beispiel #24
0
class TestStatues(object):
    """
    Test handling of statues (mainly mimicing items)
    """

    def __init__(self):
        """
        Default constructor
        """
        super(TestStatues, self).__init__()

    def test_deactivating_creature(self):
        """
        Test that activated character can deactivate
        """
        self.model = Model()

        creature = (CharacterBuilder()
                        .with_model(self.model)
                        .with_name('Mimic')
                        .build())

        item = (ItemBuilder()
                    .with_name('Chest')
                    .build())

        creature.set_mimic_item(item)

        self.model.dungeon = Dungeon()

        self.level1 = LevelBuilder().build()
        self.model.dungeon.levels = self.level1

        self.level1.add_creature(creature, self.level1.find_free_space())

        location = creature.location

        creatures = self.level1.get_creature_at(location)
        items = self.level1.get_items_at(location)
        assert_that(creatures, is_(same_instance(creature)))
        assert_that(len(items), is_(equal_to(0)))

        deactivate(self.model, creature)

        creatures = self.level1.get_creature_at(location)
        items = self.level1.get_items_at(location)
        assert_that(creatures, is_(none()))
        assert_that(len(items), is_(equal_to(1)))
    def setup(self):
        """
        Setup the test case
        """
        self.floor_rock = 1
        self.wall_ground = 2

        self.level = (LevelBuilder()
                        .with_size((10, 10))
                        .with_floor_tile(self.floor_rock)
                        .with_wall_tile(self.wall_ground)
                        .build())

        self.rng = random.Random()
        self.section = new_section((0, 0),
                                   (10, 10),
                                   self.level,
                                   self.rng)
    def setup(self):
        """
        Setup test case
        """
        self.model = mock()

        effects = get_effect_creator({'poison':
                                        {'type': Poison,
                                         'duration': 12,
                                         'frequency': 3,
                                         'tick': 3,
                                         'damage': 5,
                                         'icon': 101,
                                         'title': 'poison',
                                         'description': 'Causes damage'}})

        pyherc.vtable['\ufdd0:create-effect'] = effects
        
        set_action_factory(ActionFactoryBuilder()
                           .with_effect_factory(effects)
                           .build())

        self.attacker = (CharacterBuilder()
                         .with_location((5, 5))
                         .with_effect_handle(EffectHandleBuilder()
                                             .with_trigger('on attack hit')
                                             .with_effect('poison'))
                         .with_model(self.model)
                         .build())

        self.defender = (CharacterBuilder()
                         .with_location((5, 4))
                         .with_hit_points(50)
                         .with_model(self.model)
                         .build())

        (LevelBuilder().with_character(self.attacker)
                       .with_character(self.defender)
                       .build())
    def setup(self):
        """
        Setup test cases
        """
        self.item = (ItemBuilder()
                        .build())

        self.model = Model()

        self.level = LevelBuilder().build()

        self.character = (CharacterBuilder()
                            .with_location((5, 5))
                            .with_level(self.level)
                            .with_model(self.model)
                            .build())

        add_item(self.level, (5, 5), self.item)

        set_action_factory(ActionFactoryBuilder()
                           .with_inventory_factory()
                           .build())
    def test_going_around_wall(self):
        """
        Test that path can be found around a wall
        """
        level = (LevelBuilder().with_floor_tile(FLOOR_TILE).with_wall_tile(
            EMPTY_TILE).with_solid_wall_tile(WALL_TILE).with_wall_at(
                (12, 8)).with_wall_at((12, 9)).with_wall_at(
                    (12, 10)).with_wall_at((12, 11)).with_wall_at(
                        (12, 12)).with_size((20, 20)).build())

        path, connections, updated = a_star(
            start=(10, 10),
            goal=(15, 10),
            a_map=level,
            adjacent_nodes=free_locations_around)

        assert_that(
            path,
            is_(
                continuous_path(start=(10, 10),
                                destination=(15, 10),
                                level=level)))
Beispiel #29
0
    def setup(self):
        """
        Setup for testcases
        """

        self.model = Model()

        self.action_factory = (ActionFactoryBuilder()
                                    .with_attack_factory()
                                    .build())

        self.character1 = (CharacterBuilder()
                                .with_model(self.model)
                                .with_action_factory(self.action_factory)
                                .with_speed(1)
                                .with_tick(1)
                                .with_hit_points(10)
                                .with_attack(3)
                                .with_body(5)
                                .build())

        self.character2 = (CharacterBuilder()
                                .with_model(self.model)
                                .with_action_factory(self.action_factory)
                                .with_speed(1)
                                .with_tick(1)
                                .with_hit_points(10)
                                .with_attack(3)
                                .with_body(5)
                                .build())

        self.model.dungeon = Dungeon()
        self.level = LevelBuilder().build()

        self.model.dungeon.levels = self.level

        self.level.add_creature(self.character1, (5, 5))
        self.level.add_creature(self.character2, (6, 5))
Beispiel #30
0
    def test_deactivating_creature(self):
        """
        Test that activated character can deactivate
        """
        self.model = Model()

        creature = (CharacterBuilder()
                        .with_model(self.model)
                        .with_name('Mimic')
                        .build())

        item = (ItemBuilder()
                    .with_name('Chest')
                    .build())

        creature.set_mimic_item(item)

        self.model.dungeon = Dungeon()

        self.level1 = LevelBuilder().build()
        self.model.dungeon.levels = self.level1

        self.level1.add_creature(creature, self.level1.find_free_space())

        location = creature.location

        creatures = self.level1.get_creature_at(location)
        items = self.level1.get_items_at(location)
        assert_that(creatures, is_(same_instance(creature)))
        assert_that(len(items), is_(equal_to(0)))

        deactivate(self.model, creature)

        creatures = self.level1.get_creature_at(location)
        items = self.level1.get_items_at(location)
        assert_that(creatures, is_(none()))
        assert_that(len(items), is_(equal_to(1)))
Beispiel #31
0
    def setup(self):
        """
        Setup for testcases
        """
        self.model = Model()

        set_action_factory(ActionFactoryBuilder().build())

        self.character1 = (CharacterBuilder().with_model(
            self.model).with_hit_points(10).with_attack(3).with_body(
                5).build())

        self.effect = DamageModifier(modifier=1,
                                     damage_type='crushing',
                                     duration=None,
                                     frequency=None,
                                     tick=None,
                                     icon=101,
                                     title='Weakness against crushing',
                                     description='This character is weak')
        self.effect.multiple_allowed = True

        self.character2 = (CharacterBuilder().with_model(
            self.model).with_hit_points(10).with_attack(3).with_body(
                5).with_effect(self.effect).build())

        self.model.dungeon = Dungeon()
        self.level = (LevelBuilder().with_character(self.character1,
                                                    at_(5, 5)).with_character(
                                                        self.character2,
                                                        at_(6, 5)).build())

        self.model.dungeon.levels = self.level

        self.rng = mock()
        when(self.rng).randint(1, 6).thenReturn(1)
    def setup(self):
        """
        Setup the test case
        """
        self.level = (LevelBuilder().with_size(
            (10, 10)).with_floor_tile('floor').with_wall_tile(
                self.empty_wall).build())

        wall_tile(self.level, (1, 1), self.wall)
        wall_tile(self.level, (2, 1), self.wall)
        wall_tile(self.level, (3, 1), self.wall)

        wall_tile(self.level, (1, 2), self.wall)
        wall_tile(self.level, (1, 3), self.wall)

        wall_tile(self.level, (2, 3), self.wall)
        wall_tile(self.level, (3, 3), self.wall)

        wall_tile(self.level, (3, 2), self.wall)

        self.config = DirectionalWallDecoratorConfig(
            level_types=['crypt'],
            east_west='east-west',
            east_north='east-north',
            east_south='east-south',
            west_north='west-north',
            west_south='west-south',
            north_south='north-south',
            east_west_north='east-west-north',
            east_west_south='east-west-south',
            east_north_south='east-north-south',
            west_north_south='west-north-south',
            four_way='four-way',
            wall=self.wall)

        self.decorator = DirectionalWallDecorator(self.config)
    def setup(self):
        """
        Setup test cases
        """
        self.character = (CharacterBuilder().with_hit_points(10).build())

        self.target = (CharacterBuilder().with_hit_points(10).build())

        self.level = (LevelBuilder().build())

        add_character(self.level, (2, 2), self.character)
        add_character(self.level, (5, 2), self.target)

        bow = (ItemBuilder().with_name('bow').with_required_ammunition_type(
            'arrow').with_damage(1, 'crushing').build())
        self.arrows = (ItemBuilder().with_name('arrows').with_ammunition_type(
            'arrow').with_range_damage(3, 'piercing').with_count(10).build())

        self.character.inventory.append(bow)
        self.character.inventory.append(self.arrows)
        self.character.inventory.weapon = bow
        self.character.inventory.projectiles = self.arrows

        set_action_factory(ActionFactoryBuilder().build())
Beispiel #34
0
 def setup(self):
     """
     Setup test case
     """
     self.level = (LevelBuilder().with_size((20, 10)).build())
Beispiel #35
0
class TestMeleeCombat(object):
    """
    Class for testing melee combat related rules
    """
    def __init__(self):
        """
        Default constructor
        """
        super(TestMeleeCombat, self).__init__()
        self.level = None
        self.modle = None
        self.character1 = None
        self.character2 = None
        self.action_factory = None

    def setup(self):
        """
        Setup for testcases
        """

        self.model = Model()

        self.action_factory = (ActionFactoryBuilder()
                                    .with_attack_factory()
                                    .build())

        self.character1 = (CharacterBuilder()
                                .with_model(self.model)
                                .with_action_factory(self.action_factory)
                                .with_speed(1)
                                .with_tick(1)
                                .with_hit_points(10)
                                .with_attack(3)
                                .with_body(5)
                                .build())

        self.character2 = (CharacterBuilder()
                                .with_model(self.model)
                                .with_action_factory(self.action_factory)
                                .with_speed(1)
                                .with_tick(1)
                                .with_hit_points(10)
                                .with_attack(3)
                                .with_body(5)
                                .build())

        self.model.dungeon = Dungeon()
        self.level = LevelBuilder().build()

        self.model.dungeon.levels = self.level

        self.level.add_creature(self.character1, (5, 5))
        self.level.add_creature(self.character2, (6, 5))

    def test_get_unarmed_action(self):
        """
        Test that unarmed combat action can be generated
        """
        rng = mock()

        action = self.action_factory.get_action(AttackParameters(
                                                      self.character1,
                                                      3,
                                                      'unarmed',
                                                      rng))

        assert_that(action, is_(instance_of(AttackAction)))
        assert_that(action.attack_type, is_(equal_to('unarmed')))

    def test_events_in_unarmed_combat(self):
        """
        Test that attacking raises events
        """
        character1 = (CharacterBuilder()
                        .with_model(self.model)
                        .with_action_factory(self.action_factory)
                        .with_attack(12)
                        .with_speed(1)
                        .with_tick(0)
                        .build())

        self.level.add_creature(character1, (2, 2))

        character2 = mock(Character)
        character2.hit_points = 20
        self.level.add_creature(character2, (2, 3))

        character1.perform_attack(5)

        verify(character2).receive_event(any())
Beispiel #36
0
class TestMoving(object):
    """
    Tests for moving
    """

    def __init__(self):
        """
        Default constructor
        """
        super(TestMoving, self).__init__()
        self.action_factory = None
        self.character = None
        self.level1 = None
        self.level2 = None
        self.portal1 = None
        self.portal2 = None
        self.model = None

    def setup(self):
        """
        Setup the test case
        """
        self.action_factory = ActionFactoryBuilder().with_move_factory().build()

        self.character = (CharacterBuilder()
                                .with_action_factory(self.action_factory)
                                .build())

        self.level1 = (LevelBuilder()
                            .with_wall_at((1, 0))
                            .build())

        self.level2 = LevelBuilder().build()
        self.portal1 = Portal((None, None), None)

        self.portal1.icon = 1
        self.portal2 = Portal((None, None), None)
        self.portal2 = Portal((None, None), None)

        self.level1.add_portal(self.portal1, (5, 5))
        self.level2.add_portal(self.portal2, (10, 10), self.portal1)

        self.level1.add_creature(self.character, (5, 5))

    def test_simple_move(self):
        """
        Test that taking single step is possible
        """
        assert(self.character.location == (5, 5))

        self.character.move(3)

        assert(self.character.location == (6, 5))

    def test_walking_to_walls(self):
        """
        Test that it is not possible to walk through walls
        """
        self.character.location = (1, 1)

        self.character.move(1)

        assert(self.character.location == (1, 1))

    def test_entering_portal(self):
        """
        Test that character can change level via portal
        """
        assert(self.character.location == (5, 5))
        assert(self.character.level == self.level1)

        self.character.move(9)

        assert(self.character.location == (10, 10))
        assert(self.character.level == self.level2)

    def test_entering_portal_adds_character_to_creatures(self):
        """
        Test that entering portal will add character to the creatures list
        """
        assert self.character.level == self.level1
        assert self.character in self.level1.creatures

        self.character.move(9)

        assert self.character.level == self.level2
        assert self.character in self.level2.creatures

    def test_entering_portal_removes_character_from_old_level(self):
        """
        Test that entering portal will remove character from level
        """
        assert self.character.level == self.level1
        assert self.character in self.level1.creatures

        self.character.move(9)

        assert self.character not in self.level1.creatures

    def test_entering_non_existent_portal(self):
        """
        Test that character can not walk through floor
        """
        self.character.location = (6, 3)
        assert(self.character.level == self.level1)

        self.character.move(9)

        assert(self.character.location == (6, 3))
        assert(self.character.level == self.level1)

    def test_moving_uses_time(self):
        """
        Test that moving around uses time
        """
        tick = self.character.tick

        self.character.move(3)

        assert self.character.tick > tick