Esempio n. 1
0
    def move_hero(self, direction):
        direction = direction.lower()

        x = self.hero_position_X
        y = self.hero_position_Y

        if direction == 'up':
            x -= 1
        if direction == 'down':
            x += 1
        if direction == 'left':
            y -= 1
        if direction == 'right':
            y += 1

        if x in range(0, self.X) and y in range(0, self.Y):
            enemy = Enemy(self.level * 15, self.level * 10)
            fight = Fight(self.hero, enemy, self.tmp_map, self.X, self.Y)
            if self.tmp_map[x][y] != '#':
                self.hero.take_mana()
                if self.tmp_map[x][y] == 'T':
                    self.treasure_found()
                if self.tmp_map[x][y] == 'E':
                    enemy = Enemy(self.level * 15, self.level * 10)
                    fight.fight()
                self._update_tmp_map(x, y)
                if self.hero.can_cast():
                    fight.remote_battle(x, y)
                return True
        else:
            print('Invalid. Your move was out of the map!')

        return False