Skip to content

Commit

Permalink
Merge pull request #87 from HE-Arc/simon-plumey-76-ajouter-indices-au…
Browse files Browse the repository at this point in the history
…-frontend

add hints
  • Loading branch information
Krucksy authored Dec 14, 2023
2 parents 0579c6f + 1273b91 commit f28e128
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion resources/js/components/comparaison.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { data } = toRefs(props);
const emit = defineEmits(['clear-history'])
const title = ref('');
const indexAlreadyHinted = ref([]);
const artist = ref({
label: 'Artist ?',
Expand Down Expand Up @@ -151,7 +152,28 @@ function updateFields(comparisonData) {
}
else
{
// TODO add clue
// add a clue
addClueToTitle()
}
}
async function addClueToTitle() {
// get random index of title
let index = Math.floor(Math.random() * title.value.length)
while (indexAlreadyHinted.value.includes(index)) {
index = Math.floor(Math.random() * title.value.length)
}
indexAlreadyHinted.value.push(index)
const answer = await axios.post('/hint', {
index: index
})
console.log(answer)
if (answer.status == 200) {
title.value = title.value.substring(0, index) + answer.data.hint + title.value.substring(index + 1)
}
saveFieldsInLocalStorage()
}
Expand Down

0 comments on commit f28e128

Please sign in to comment.