diff --git a/assets/Manuel.pdf b/assets/Manuel.pdf index 90025ce..82f5f8a 100644 Binary files a/assets/Manuel.pdf and b/assets/Manuel.pdf differ diff --git a/config.json b/config.json index d3e7fad..d90c964 100644 --- a/config.json +++ b/config.json @@ -3,9 +3,8 @@ "Vie": {"Value": 3, "Available": [1,2,3,4,5,6,7,8,9,10]}, "Temps": {"Value": 180, "Available": [30,45,60,75,90,105,120,135,150,165,180,195,210,225,240,255,270,285,300,315,330,345,360,375,390,405,420,435,450,465,480,495,510,525,540,555,570,585,600]}, "Bonus de temps": {"Value": 30, "Available": [0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180]}, - "Bonus de vie": {"Value": 0, "Available": [0,1,2,3,4,5]}, - "Max. Vie": {"Value": 5, "Available": [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]}, - "Module négligeable": {"Value": 0, "Available": [0,1,2,3,4,5,6,7,8,9,10]}, - "Mode daltonien": {"Value": "Aucun", "Available": ["Protanopie", "Deutéranopie", "Tritanopie"]}, + "Malus de temps": {"Value": 0, "Available": [0,5,10,15,20,25,30,35,40,45,50,55,60]}, + "Module négli.": {"Value": 0, "Available": [0,1,2,3,4,5,6,7,8,9,10]}, + "Mode daltonien": {"Value": "Aucun", "Available": ["Aucun", "Protanopie", "Deutéranopie", "Tritanopie"]}, "Max. Score sauv.": {"Value": 30, "Available": [5,10,15,20,25,30,45,50,75,100,150,200,300]} } diff --git a/config.pickle b/config.pickle index 7fbf7e5..125445e 100644 Binary files a/config.pickle and b/config.pickle differ diff --git a/main.pyw b/main.pyw index c9cf2b9..bd1ed64 100644 --- a/main.pyw +++ b/main.pyw @@ -33,6 +33,7 @@ class AppClass(): # Classe du "moteur" du jeu MainMenu_Option = { "Lancer" : self.start, "Option" : self.settings, + "Reinit. Option.": self.confirm_reinit_option, "Quitter" : self.leave, } # On créer un dictionnaire qui associe toute les options proposé à leur fonction respective. MainMenu_Keys = list(MainMenu_Option.keys()) # On créer une liste qui ne contient que les clé du dictionnaire, permettant d'utiliser des index numériques. @@ -73,7 +74,6 @@ class AppClass(): # Classe du "moteur" du jeu # Initilisalisé tout les modules # Démmaré un chrono - def settings(self, selected = 0): # On créer un dictionnaire qui associe toute les options proposé à leur fonction respective. SettingsMenu_Keys = list(self.config.keys()) # On créer une liste qui ne contient que les clé du dictionnaire, permettant d'utiliser des index numériques. @@ -146,8 +146,24 @@ class AppClass(): # Classe du "moteur" du jeu with open(r"config.pickle","rb") as file: self.config = pickle.load(file) except: # Sinon, charge les options par défaut - with open(r"config.json","rb") as file: - self.config = json.load(file) + self.reinit_option() + + + def confirm_reinit_option(self): + classModule["display"].write("Êtes-vous sur de\nvouloir réinitialiser ?") + cancel = lambda: self.MainMenu(selected = 2) + confirm = lambda: self.reinit_option(mainmenu_return = True) + classModule["simon"].bind(UpCmd = cancel, DownCmd = cancel, LeftCmd = cancel, RightCmd = confirm) + + + def reinit_option(self, mainmenu_return = False): + with open(r"config.json","rb") as file: + self.config = json.load(file) + + with open(r"config.pickle","wb") as file: # Recréer le .pickle + pickle.dump(self.config, file) + + if mainmenu_return: self.MainMenu(selected = 2) def leave(self): diff --git a/module/button.py b/module/button.py index 51c6628..41477ec 100644 --- a/module/button.py +++ b/module/button.py @@ -18,10 +18,18 @@ class button(): } } - self.frame = LabelFrame(Fen, text = "Button") # On créer une sous-fenêtre + self.frame = LabelFrame(Fen, text = "Button", width = 180, height = 180) # On créer une sous-fenêtre self.frame.grid(row = 2, column = 3, sticky = "NEWS") # On l'affiche - self.big_but = Button(self.frame, text = "", background = "lightgray", width = 8, height = 5, relief = GROOVE) # On créer le boutton du haut + self.frame.grid_propagate(0) # Force le LabelFrame à ne pas changer de taille + + self.frame.grid_rowconfigure(1, weight = 1) # tout les objets seront centré horizontalement + self.frame.grid_columnconfigure(1, weight = 1) # tout les objets seront centré verticalement + + self.big_but = Button( self.frame, text = "Appuyez", foreground = "white", + background = "#F13308", width = 10, height = 5, + relief = GROOVE, font = ("Arial Black", 10)) # On créer le boutton du haut + self.big_but.grid(row = 1, column = 1) @@ -76,6 +84,3 @@ class button(): self.big_but.config(command = "pass") classModule["button"] = button() - -# 2 - Le bouton doit être relié à la fonction "check" -# 3 - On vérifie que la condition est respecté diff --git a/module/display.py b/module/display.py index 65c928f..82186e7 100644 --- a/module/display.py +++ b/module/display.py @@ -2,11 +2,16 @@ class display(): def __init__(self): # Cette fonction est automatiquement éxécuter lors de la création de l'objet self.defuse = True # Ce module est toujours désamorçé. - self.frame = LabelFrame(Fen, text = "Display") # On créer une sous-fenêtre - self.frame.grid(row = 1, column = 1, sticky = "NEWS") # On l'affiche + self.frame = LabelFrame(Fen, text = "Display", width = 180, height = 180) # On créer une sous-fenêtre + self.frame.grid(row = 1, column = 1) # On l'affiche - self.label = Label(self.frame, text = "chargement du chrono") - self.label.grid(row = 1, column = 1, sticky = "NEWS") + self.frame.grid_propagate(0) # Force le LabelFrame à ne pas changer de taille + self.frame.grid_rowconfigure(1, weight = 1) # Centre verticalement + self.frame.grid_columnconfigure(1, weight = 1) # Centre horizontalement + + + self.label = Label(self.frame, text = "chargement du chrono", font = ("TkDefaultFont", 15)) + self.label.grid(row = 1, column = 1) def write(self, text): self.label.config(text = text) @@ -35,7 +40,7 @@ class display(): else: self.label.config(foreground = "black", background = "SystemButtonFace") - if self.time > 0: # Vérification que le joueur n'ai pas dépassé le temps imparti + if self.time >= 0: # Vérification que le joueur n'ai pas dépassé le temps imparti self.chrono_event = Fen.after(1000, self.chrono) else: @@ -53,12 +58,12 @@ class display(): def checkDefuse(self): self.time += App.config["Bonus de temps"]["Value"] - _Stop = False + _Stop = 0 for module in classModule: if classModule[module].defuse == False: - _Stop = True + _Stop += 1 - if not(_Stop): # Si tout les modules sont désamorcé + if _Stop <= App.config["Module négli."]["Value"]: # Si tout les modules sont désamorcé Fen.after_cancel(self.chrono_event) # On désactive le chrono self.write(random.choice(["GG", "Bravo", "Félicitation"])) @@ -71,6 +76,7 @@ class display(): def PenalityLife(self): App.Life -= 1 self.PenalityAnimation = True + self.time -= App.config["Malus de temps"]["Value"] if App.Life <= 0: self.Lose() diff --git a/module/morse.py b/module/morse.py index faef28d..c059af6 100644 --- a/module/morse.py +++ b/module/morse.py @@ -23,9 +23,11 @@ class morse(): "V":"...-", "W":".--", "X":"-..-", "Y":"-.--", "Z":"--.." } - self.frame = LabelFrame(Fen, text = "Morse") # On créer une sous-fenêtre + self.frame = LabelFrame(Fen, text = "Morse", width = 180, height = 180) # On créer une sous-fenêtre self.frame.grid(row = 2, column = 2, sticky = "NEWS") # On l'affiche + self.frame.grid_propagate(0) # Force le LabelFrame à ne pas changer de taille + self.frame.grid_rowconfigure(1, weight = 1) # tout les objets seront centré horizontalement self.frame.grid_columnconfigure(1, weight = 1) # tout les objets seront centré verticalement @@ -33,7 +35,7 @@ class morse(): self.morse.grid(row = 1, column = 1) self.SelectButton = Button(self.frame, text = "", relief = RIDGE, width = 16, height = 3) - self.SelectButton.grid(row = 2, column = 1) + self.SelectButton.grid(row = 2, column = 1, sticky = "WE") self.SelectFen = Toplevel() # Créer une fenêtre secondaire. self.SelectFen.iconbitmap(PATH_ASSETS + "icon.ico") # Change l'icone diff --git a/module/safe.py b/module/safe.py index bdaf046..6ae1262 100644 --- a/module/safe.py +++ b/module/safe.py @@ -26,16 +26,22 @@ class safe(): } - self.frame = LabelFrame(Fen, text = "Safe") # On créer une sous-fenêtre + self.frame = LabelFrame(Fen, text = "Safe", width = 180, height = 180) # On créer une sous-fenêtre self.frame.grid(row = 1, column = 3, sticky = "NEWS") # On l'affiche + self.frame.grid_propagate(0) # Force le LabelFrame à ne pas changer de taille + + self.frame.grid_columnconfigure(1, weight = 1) + self.frame.grid_rowconfigure(1, weight = 1) + + self.label = Label(self.frame, text = "", background = "lightgray", relief = SUNKEN, width = 2, height = 1) # On créer la led self.label.grid(row = 1, column = 1) 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 = Button(self.frame, text = "Validé", background = "lightgreen", relief = RIDGE, width = 10) self.Valid_but.grid(row = 3, column = 1) @@ -85,10 +91,4 @@ class safe(): self.Valid_but.config(command = lambda: "pass") # Désactive le bouton - - - - # Code qui choisi des combinaisons à rentré - - classModule["safe"] = safe() diff --git a/module/simon.py b/module/simon.py index 85370f3..bf8db34 100644 --- a/module/simon.py +++ b/module/simon.py @@ -19,22 +19,28 @@ class simon(): } } - self.frame = LabelFrame(Fen, text = "Simon") # On créer une sous-fenêtre + self.reset_color() + + self.frame = LabelFrame(Fen, text = "Simon", width = 180, height = 180) # On créer une sous-fenêtre self.frame.grid(row = 2, column = 1, sticky = "NEWS") # On l'affiche + self.frame.grid_propagate(0) # Force le LabelFrame à ne pas changer de taille + + + self.dico_but = {} # On créer un dictionnaire qui va contenir les objets bouttons. - self.dico_but["Up"] = Button(self.frame, text = "", background = "lightgreen", width = 2, height = 1) # On créer le boutton du haut - self.dico_but["Up"].grid(row = 2, column = 2) + self.dico_but["Up"] = Button(self.frame, text = "", background = self.green_off_color, width = 4, height = 2) # On créer le boutton du haut + self.dico_but["Up"].grid(row = 1, column = 2) - self.dico_but["Left"] = Button(self.frame, text = "", background = "lightblue", width = 2, height = 1) # On créer le boutton à gauche - self.dico_but["Left"].grid(row = 3, column = 1) + self.dico_but["Left"] = Button(self.frame, text = "", background = self.blue_off_color, width = 4, height = 2) # On créer le boutton à gauche + self.dico_but["Left"].grid(row = 2, column = 1) - self.dico_but["Right"] = Button(self.frame, text = "", background = "indianred", width = 2, height = 1) # On créer le boutton à droite - self.dico_but["Right"].grid(row = 3, column = 3) + self.dico_but["Right"] = Button(self.frame, text = "", background = self.red_off_color, width = 4, height = 2) # On créer le boutton à droite + self.dico_but["Right"].grid(row = 2, column = 3) - self.dico_but["Down"] = Button(self.frame, text = "", background = "lightyellow", width = 2, height = 1) # On créer le boutton - self.dico_but["Down"].grid(row = 4, column = 2) + self.dico_but["Down"] = Button(self.frame, text = "", background = self.yellow_off_color, width = 4, height = 2) # On créer le boutton + self.dico_but["Down"].grid(row = 3, column = 2) def bind(self, UpCmd, DownCmd, LeftCmd, RightCmd): # Bind les touches à leur fonction associé dans les arguments @@ -44,7 +50,30 @@ class simon(): self.dico_but["Down"].config(command = DownCmd) + def reset_color(self): + self.red_off_color = "indianred" # Couleur défini, peut être modifier par le mode daltonien + self.red_lit_color = "red" + self.blue_off_color = "lightblue" + self.blue_lit_color = "blue" + self.green_off_color = "lightgreen" + self.green_lit_color = "green" + self.yellow_off_color = "lightyellow" + self.yellow_lit_color = "yellow" + def start(self): + if App.config["Mode daltonien"]["Value"] == "Protanopie": + self.red_off_color = "gray" + self.red_lit_color = "black" + + elif App.config["Mode daltonien"]["Value"] == "Deutéranopie": + self.red_off_color = "gray" + self.red_lit_color = "black" + + elif App.config["Mode daltonien"]["Value"] == "Tritanopie": + self.blue_off_color = "gray" + self.blue_lit_color = "black" + + self.defuse = False # Le module n'est pas désamorçer. self.Sequence = [] self.MaxStep = 6 @@ -80,19 +109,19 @@ class simon(): def reset_all(self): - self.dico_but["Up"].config(background = "lightgreen") - self.dico_but["Left"].config(background = "lightblue") - self.dico_but["Right"].config(background = "indianred") - self.dico_but["Down"].config(background = "lightyellow") + self.dico_but["Up"].config(background = self.green_off_color) + self.dico_but["Left"].config(background = self.blue_off_color) + self.dico_but["Right"].config(background = self.red_off_color) + self.dico_but["Down"].config(background = self.yellow_off_color) def sequence_choice(self, frame = 0): if frame <= self.Step: self.Sequence_step = self.Sequence[frame] - if self.Sequence_step == "Up": self.dico_but[self.Sequence_step].config(background = "green") - elif self.Sequence_step == "Left": self.dico_but[self.Sequence_step].config(background = "blue") - elif self.Sequence_step == "Right": self.dico_but[self.Sequence_step].config(background = "red") - elif self.Sequence_step == "Down": self.dico_but[self.Sequence_step].config(background = "yellow") + if self.Sequence_step == "Up": self.dico_but[self.Sequence_step].config(background = self.green_lit_color) + elif self.Sequence_step == "Left": self.dico_but[self.Sequence_step].config(background = self.blue_lit_color) + elif self.Sequence_step == "Right": self.dico_but[self.Sequence_step].config(background = self.red_lit_color) + elif self.Sequence_step == "Down": self.dico_but[self.Sequence_step].config(background = self.yellow_lit_color) else: frame = -1 diff --git a/module/wire.py b/module/wire.py index 24de5f8..7dff09c 100644 --- a/module/wire.py +++ b/module/wire.py @@ -26,12 +26,18 @@ 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.frame = LabelFrame(Fen, text = "Wire", width = 180, height = 180) + self.frame.grid(row = 1, column = 2) # On l'affiche + + self.frame.grid_propagate(0) # Force le LabelFrame à ne pas changer de taille + + [self.frame.grid_columnconfigure(i, weight = 1) for i in range(3)] # Centre (horizontalement) # On créer une sous-fenêtre 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.frame.grid_rowconfigure(index, weight = 1) # Centre verticalement + 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