mirror of
https://github.com/FranP-code/Hangman-game-with-React.git
synced 2025-10-13 00:42:32 +00:00
bugs fix
This commit is contained in:
@@ -134,6 +134,8 @@ function App() {
|
||||
<Header
|
||||
language={language}
|
||||
|
||||
category={category}
|
||||
|
||||
displayCategories={displayCategories}
|
||||
setDisplayCategories={setDisplayCategories}
|
||||
/>
|
||||
|
||||
@@ -9,6 +9,7 @@ const BringTheWords = async (language = false, category = false, selectedWord) =
|
||||
|
||||
|
||||
console.log(category)
|
||||
console.log(language)
|
||||
|
||||
if (!language) {
|
||||
|
||||
@@ -28,8 +29,10 @@ const BringTheWords = async (language = false, category = false, selectedWord) =
|
||||
const data = collection(db, `hangman_words/${language}/${category}`)
|
||||
const result = await getDocs(data)
|
||||
|
||||
|
||||
const words = await result.docs.map(doc => doc.id)
|
||||
const word = await SelectRandomWord(await words)
|
||||
|
||||
return await word
|
||||
|
||||
} catch (error) {
|
||||
|
||||
@@ -4,6 +4,11 @@ const SelectRandomWord = (arrayWords) => {
|
||||
|
||||
Math.random() * (arrayWords.length - 0) + 0
|
||||
)
|
||||
|
||||
if (arrayWords[randomWord] === undefined) {
|
||||
|
||||
return SelectRandomWord()
|
||||
}
|
||||
|
||||
return arrayWords[randomWord]
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ const checkDefeat = (setEndOfGame, hangmanFrame, setCorrectLetters, selectedWord
|
||||
if (hangmanFrame >= 5) {
|
||||
setCorrectLetters([...selectedWord])
|
||||
setEndOfGame('Defeat')
|
||||
|
||||
navigator.keyboard.lock();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ const images = {
|
||||
countries: countries,
|
||||
países: countries,
|
||||
|
||||
pokemon: pokemon,
|
||||
pokemons: pokemon,
|
||||
|
||||
'programming languages': programmingLanguage,
|
||||
'lenguajes de programación': programmingLanguage,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, {useState} from 'react'
|
||||
|
||||
const Header = ({language, displayCategories, setDisplayCategories}) => {
|
||||
const Header = ({language, category, displayCategories, setDisplayCategories}) => {
|
||||
|
||||
const [title, setTitle] = useState('')
|
||||
const [categoryText, setCategoryText] = useState('')
|
||||
@@ -18,7 +18,18 @@ const Header = ({language, displayCategories, setDisplayCategories}) => {
|
||||
setTitle('Ahorcado')
|
||||
setCategoryText('Seleccionar categoría')
|
||||
}
|
||||
})
|
||||
|
||||
if (category) {
|
||||
|
||||
console.log(category);
|
||||
|
||||
let categoryText = category.split('')
|
||||
categoryText[0] = categoryText[0].toUpperCase()
|
||||
|
||||
setCategoryText(categoryText)
|
||||
}
|
||||
|
||||
}, [category])
|
||||
|
||||
return (
|
||||
<header>
|
||||
|
||||
Reference in New Issue
Block a user