def __init__(self, name, pos, sprite, sprite_empty, effect, times):
     Entity.__init__(self, name, pos, sprite)
     self.effect = effect
     self.times = times
     self.sprite_empty = pg.transform.scale(
         pg.image.load(sprite_empty).convert_alpha(),
         (TILE_SIZE, TILE_SIZE))
Пример #2
0
 def __init__(self, pos, sprite_close, sprite_open, potential_items):
     Entity.__init__(self, "Chest", pos, sprite_close)
     self.sprite_open_link = sprite_open
     self.sprite_close_link = sprite_close
     self.sprite_open = pg.transform.scale(
         pg.image.load(sprite_open).convert_alpha(), (TILE_SIZE, TILE_SIZE))
     self.item = Chest.determine_item(potential_items)
     self.opened = False
     self.pick_lock_initiated = False
    def __init__(self, name, pos, sprite, interaction=None):
        Entity.__init__(self, name, pos, sprite)
        self.sprite_name = sprite
        self.interaction = interaction

        self.door_sfx = pg.mixer.Sound(os.path.join('sound_fx', 'door.ogg'))
        self.gold_sfx = pg.mixer.Sound(os.path.join('sound_fx', 'trade.ogg'))
        self.talk_sfx = pg.mixer.Sound(os.path.join('sound_fx', 'talking.ogg'))
        self.inventory_sfx = pg.mixer.Sound(os.path.join('sound_fx', 'inventory.ogg'))
Пример #4
0
    def __init__(self, name, pos, sprite, hp, defense, res):
        Entity.__init__(self, name, pos, sprite)
        self.hp_max = hp
        self.hp = hp
        self.defense = defense
        self.res = res

        self.attack_sfx = pg.mixer.Sound(os.path.join('sound_fx',
                                                      'attack.ogg'))
 def test_init_entity(self):
     name = 'entity'
     pos = (3, 2)
     sprite = 'imgs/dungeon_crawl/monster/angel.png'
     entity = Entity(name, pos, sprite)
     self.assertEqual(name, entity.name)
     self.assertEqual(pos, entity.pos)
     self.assertEqual('Entity', str(entity))
     self.assertTrue(entity.is_on_pos(pos))
Пример #6
0
    def __init__(self, pos, sprite_close, sprite_open, potential_items):
        Entity.__init__(self, "Chest", pos, sprite_close)
        self.sprite_open_link = sprite_open
        self.sprite_close_link = sprite_close
        self.sprite_open = pg.transform.scale(
            pg.image.load(sprite_open).convert_alpha(), (TILE_SIZE, TILE_SIZE))
        self.item = Chest.determine_item(potential_items)
        self.opened = False
        self.pick_lock_initiated = False

        self.chest_sfx = pg.mixer.Sound(os.path.join('sound_fx', 'chest.ogg'))
    def save(self, tree_name):
        tree = Entity.save(self, tree_name)

        # Save state
        state = etree.SubElement(tree, 'state')
        state.text = str(self.interaction is None)

        # Save sprite
        sprite = etree.SubElement(tree, 'sprite')
        sprite.text = self.sprite_name

        # Save interaction
        if self.interaction:
            interaction = etree.SubElement(tree, 'interaction')
            talks = etree.SubElement(interaction, 'talks')
            for t in self.interaction['talks']:
                talk = etree.SubElement(talks, 'talk')
                talk.text = t
            if self.interaction['gold'] > 0:
                gold = etree.SubElement(interaction, 'gold')
                gold.text = str(self.interaction['gold'])
            if self.interaction['item'] is not None:
                item = etree.SubElement(interaction, 'item')
                item.text = self.interaction['item'].name

        return tree
Пример #8
0
    def save(self, tree_name):
        tree = Entity.save(self, tree_name)

        # Save current hp
        hp = etree.SubElement(tree, 'current_hp')
        hp.text = str(self.hp)

        return tree
    def test_name_format(self):
        pos = random_position()
        sprite = 'imgs/dungeon_crawl/monster/angel.png'

        name = 'test'
        entity = Entity(name, pos, sprite)
        self.assertEqual('Test', str(entity))

        name = 'Test'
        entity = Entity(name, pos, sprite)
        self.assertEqual('Test', str(entity))

        name = 'entity_test'
        entity = Entity(name, pos, sprite)
        self.assertEqual('Entity Test', str(entity))

        name = '5entity_test_01'
        entity = Entity(name, pos, sprite)
        self.assertEqual('Entity Test', str(entity))
    def save(self, tree_name):
        tree = Entity.save(self, tree_name)

        # Save remaining uses
        times = etree.SubElement(tree, 'times')
        times.text = str(self.times)

        # Save type
        nature = etree.SubElement(tree, 'type')
        nature.text = self.name

        return tree
Пример #11
0
    def test_position(self):
        name = 'test'
        sprite = 'imgs/dungeon_crawl/monster/angel.png'
        pos = random_position()
        entity = Entity(name, pos, sprite)

        self.assertTrue(entity.is_on_pos(pos))
        self.assertTrue(entity.is_on_pos((pos[0] + rd.randint(0, TILE_SIZE), pos[1] + rd.randint(0, TILE_SIZE))))
        self.assertFalse(entity.is_on_pos((pos[0] - rd.randint(0, MAIN_WIN_WIDTH), pos[1])))
        self.assertFalse(entity.is_on_pos((pos[0], pos[1] - rd.randint(0, MAIN_WIN_HEIGHT))))
Пример #12
0
    def save(self, tree_name):
        tree = Entity.save(self, tree_name)

        # Save state
        state = etree.SubElement(tree, 'state')
        state.text = str(self.opened)
        # Save sprites
        closed = etree.SubElement(tree, 'closed')
        closed_sprite = etree.SubElement(closed, 'sprite')
        closed_sprite.text = self.sprite_close_link

        opened = etree.SubElement(tree, 'opened')
        opened_sprite = etree.SubElement(opened, 'sprite')
        opened_sprite.text = self.sprite_open_link

        # Save content
        content = etree.SubElement(tree, 'contains')
        item = etree.SubElement(content, 'item')
        item.text = self.item.name

        return tree
Пример #13
0
 def __init__(self, pos_first, sprite):
     Entity.__init__(self, "Portal", pos_first, sprite)
     self.linked_to = None
Пример #14
0
 def __init__(self, name, pos, sprite, hp, defense, res):
     Entity.__init__(self, name, pos, sprite)
     self.hp_max = hp
     self.hp = hp
     self.defense = defense
     self.res = res
Пример #15
0
 def __init__(self, name, pos, sprite, interaction=None):
     Entity.__init__(self, name, pos, sprite)
     self.sprite_name = sprite
     self.interaction = interaction