perdu !
This commit is contained in:
parent
a03e5b567a
commit
5c3957c516
23
script.js
23
script.js
@ -40,6 +40,13 @@ function nouvellePartie() {
|
|||||||
nouvelEssai()
|
nouvelEssai()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function perdu() {
|
||||||
|
if (confirm(`Perdu ! Le mot à trouver était : ${motATrouver.toUpperCase()}.\nRéessayer ?`)) nouvellePartie()
|
||||||
|
else nbEssais = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
sonPerdu.onended = perdu
|
||||||
|
|
||||||
var form
|
var form
|
||||||
var lettresATrouver
|
var lettresATrouver
|
||||||
var nbLettresBienPlacees
|
var nbLettresBienPlacees
|
||||||
@ -83,12 +90,8 @@ function nouvelEssai() {
|
|||||||
input.disabled = true
|
input.disabled = true
|
||||||
input.value = lettre
|
input.value = lettre
|
||||||
})
|
})
|
||||||
sonPerdu.onended = function() {
|
|
||||||
if (confirm(`Perdu ! Le mot à trouver était : ${motATrouver.toUpperCase()}.\nRéessayer ?`)) nouvellePartie()
|
|
||||||
else nbEssais = 0
|
|
||||||
}
|
|
||||||
if (volumeOn) play(sonPerdu)
|
if (volumeOn) play(sonPerdu)
|
||||||
else sonPerdu.onended()
|
else perdu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,10 +129,12 @@ function play(son) {
|
|||||||
son.play()
|
son.play()
|
||||||
}
|
}
|
||||||
|
|
||||||
sonMotTrouve.onended = function(event) {
|
function gagne() {
|
||||||
if (confirm("Bien joué !\nUne nouvelle partie ?")) nouvellePartie()
|
if (confirm("Bien joué !\nUne nouvelle partie ?")) nouvellePartie()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sonMotTrouve.onended = gagne
|
||||||
|
|
||||||
function onsubmit(event) {
|
function onsubmit(event) {
|
||||||
if (this.checkValidity()) {
|
if (this.checkValidity()) {
|
||||||
if (motsAutorises.includes(Array.from(form.children).map((input) => input.value).join(""))) {
|
if (motsAutorises.includes(Array.from(form.children).map((input) => input.value).join(""))) {
|
||||||
@ -157,15 +162,15 @@ function onsubmit(event) {
|
|||||||
input.classList.add("mal-placee")
|
input.classList.add("mal-placee")
|
||||||
if (volumeOn) play(sonLettreMalPlacee)
|
if (volumeOn) play(sonLettreMalPlacee)
|
||||||
}, periode * indice)
|
}, periode * indice)
|
||||||
} else {
|
} else if (volumeOn) {
|
||||||
setTimeout(() => {if (volumeOn) play(sonLettreNonTrouvee)}, periode * indice)
|
setTimeout(() => play(sonLettreNonTrouvee), periode * indice)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (nbLettresBienPlacees == nbLettres) {
|
if (nbLettresBienPlacees == nbLettres) {
|
||||||
if (volumeOn) play(sonMotTrouve)
|
if (volumeOn) play(sonMotTrouve)
|
||||||
else sonMotTrouve.onended()
|
else gagne()
|
||||||
} else nouvelEssai()
|
} else nouvelEssai()
|
||||||
}, listeATrouver.length * periode)
|
}, listeATrouver.length * periode)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user