Exemple #1
0
    def test_merging_ammunition_in_pickup(self):
        """
        Same kind of ammunition should be merged when picked up
        """
        ammo_1 = (ItemBuilder()
                    .with_name('arrow')
                    .with_count(10)
                    .build())
        ammo_2 = (ItemBuilder()
                    .with_name('arrow')
                    .with_count(20)
                    .build())

        add_item(self.level, self.character.location, ammo_1)
        add_item(self.level, self.character.location, ammo_2)

        pick_up(self.character,
                ammo_1)
        pick_up(self.character,
                ammo_2)

        assert_that(len(self.character.inventory), is_(equal_to(1)))

        item = self.character.inventory[0]

        assert_that(item.ammunition_data.count, is_(equal_to(30)))
    def test_merging_ammunition_in_pickup(self):
        """
        Same kind of ammunition should be merged when picked up
        """
        ammo_1 = (ItemBuilder()
                    .with_name('arrow')
                    .with_count(10)
                    .build())
        ammo_2 = (ItemBuilder()
                    .with_name('arrow')
                    .with_count(20)
                    .build())

        add_item(self.level, self.character.location, ammo_1)
        add_item(self.level, self.character.location, ammo_2)

        pick_up(self.character,
                ammo_1)
        pick_up(self.character,
                ammo_2)

        assert_that(len(self.character.inventory), is_(equal_to(1)))

        item = self.character.inventory[0]

        assert_that(item.ammunition_data.count, is_(equal_to(30)))
    def test_picking_up(self):
        """
        Test that item can be picked up
        """
        pick_up(self.character,
                self.item)

        assert(self.item in self.character.inventory)
        assert(not self.item in get_items(self.level))
        assert(self.item.location == ())
Exemple #4
0
    def test_picking_up(self):
        """
        Test that item can be picked up
        """
        pick_up(self.character,
                self.item)

        assert(self.item in self.character.inventory)
        assert(not self.item in get_items(self.level))
        assert(self.item.location == ())
    def test_picking_up_not_correct_location(self): #pylint: disable=C0103
        """
        Test that item is not picked up from wrong location
        """
        self.character.location = (6, 6)

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

        pick_up(self.character,
                self.item)

        assert(not self.item in self.character.inventory)
        assert(self.item in get_items(self.level))
Exemple #6
0
    def test_picking_up_not_correct_location(self): #pylint: disable=C0103
        """
        Test that item is not picked up from wrong location
        """
        self.character.location = (6, 6)

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

        pick_up(self.character,
                self.item)

        assert(not self.item in self.character.inventory)
        assert(self.item in get_items(self.level))
Exemple #7
0
    def _action_a(self, key):
        """
        Process action a key

        :param key: key triggering the processing
        :type key: int
        """
        player = self.model.player
        level = player.level
        items = level.get_items_at(player.location)

        if items is not None and len(items) > 0:
            pick_up(player,
                    items[0])

        elif pyherc.vtable['\ufdd0:is-move-legal'](player, 9, 'walk', self.action_factory):
            pyherc.vtable['\ufdd0:move'](player, 9, self.action_factory)
Exemple #8
0
    def _action_a(self, key):
        """
        Process action a key

        :param key: key triggering the processing
        :type key: int
        """
        player = self.model.player
        level = player.level
        items = level.get_items_at(player.location)

        if items is not None and len(items) > 0:
            pick_up(player, items[0])

        elif pyherc.vtable['\ufdd0:is-move-legal'](player, 9, 'walk',
                                                   self.action_factory):
            pyherc.vtable['\ufdd0:move'](player, 9, self.action_factory)
Exemple #9
0
    def _action_a(self, key, modifiers):
        """
        Process action a key

        :param key: key triggering the processing
        :type key: int
        """
        player = self.model.player
        level = player.level
        items = list(get_items(level, player.location))

        if items is not None and len(items) > 0:
            pick_up(player, items[0])

        elif pyherc.vtable["\ufdd0:is-move-legal"](player, 9):
            pyherc.vtable["\ufdd0:move"](player, 9)

        elif is_dig_legal(player):
            dig(player)
Exemple #10
0
    def _action_a(self, key, modifiers):
        """
        Process action a key

        :param key: key triggering the processing
        :type key: int
        """
        player = self.model.player
        level = player.level
        items = list(get_items(level, player.location))

        if items is not None and len(items) > 0:
            pick_up(player, items[0])

        elif pyherc.vtable['\ufdd0:is-move-legal'](player, 9):
            pyherc.vtable['\ufdd0:move'](player, 9)

        elif is_dig_legal(player):
            dig(player)
Exemple #11
0
 def pick_up_item(self, item):
     """
     Pick up item
     """
     pick_up(self.character,
             item)