def perdreCle(self): self.nbCle -= 1 for obj in self.getSac(): if obj.__class__.__name__ == "Clef": self.getSac().remove(obj) break Labyrinthe.getInstance().deposerObjetAleatoirement( ObjetFactoryPrincipale.getInstance().creerObjet("clef"), self.getInstance("", "", 100))
def jouer(self): j = Joueur.getInstance("👤", "X", 100) l = Labyrinthe.getInstance() j.printEnergie(sys.platform == "win32" and os.environ.get("WT_SESSION")) l.afficher() print() self.afficherCommandesDispo() while True: print("Que voulez vous faire ?") choix = input() try: self.executer(choix) break except KeyError: print( "\nCommande inconnue, les seules commandes autorisées sont : " ) self.descriptionCommande() except ValueError as e: print("\n" + e.__str__()) self.afficherCommandesDispo()
def __init__(self): Niveau.__init__(self, "niveau 1", 1, 45, 5, 30, 1, 1, 1, 1, 5, 10, 5, 1, 5, 0, Joueur("X", 100), Labyrinthe(10, 10))
def __init__(self): Niveau.__init__(self, "niveau 3", 1, 140, 15, 100, 1, 1, 1, 1, 20, 35, 25, 1, 15, 5, Joueur("X", 55), Labyrinthe(20, 20))
def __init__(self): Niveau.__init__(self, "niveau 2", 1, 75, 10, 60, 1, 1, 1, 1, 10, 25, 15, 1, 10, 3, Joueur("X", 69), Labyrinthe(20, 10))
print( " Il est téléchargeable via le lien suivant : https://www.microsoft.com/fr-fr/p/windows-terminal/9n0dx20hk701\n" ) input(" Appuyer sur 'Entrée' pour entrer dans le labyrinthe") cls() difficultyChoice = int(ConfigMenu().ask()) if difficultyChoice == 1: joueur = Joueur.getInstance("👤", "X", 70) monsterSpawnRate = 2 potionRate = 40 redbullRate = 20 l = Labyrinthe.getInstance(20, 10) elif difficultyChoice == 2: joueur = Joueur.getInstance("👤", "X", 60) monsterSpawnRate = 4 potionRate = 30 redbullRate = 15 l = Labyrinthe.getInstance(30, 20) else: joueur = Joueur.getInstance("👤", "X", 55) monsterSpawnRate = 8 potionRate = 25 redbullRate = 10 l = Labyrinthe.getInstance(30, 30) l.deposerJoueurAleatoirement(joueur) factoryObjet = ObjetFactoryPrincipale.getInstance()
class Sphinx(Personnage): """ Cette classe représente la sortie du jeu """ joueur = Joueur.getInstance("👤", "X", 100) labyrinthe = Labyrinthe.getInstance() __instance = None @staticmethod def getInstance(): if Sphinx.__instance is None: Sphinx.__instance = Sphinx() return Sphinx.__instance def __init__(self): " Constructeur. Paramètres :" self._symboleWindowsTerminal = "🦅" self._symbole = "T" self._questions = { "Quel est l'être doué de la voix qui a quatre pieds le matin, deux à midi et trois le soir ?": ["l'homme", "nous", "l'humain", "humain", "homme"], "Je ne peux pas marcher, j’ai pourtant un dos et quatre pieds. Qui suis-je ?": ["une chaise", "chaise"], """Un homme se réveille chez lui, dans le noir complet. Dans son tiroir, il y a 6 chaussettes noires, 4 blanches et deux rouges.\n Combien doit-il prendre de chaussettes au minimum pour être certain d’avoir deux chaussettes de la même couleur ?""": ["quatre", "4"], "Qu’est-ce qui est jaune avec une cape ?": ["une banane", "banane"], "je suis noir, je deviens rouge, et je finis blanc.\nQui suis-je?": ["le charbon", "charbon"], "lisez cette chaine: g-k-c-1-9-i-r": ["j'ai cassé un neuf hier"] } def description(self): """ Renvoie la description du sphinx.""" return "L'animal mythologique représentant votre liberté!!!" def parler(self, joueur): if Sphinx.joueur.getCle() >= 10: print( "*le Sphinx vous pose une question pour verifier la légitimité de votre liberté...*" ) question = random.choice(list(self._questions.keys())) reponse = input(question).lower() for response in self._questions[question]: if reponse == response: os.system('cls' if os.name == 'nt' else 'clear') print(""" .____ ._____. __ __ | | |__\_ |__ ____________/ |_ __/_ | | | || __ \_/ __ \_ __ \ __\/ __ \ | |___| || \_\ \ ___/| | \/| | \ ___/ |_______ \__||___ /\___ >__| |__| \___ > \/ \/ \/ \/ """) exit(0) print("*Le Sphinx vous vole une clé et s'envole *") print( "Sphinx-> Retourner à vos occupations, retrouver la clé volée, et revenez vers moi..." ) Sphinx.joueur.perdreCle() Sphinx.labyrinthe.deposerPersonneAleatoirement( self.getInstance(), Sphinx.joueur) Sphinx.joueur.getCaseCourante().supprimerPersonnage( self.getInstance()) Sphinx.joueur.reinitionalisationDecouverte() else: print("Il vous manque encore " + str(10 - int(Sphinx.joueur.getCle())) + "clef !!!") print("Continuer à les chercher...") input() def rencontrer(self): pass def getSymbole(self, isWindowsTerminal): if isWindowsTerminal: return self._symboleWindowsTerminal else: return self._symbole
def toutDecouvrir(self): for case in Labyrinthe.getInstance().cases: case.decouvrir()
def reinitionalisationDecouverte(self): for case in Labyrinthe.getInstance().cases: case.cacher()