Retrait de l'effacement automatique en cas de mot invalide

This commit is contained in:
JonathanMM 2022-02-27 10:50:02 +01:00
parent fd0b0db964
commit e4aec89edd
2 changed files with 8 additions and 8 deletions

View file

@ -165,20 +165,20 @@ export default class Gestionnaire {
return composition; return composition;
} }
public verifierMot(mot: string, chargementPartie: boolean = false): void { public verifierMot(mot: string, chargementPartie: boolean = false): boolean {
mot = Dictionnaire.nettoyerMot(mot); mot = Dictionnaire.nettoyerMot(mot);
//console.debug(mot + " => " + (Dictionnaire.estMotValide(mot) ? "Oui" : "non")); //console.debug(mot + " => " + (Dictionnaire.estMotValide(mot) ? "Oui" : "non"));
if (mot.length !== this._motATrouver.length) { if (mot.length !== this._motATrouver.length) {
NotificationMessage.ajouterNotification("Le mot proposé est trop court"); NotificationMessage.ajouterNotification("Le mot proposé est trop court");
return; return false;
} }
if (mot[0] !== this._motATrouver[0]) { if (mot[0] !== this._motATrouver[0]) {
NotificationMessage.ajouterNotification("Le mot proposé doit commencer par la même lettre que le mot recherché"); NotificationMessage.ajouterNotification("Le mot proposé doit commencer par la même lettre que le mot recherché");
return; return false;
} }
if (!Dictionnaire.estMotValide(mot)) { if (!Dictionnaire.estMotValide(mot)) {
NotificationMessage.ajouterNotification("Ce mot n'est pas dans notre dictionnaire"); NotificationMessage.ajouterNotification("Ce mot n'est pas dans notre dictionnaire");
return; return false;
} }
if (!this._datePartieEnCours) this._datePartieEnCours = new Date(); if (!this._datePartieEnCours) this._datePartieEnCours = new Date();
let resultats = this.analyserMot(mot); let resultats = this.analyserMot(mot);
@ -209,6 +209,8 @@ export default class Gestionnaire {
} }
this.sauvegarderPartieEnCours(); this.sauvegarderPartieEnCours();
return true;
} }
public actualiserAffichage(mot: string): void { public actualiserAffichage(mot: string): void {

View file

@ -160,10 +160,8 @@ export default class Input {
private validerMot(): void { private validerMot(): void {
if (this._estBloque) return; if (this._estBloque) return;
let mot = this._motSaisi; let mot = this._motSaisi;
this._gestionnaire.verifierMot(mot); let isMotValide = this._gestionnaire.verifierMot(mot);
if (mot.length === this._longueurMot) { if (isMotValide) this._motSaisi = "";
this._motSaisi = "";
}
} }
private saisirLettre(lettre: string): void { private saisirLettre(lettre: string): void {