mirror of
https://framagit.org/JonathanMM/sutom.git
synced 2024-06-10 09:52:13 +02:00
Close #24 Meilleure gestion de la saisie de la première lettre
This commit is contained in:
parent
f6011d2dc1
commit
d678bfe055
|
@ -29,7 +29,7 @@ export default class Gestionnaire {
|
||||||
this._dictionnaire = new Dictionnaire();
|
this._dictionnaire = new Dictionnaire();
|
||||||
this._motATrouver = this.choisirMot();
|
this._motATrouver = this.choisirMot();
|
||||||
this._grille = new Grille(this._motATrouver.length, this._maxNbPropositions, this._motATrouver[0], this._config);
|
this._grille = new Grille(this._motATrouver.length, this._maxNbPropositions, this._motATrouver[0], this._config);
|
||||||
this._input = new Input(this, this._motATrouver.length);
|
this._input = new Input(this, this._motATrouver.length, this._motATrouver[0]);
|
||||||
this._victoirePanel = new FinDePartiePanel();
|
this._victoirePanel = new FinDePartiePanel();
|
||||||
this._propositions = new Array<string>();
|
this._propositions = new Array<string>();
|
||||||
this._resultats = new Array<Array<LettreResultat>>();
|
this._resultats = new Array<Array<LettreResultat>>();
|
||||||
|
|
|
@ -6,14 +6,16 @@ export default class Input {
|
||||||
private readonly _grille: HTMLElement;
|
private readonly _grille: HTMLElement;
|
||||||
private readonly _inputArea: HTMLElement;
|
private readonly _inputArea: HTMLElement;
|
||||||
private readonly _gestionnaire: Gestionnaire;
|
private readonly _gestionnaire: Gestionnaire;
|
||||||
|
private readonly _premiereLettre: string;
|
||||||
|
|
||||||
private _longueurMot: number;
|
private _longueurMot: number;
|
||||||
private _motSaisi: string;
|
private _motSaisi: string;
|
||||||
private _estBloque: boolean;
|
private _estBloque: boolean;
|
||||||
|
|
||||||
public constructor(gestionnaire: Gestionnaire, longueurMot: number) {
|
public constructor(gestionnaire: Gestionnaire, longueurMot: number, premiereLettre: string) {
|
||||||
this._grille = document.getElementById("grille") as HTMLElement;
|
this._grille = document.getElementById("grille") as HTMLElement;
|
||||||
this._inputArea = document.getElementById("input-area") as HTMLElement;
|
this._inputArea = document.getElementById("input-area") as HTMLElement;
|
||||||
|
this._premiereLettre = premiereLettre;
|
||||||
this._longueurMot = longueurMot;
|
this._longueurMot = longueurMot;
|
||||||
this._gestionnaire = gestionnaire;
|
this._gestionnaire = gestionnaire;
|
||||||
this._motSaisi = "";
|
this._motSaisi = "";
|
||||||
|
@ -85,6 +87,7 @@ export default class Input {
|
||||||
private saisirLettre(lettre: string): void {
|
private saisirLettre(lettre: string): void {
|
||||||
if (this._estBloque) return;
|
if (this._estBloque) return;
|
||||||
if (this._motSaisi.length >= this._longueurMot) return;
|
if (this._motSaisi.length >= this._longueurMot) return;
|
||||||
|
if (this._motSaisi.length === 0 && lettre.toUpperCase() !== this._premiereLettre) this._motSaisi += this._premiereLettre;
|
||||||
this._motSaisi += lettre;
|
this._motSaisi += lettre;
|
||||||
this._gestionnaire.actualiserAffichage(this._motSaisi);
|
this._gestionnaire.actualiserAffichage(this._motSaisi);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue