tart over function
This commit is contained in:
parent
5a5d4f5924
commit
33c48b5343
1 changed files with 32 additions and 0 deletions
32
script.js
32
script.js
|
@ -3,6 +3,7 @@ var word ="";
|
|||
const good_letter_color = "#8dc689";
|
||||
const bad_letter_color = "#e57373";
|
||||
const mid_letter_color = "#e3e466";
|
||||
const base_letter_color = "#f3d7c7" ;
|
||||
var free_box = [1,1];
|
||||
let arrWords;
|
||||
readTextFile("words.txt");
|
||||
|
@ -36,6 +37,7 @@ function update(x) {
|
|||
else {
|
||||
word += x.toLowerCase();
|
||||
free = free_box.map(num=>{return String(num)}).join("");
|
||||
console.log(free);
|
||||
document.getElementById(free).innerHTML = x;
|
||||
free_box[1]+=1;
|
||||
}
|
||||
|
@ -59,6 +61,15 @@ function Enter() {
|
|||
free_box[1]=1;
|
||||
word="";
|
||||
}
|
||||
if (verifWord() && free_box[0]==6) {
|
||||
write_result(verifLettres(word));
|
||||
if(word != reponse){
|
||||
//afficher dans p
|
||||
if (false){
|
||||
recommencer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function verifLettres() {
|
||||
|
@ -80,11 +91,13 @@ function verifLettres() {
|
|||
function write_result(verif){
|
||||
let pos = "";
|
||||
pos = free_box[0].toString();
|
||||
let good_letter = 0;
|
||||
for(let i=0; i<5; i++){
|
||||
pos = (free_box[0]).toString();
|
||||
pos = pos.concat((i+1).toString());
|
||||
if (verif[i] == 2){
|
||||
change_color_good_letter(pos);
|
||||
good_letter += 1;
|
||||
}
|
||||
else if ( verif[i]===1){
|
||||
change_color_mid_letter(pos);
|
||||
|
@ -93,6 +106,25 @@ function write_result(verif){
|
|||
change_color_bad_letter(pos);
|
||||
}
|
||||
}
|
||||
if (good_letter == 5){
|
||||
//afficher dans p
|
||||
}
|
||||
}
|
||||
|
||||
function recommencer (){
|
||||
word="";
|
||||
let coord;
|
||||
for (let i=1; i<6; i++){
|
||||
for (let j=1; j<7; j++){
|
||||
coord = j.toString().concat(i.toString());
|
||||
var case_div = document.getElementById(coord);
|
||||
console.log(coord);
|
||||
document.getElementById(coord).innerHTML = "";
|
||||
case_div.style.backgroundColor = base_letter_color;
|
||||
}
|
||||
}
|
||||
aleatoire();
|
||||
free_box = [1,1];
|
||||
}
|
||||
|
||||
function readTextFile(file) { //Merci StackOverflow
|
||||
|
|
Loading…
Reference in a new issue