def setUp(self): # Chaine de type labyrinthe : on la charge à partir du fichier with open('cartes/facile.txt','r') as fichier: strcarte = fichier.read() self.chaine = strcarte # On crée une grille à partir de la chaine self.grille = labyrinthes.chaine_to_labyrinthe(self.chaine) # On crée un labyrinthe à partir de la grille self.lab = labyrinthes.Labyrinthe('test',self.grille)
connexion_principale.bind((hote, port)) connexion_principale.listen(5) print("Le serveur écoute à présent sur le port {}".format(port)) # Charger les cartes existantes (recherche dans dossier) dans des objets Carte cartes_dispo = [] for fcarte in os.listdir('cartes'): pathcarte = os.path.join('cartes',fcarte) nomcarte = fcarte.replace('.txt','') nomcarte = nomcarte.lower() with open(pathcarte,'r') as fichier: strcarte = fichier.read() carte = labyrinthes.chaine_to_labyrinthe(strcarte) labyrinthe = labyrinthes.Labyrinthe(nomcarte,carte) cartes_dispo.append(labyrinthe) # Choix d'une carte print('Liste des cartes disponibles') for idx,carte in enumerate(cartes_dispo): print('{} - {}'.format(idx+1,carte.nom)) choix = input('Faites votre choix ') input_ok = False while input_ok == False: try: choix = int(choix)