v0.9
Sauvegarde du 17/04/2020
This commit is contained in:
parent
93448b1cc1
commit
10e997b3bb
2 changed files with 122 additions and 47 deletions
|
@ -1,5 +1,31 @@
|
|||
class safe():
|
||||
def __init__(self): # Cette fonction est automatiquement éxécuter lors de la création de l'objet
|
||||
self.rules = {
|
||||
"Facile": {
|
||||
1: {1: 3, 2: 2, 3: 1, 4: 4}, # Nb Etape : {Si led X allumé : selectionné led Y, ...}
|
||||
2: {1: 4, 2: 3, 3: 2, 4: 1},
|
||||
3: {1: 3, 2: 1, 3: 4, 4: 2}
|
||||
}, "Normal": {
|
||||
1: {1: 2, 2: 1, 3: 3, 4: 4},
|
||||
2: {1: 1, 2: 2, 3: 4, 4: 3},
|
||||
3: {1: 4, 2: 3, 3: 2, 4: 1},
|
||||
4: {1: 2, 2: 4, 3: 1, 4: 3},
|
||||
5: {1: 3, 2: 1, 3: 4, 4: 2},
|
||||
6: {1: 3, 2: 2, 3: 1, 4: 4}
|
||||
}, "Difficile": {
|
||||
1: {1: 2, 2: 4, 3: 1, 4: 3},
|
||||
2: {1: 4, 2: 1, 3: 2, 4: 3},
|
||||
3: {1: 1, 2: 3, 3: 4, 4: 2},
|
||||
4: {1: 1, 2: 2, 3: 4, 4: 3},
|
||||
5: {1: 3, 2: 2, 3: 1, 4: 4},
|
||||
6: {1: 4, 2: 3, 3: 2, 4: 1},
|
||||
7: {1: 4, 2: 2, 3: 3, 4: 1},
|
||||
8: {1: 2, 2: 1, 3: 3, 4: 4},
|
||||
9: {1: 3, 2: 4, 3: 1, 4: 2}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
self.frame = LabelFrame(Fen, text = "Safe") # On créer une sous-fenêtre
|
||||
self.frame.grid(row = 1, column = 3, sticky = "NEWS") # On l'affiche
|
||||
|
||||
|
@ -9,9 +35,56 @@ class safe():
|
|||
self.scale = Scale(self.frame, from_ = 1, to_ = 4, orient = HORIZONTAL) # On créer un scroller pour sélectionner une valeur entre 1 et 4
|
||||
self.scale.grid(row = 2, column = 1)
|
||||
|
||||
self.Valid_but = Button(self.frame, text = "Validé", background = "lightgreen", relief = RIDGE)
|
||||
self.Valid_but.grid(row = 3, column = 1)
|
||||
|
||||
|
||||
def start(self):
|
||||
pass
|
||||
self.defuse = False # Le module n'est pas désamorçer.
|
||||
self.Step = 0
|
||||
self.position_curseur = 0
|
||||
|
||||
self.scale.config(command = lambda event: self.zone_choice())
|
||||
self.Valid_but.config(command = lambda: self.check())
|
||||
self.scale_zone = []
|
||||
|
||||
for _ in range(9):
|
||||
self.scale_zone.append(random.choice([1, 2, 3, 4])) # Valeur que le joueur doit sélectionner avec le curseur
|
||||
|
||||
self.zone_choice()
|
||||
|
||||
|
||||
|
||||
def zone_choice(self): # S'enclenche quand le joueur touche au curseur
|
||||
self.position_curseur = self.scale.get() # Valeur sélectionner avec le curseur
|
||||
|
||||
if self.scale_zone[self.Step] == self.position_curseur:
|
||||
self.label.config(background = "yellow")
|
||||
else:
|
||||
self.label.config(background = "lightgray")
|
||||
|
||||
def check(self):
|
||||
Difficulty = App.config["Difficulté"]["Value"]
|
||||
Step_max = len(self.rules[Difficulty])
|
||||
|
||||
if self.rules[Difficulty][self.Step + 1][self.scale_zone[self.Step]] == self.position_curseur: # Si le joueur à bien placé le curseur
|
||||
self.Step += 1
|
||||
if self.Step >= Step_max: # Si à la dernière étape
|
||||
self.defuse = True
|
||||
print("DEFUSER")
|
||||
else:
|
||||
self.zone_choice()
|
||||
|
||||
else: print("FAUX")
|
||||
# +pénaliter si le nombre d'erreur autorisé est atteint donc enlever une vie
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Code qui choisi des combinaisons à rentré
|
||||
|
||||
|
||||
|
|
|
@ -1,51 +1,5 @@
|
|||
class wire():
|
||||
def __init__(self): # Cette fonction est automatiquement éxécuter lors de la création de l'objet
|
||||
self.frame = LabelFrame(Fen, text = "Wire") # On créer une sous-fenêtre
|
||||
self.frame.grid(row = 1, column = 2, sticky = "NEWS") # On l'affiche
|
||||
|
||||
self.defuse = False # Le module n'est pas désamorçer.
|
||||
self.dico_wire = {} # On créer un dictionnaire vide qui va contenir tout les éléments
|
||||
|
||||
for index, led in enumerate("ABCDEF"): # Il y a 6 câbles différents nommé par ces lettres
|
||||
self.dico_wire[led] = {} # On les tries par leur lettre associé
|
||||
|
||||
self.dico_wire[led]["ID"] = Label(self.frame, text = led) # Affichage de la lettre du fil
|
||||
self.dico_wire[led]["ID"].grid(row = index, column = 0)
|
||||
|
||||
self.dico_wire[led]["LED"] = Label(self.frame, text = "", background = "lightgray", relief = SUNKEN, width = 2, height = 1) # Affichage de la led
|
||||
self.dico_wire[led]["LED"].grid(row = index, column = 1)
|
||||
|
||||
self.dico_wire[led]["WIRE"] = Button(self.frame, text = "---------------------", relief = FLAT) # Affichage du fil coupable
|
||||
self.dico_wire[led]["WIRE"].grid(row = index, column = 2)
|
||||
|
||||
self.dico_wire[led]["CUT"] = False
|
||||
|
||||
|
||||
def start(self): # Code qui choisi des led qui doivent s'allumé, etc...
|
||||
for wire in self.dico_wire: # Pour chaque câbles, ...
|
||||
self.dico_wire[wire]["WIRE"].config(command = lambda led = "%s" % wire: self.cut_wire(led = led)) # ... On le rend sécable.
|
||||
|
||||
self.dico_wire[wire]["LIT"] = random.choice(["Off", "On", "Blink"])
|
||||
if self.dico_wire[wire]["LIT"] == "On":
|
||||
self.dico_wire[wire]["LED"].config(background = "yellow")
|
||||
if self.dico_wire[wire]["LIT"] == "Blink":
|
||||
self.dico_wire[wire]["LED"].config(background = "green")
|
||||
|
||||
|
||||
self.wrong_cut = 0 # Compte le nombre de fils que le joueur n'aurait dû pas coupé avant
|
||||
self.check(penality = False) # On compte le nombre de fil à corrigé pour les pénalités plus tard
|
||||
|
||||
|
||||
def cut_wire(self, led): #coupe les cables
|
||||
self.dico_wire[led]["WIRE"].config(command = lambda: "pass")
|
||||
self.dico_wire[led]["WIRE"].config(text = "--------- ---------")
|
||||
|
||||
self.dico_wire[led]["CUT"] = True
|
||||
|
||||
self.check()
|
||||
|
||||
|
||||
def check(self, penality = True): # Fonction qui vérifie si les câbles ont bien été coupé selon le manuel
|
||||
self.rules = {
|
||||
"Facile": {
|
||||
"A": {"Off": False, "On": False, "Blink": True},
|
||||
|
@ -71,6 +25,54 @@ class wire():
|
|||
}
|
||||
} # Règles du manuel transcrite dans le code
|
||||
|
||||
|
||||
self.frame = LabelFrame(Fen, text = "Wire") # On créer une sous-fenêtre
|
||||
self.frame.grid(row = 1, column = 2, sticky = "NEWS") # On l'affiche
|
||||
|
||||
self.dico_wire = {} # On créer un dictionnaire vide qui va contenir tout les éléments
|
||||
|
||||
for index, led in enumerate("ABCDEF"): # Il y a 6 câbles différents nommé par ces lettres
|
||||
self.dico_wire[led] = {} # On les tries par leur lettre associé
|
||||
|
||||
self.dico_wire[led]["ID"] = Label(self.frame, text = led) # Affichage de la lettre du fil
|
||||
self.dico_wire[led]["ID"].grid(row = index, column = 0)
|
||||
|
||||
self.dico_wire[led]["LED"] = Label(self.frame, text = "", background = "lightgray", relief = SUNKEN, width = 2, height = 1) # Affichage de la led
|
||||
self.dico_wire[led]["LED"].grid(row = index, column = 1)
|
||||
|
||||
self.dico_wire[led]["WIRE"] = Button(self.frame, text = "---------------------", relief = FLAT) # Affichage du fil coupable
|
||||
self.dico_wire[led]["WIRE"].grid(row = index, column = 2)
|
||||
|
||||
self.dico_wire[led]["CUT"] = False
|
||||
|
||||
|
||||
def start(self): # Code qui choisi des led qui doivent s'allumé, etc...
|
||||
self.defuse = False # Le module n'est pas désamorçer.
|
||||
|
||||
for wire in self.dico_wire: # Pour chaque câbles, ...
|
||||
self.dico_wire[wire]["WIRE"].config(command = lambda led = "%s" % wire: self.cut_wire(led = led)) # ... On le rend sécable.
|
||||
|
||||
self.dico_wire[wire]["LIT"] = random.choice(["Off", "On", "Blink"])
|
||||
if self.dico_wire[wire]["LIT"] == "On":
|
||||
self.dico_wire[wire]["LED"].config(background = "yellow")
|
||||
if self.dico_wire[wire]["LIT"] == "Blink":
|
||||
self.dico_wire[wire]["LED"].config(background = "green")
|
||||
|
||||
|
||||
self.wrong_cut = 0 # Compte le nombre de fils que le joueur n'aurait dû pas coupé avant
|
||||
self.check(penality = False) # On compte le nombre de fil à corrigé pour les pénalités plus tard
|
||||
|
||||
|
||||
def cut_wire(self, led): #coupe les cables
|
||||
self.dico_wire[led]["WIRE"].config(command = lambda: "pass")
|
||||
self.dico_wire[led]["WIRE"].config(text = "--------- ---------")
|
||||
|
||||
self.dico_wire[led]["CUT"] = True
|
||||
|
||||
self.check()
|
||||
|
||||
|
||||
def check(self, penality = True): # Fonction qui vérifie si les câbles ont bien été coupé selon le manuel
|
||||
Difficulty = App.config["Difficulté"]["Value"]
|
||||
|
||||
self.wire_errorTotal = 0 # Compte le nombre de fils en mauvais état
|
||||
|
|
Loading…
Reference in a new issue