Example #1
0
 def __init__(self,
              name,
              pos,
              sprite,
              hp,
              defense,
              res,
              max_move,
              strength,
              strategy,
              lvl=1,
              compl_sprite=None):
     Destroyable.__init__(self, name, pos, sprite, hp, defense, res)
     self.max_move = max_move
     self.on_move = []
     self.timer = TIMER
     self.strength = strength
     self.alterations = []
     self.lvl = lvl
     self.xp = 0
     self.xp_next_lvl = self.determine_xp_goal()
     self.state = 0
     self.items = []
     self.nb_items_max = NB_ITEMS_MAX
     if compl_sprite:
         compl = pg.transform.scale(
             pg.image.load(compl_sprite).convert_alpha(),
             (TILE_SIZE, TILE_SIZE))
         self.sprite.blit(compl, (0, 0))
     '''Possible strategies :
             - STATIC : Entity will never move, just attack if possible
             - PASSIVE : Entity will react to attacks, and pursue opponent if it's trying to flee
             - SEMI_ACTIVE : Entity will only move if an opponent is at reach
             - ACTIVE : Entity always move to get closer from opponents'''
     self.strategy = strategy
 def test_init_destroyable(self):
     name = 'destroyable'
     pos = (3, 2)
     sprite = 'imgs/dungeon_crawl/monster/angel.png'
     hp = 10
     defense = 4
     res = 3
     destroyable = Destroyable(name, pos, sprite, hp, defense, res)
     self.assertEqual(name, destroyable.name)
     self.assertEqual(pos, destroyable.pos)
     self.assertEqual('Destroyable', str(destroyable))
     self.assertEqual(hp, destroyable.hp_max)
     self.assertEqual(hp, destroyable.hp)
     self.assertEqual(defense, destroyable.defense)
     self.assertEqual(res, destroyable.res)
     self.assertTrue(destroyable.is_on_pos(pos))
Example #3
0
    def save(self):
        tree = Destroyable.save(self)

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

        return tree
Example #4
0
 def __init__(self,
              name,
              pos,
              sprite,
              hp,
              defense,
              res,
              max_move,
              strength,
              lvl=1):
     Destroyable.__init__(self, name, pos, sprite, hp, defense, res)
     self.max_move = max_move
     self.on_move = []
     self.timer = TIMER
     self.strength = strength
     self.alterations = []
     self.lvl = lvl
     self.xp = 0
     self.xp_next_lvl = self.determine_xp_goal()
     self.state = 0
     self.items = []
     self.nb_items_max = NB_ITEMS_MAX
Example #5
0
    def save(self):
        tree = Destroyable.save(self)

        # Save level
        level = etree.SubElement(tree, 'level')
        level.text = str(self.lvl)

        # Save exp
        exp = etree.SubElement(tree, 'exp')
        exp.text = str(self.xp)

        # Save stats
        hp_m = etree.SubElement(tree, 'hp')
        hp_m.text = str(self.hp_max)
        atk = etree.SubElement(tree, 'strength')
        atk.text = str(self.strength)
        defense = etree.SubElement(tree, 'def')
        defense.text = str(self.defense)
        res = etree.SubElement(tree, 'res')
        res.text = str(self.res)
        move = etree.SubElement(tree, 'move')
        move.text = str(self.max_move)

        return tree
 def display(self, screen):
     Destroyable.display(self, screen)
     screen.blit(CRACKED, self.pos)
 def __init__(self, name, pos, sprite, hp, defense, res):
     Destroyable.__init__(self, name, pos, sprite, hp, defense, res)
Example #8
0
 def __init__(self, name, pos, sprite, hp, defense, res):
     Destroyable.__init__(self, name, pos, sprite, hp, defense, res)
     # Useful in case of saving
     self.sprite_link = sprite
def random_destroyable_entity(min_hp=10, max_defense=10, max_res=10):
    attrs = random_destroyable_attributes(min_hp, max_defense, max_res)
    return Destroyable(attrs['name'], attrs['pos'], attrs['sprite'],
                       attrs['hp'], attrs['defense'], attrs['res'])
Example #10
0
    from src.Sidebar import Sidebar
    from src.Level import Level
    from src.StartScreen import StartScreen
    from src import LoadFromXMLManager as Loader

    pg.init()

    # Load fonts
    fonts.init_fonts()

    # Window parameters
    pg.display.set_caption("In the name of the Five Cats")
    screen = pg.display.set_mode((MAIN_WIN_WIDTH, MAIN_WIN_HEIGHT))

    # Load constant sprites
    Destroyable.init_constant_sprites()
    Breakable.init_constant_sprites()
    Movable.init_constant_sprites()
    Sidebar.init_constant_sprites()
    Level.init_constant_sprites()

    # Load some data
    races = Loader.load_races()
    classes = Loader.load_classes()
    Character.init_data(races, classes)

    clock = pg.time.Clock()

    start_screen = StartScreen(screen)

    quit_game = False