diff --git a/.idea/php.xml b/.idea/php.xml index ce2b5c9..7a32347 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -110,6 +110,7 @@ + diff --git a/.idea/portal.iml b/.idea/portal.iml index 26d5290..4f85efb 100644 --- a/.idea/portal.iml +++ b/.idea/portal.iml @@ -85,6 +85,7 @@ + diff --git a/resources/js/views/Games/GameIndex.vue b/resources/js/views/Games/GameIndex.vue index 7f43775..f632881 100644 --- a/resources/js/views/Games/GameIndex.vue +++ b/resources/js/views/Games/GameIndex.vue @@ -1,8 +1,8 @@ diff --git a/resources/js/views/Games/HangMan/Hangman.vue b/resources/js/views/Games/HangMan/Hangman.vue index 01bef92..1a19a4f 100644 --- a/resources/js/views/Games/HangMan/Hangman.vue +++ b/resources/js/views/Games/HangMan/Hangman.vue @@ -2,6 +2,11 @@

Pendu

Trouve le mot du pendu - Saisi les lettres

+
+
+ {{ key }} +
+
@@ -32,8 +37,7 @@
@@ -48,7 +52,7 @@ name: "Hangman", data: function () { return { - words: json['fruits'], + dictionary: json, letterBox: '', figureParts: [], correctLetters: [], @@ -62,14 +66,16 @@ } }, mounted() { - this.selectedWord = this.words[Math.floor(Math.random() * this.words.length)].toLowerCase() this.figureParts = this.$el.querySelectorAll('.figure-part') - this.displayWord() window.addEventListener('keyup', this.keyMessage) }, methods: { + selectWord(e) { + this.selectedWord = this.dictionary[e.target.textContent][Math.floor(Math.random() * this.dictionary[e.target.textContent].length)].toLowerCase() + this.displayWord() + this.popup = false + }, keyMessage(e) { - console.log(event.key, event.keyCode) if(e.keyCode >= 65 && e.keyCode <= 90) { const letter = e.key @@ -105,14 +111,13 @@ const innerWord = this.wordEl.replace(/|<\/span>/g, ''); - console.log('win', innerWord, this.selectedWord) if(innerWord === this.selectedWord) { this.finalMessage = 'Gagné! 😃'; this.popup = true + this.newGame() } }, updateWrongLettersEl() { - console.log('wrong', this.wrongLettersEl) this.wrongLettersEl = !this.wrongLetters ? '

Wrong

' : '' + @@ -133,16 +138,15 @@ if(this.wrongLetters.length === this.figureParts.length) { this.finalMessage = 'Perdu. 😕'; this.popup = true + this.newGame() } }, - playAgain: function () { + newGame: function () { + this.popup = true this.correctLetters.splice(0); this.wrongLetters.splice(0); - this.selectedWord = this.words[Math.floor(Math.random() * this.words.length)].toLowerCase(); - this.displayWord(); - this.updateWrongLettersEl(); - this.popup = false this.letterBox = '' + this.selectedWord = '' }, showNotification(){ this.notification = true diff --git a/resources/js/views/Games/HangMan/HangmanIndex.vue b/resources/js/views/Games/HangMan/HangmanIndex.vue index 73ee6d1..c8ea201 100644 --- a/resources/js/views/Games/HangMan/HangmanIndex.vue +++ b/resources/js/views/Games/HangMan/HangmanIndex.vue @@ -1,5 +1,5 @@