mirror of
https://framagit.org/JonathanMM/sutom.git
synced 2024-05-19 06:06:35 +02:00
Close #15 : Affichage des résultats après la fin de l'animation
This commit is contained in:
parent
58dbdbcf8c
commit
d29bb39c65
|
@ -97,13 +97,16 @@ export default class Gestionnaire {
|
||||||
let isBonneReponse = resultats.every((item) => item.statut === LettreStatut.BienPlace);
|
let isBonneReponse = resultats.every((item) => item.statut === LettreStatut.BienPlace);
|
||||||
this._propositions.push(mot);
|
this._propositions.push(mot);
|
||||||
this._resultats.push(resultats);
|
this._resultats.push(resultats);
|
||||||
this._grille.validerMot(mot, resultats, isBonneReponse, skipAnimation);
|
this._grille.validerMot(mot, resultats, isBonneReponse, skipAnimation, () => {
|
||||||
this._input.updateClavier(resultats);
|
this._input.updateClavier(resultats);
|
||||||
|
if (isBonneReponse || this._propositions.length === this._maxNbPropositions) {
|
||||||
|
this._victoirePanel.afficher(isBonneReponse, this._motATrouver);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (isBonneReponse || this._propositions.length === this._maxNbPropositions) {
|
if (isBonneReponse || this._propositions.length === this._maxNbPropositions) {
|
||||||
this._input.bloquer();
|
this._input.bloquer();
|
||||||
this._victoirePanel.genererResume(isBonneReponse, this._resultats);
|
this._victoirePanel.genererResume(isBonneReponse, this._resultats);
|
||||||
this._victoirePanel.afficher(isBonneReponse, this._motATrouver);
|
|
||||||
this.enregistrerPartieDansStats();
|
this.enregistrerPartieDansStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
20
ts/grille.ts
20
ts/grille.ts
|
@ -82,12 +82,12 @@ export default class Grille {
|
||||||
this.afficherGrille();
|
this.afficherGrille();
|
||||||
}
|
}
|
||||||
|
|
||||||
public validerMot(mot: string, resultats: Array<LettreResultat>, isBonneReponse: boolean, skipAnimation: boolean = false): void {
|
public validerMot(mot: string, resultats: Array<LettreResultat>, isBonneReponse: boolean, skipAnimation: boolean = false, endCallback?: () => void): void {
|
||||||
this.saisirMot(this._motActuel, mot);
|
this.saisirMot(this._motActuel, mot);
|
||||||
this.mettreAJourIndice(resultats);
|
this.mettreAJourIndice(resultats);
|
||||||
this._resultats.push(resultats);
|
this._resultats.push(resultats);
|
||||||
|
|
||||||
if (!skipAnimation) this.animerResultats(resultats);
|
if (!skipAnimation) this.animerResultats(resultats, endCallback);
|
||||||
|
|
||||||
if (isBonneReponse) {
|
if (isBonneReponse) {
|
||||||
this.bloquerGrille();
|
this.bloquerGrille();
|
||||||
|
@ -95,35 +95,41 @@ export default class Grille {
|
||||||
this._motActuel++;
|
this._motActuel++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skipAnimation) this.afficherGrille();
|
if (skipAnimation) {
|
||||||
|
this.afficherGrille();
|
||||||
|
if (endCallback) endCallback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private animerResultats(resultats: Array<LettreResultat>): void {
|
private animerResultats(resultats: Array<LettreResultat>, endCallback?: () => void): void {
|
||||||
let table = this._grille.getElementsByTagName("table").item(0);
|
let table = this._grille.getElementsByTagName("table").item(0);
|
||||||
if (table === null) {
|
if (table === null) {
|
||||||
this.afficherGrille();
|
this.afficherGrille();
|
||||||
|
if (endCallback) endCallback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ligne = table.getElementsByTagName("tr").item(this._motActuel);
|
let ligne = table.getElementsByTagName("tr").item(this._motActuel);
|
||||||
if (ligne === null) {
|
if (ligne === null) {
|
||||||
this.afficherGrille();
|
this.afficherGrille();
|
||||||
|
if (endCallback) endCallback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let td = ligne.getElementsByTagName("td");
|
let td = ligne.getElementsByTagName("td");
|
||||||
this.animerLettre(td, resultats, 0);
|
this.animerLettre(td, resultats, 0, endCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private animerLettre(td: HTMLCollectionOf<HTMLTableCellElement>, resultats: Array<LettreResultat>, numLettre: number): void {
|
private animerLettre(td: HTMLCollectionOf<HTMLTableCellElement>, resultats: Array<LettreResultat>, numLettre: number, endCallback?: () => void): void {
|
||||||
if (numLettre >= td.length) {
|
if (numLettre >= td.length) {
|
||||||
this.afficherGrille();
|
this.afficherGrille();
|
||||||
|
if (endCallback) endCallback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let cellule = td[numLettre];
|
let cellule = td[numLettre];
|
||||||
let resultat = resultats[numLettre];
|
let resultat = resultats[numLettre];
|
||||||
cellule.innerHTML = resultat.lettre;
|
cellule.innerHTML = resultat.lettre;
|
||||||
let callback = (() => this.animerLettre(td, resultats, numLettre + 1)).bind(this);
|
let callback = (() => this.animerLettre(td, resultats, numLettre + 1, endCallback)).bind(this);
|
||||||
switch (resultat.statut) {
|
switch (resultat.statut) {
|
||||||
case LettreStatut.BienPlace:
|
case LettreStatut.BienPlace:
|
||||||
cellule.classList.add("bien-place", "resultat");
|
cellule.classList.add("bien-place", "resultat");
|
||||||
|
|
Loading…
Reference in a new issue