示例#1
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)
示例#2
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)
示例#3
0
    def setup(self):
        """
        Setup the test case
        """
        self.floor_rock = 1
        self.wall_empty = 2
        self.rng = Random()
        self.level = Level((60, 40), self.floor_rock, self.wall_empty)
        self.level.set_location_type((10, 10), 'room')

        for x_loc in range(11, 30):
            self.level.set_location_type((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,
                                            critical_range = 11,
                                            critical_damage = 2,
                                            damage_types = ['piercing',
                                                            'slashing'],
                                            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 = ItemAdderConfiguration(['crypt'])
        self.configuration.add_item(min_amount = 3,
                                    max_amount = 4,
                                    name = 'dagger')
        self.configuration.add_item(min_amount = 1,
                                    max_amount = 1,
                                    type = 'potion',
                                    location = 'room')
        self.item_adder = ItemAdder(self.item_generator,
                                    self.configuration,
                                    self.rng)

        self.item_adder.add_items(self.level)