From 318734b2f269b603e686caa4a8e48631c05330cc Mon Sep 17 00:00:00 2001 From: Raphael LACOTE Date: Thu, 5 Jun 2025 08:47:51 +0200 Subject: [PATCH] Combats --- public/js/home.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/public/js/home.js b/public/js/home.js index 7b1d028..2ab31ba 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -52,23 +52,26 @@ document.addEventListener('DOMContentLoaded', () => { if (type === 'combat') { const id1 = selectedCards[0].dataset.id; const id2 = selectedCards[1].dataset.id; - const t1 = 2; - const t2 = 3 + const t1 = 4; + const t2 = 6; console.log(`Combat : ${name1} contre ${name2}`); - window.location.href = `/emoji/fight/${t2}/${t1}`; + //window.location.href = `/emoji/fight/${t2}/${t1}`; //window.location.href = `/emoji/fight/${id1}/${id2}`; - /*fetch(`/pim/popim/${id}`, { - method: 'GET', + fetch(`/emoji/fight/${t2}/${t1}`, { method: 'GET', headers: { - 'Accept': 'application/json' // ou 'text/html' selon ta route - } - }) - .then(response => { + 'Accept': 'application/json' + }}).then(response => { if (!response.ok) { throw new Error(`Erreur HTTP ${response.status}`); } - return response.json(); // ou response.text() selon le retour attendu - })*/ + return response.json(); + }) + .then(data => { + console.log('Données reçues :', data); + }) + .catch(error => { + console.error('Erreur lors de la requête :', error); + }); } else if (type === 'reproduction') { console.log(`Accouplement : ${name1} et ${name2}`);