Spaces:
Running
Running
Add 2 files
Browse files- README.md +7 -5
- index.html +504 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: qui-fdes
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: red
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,504 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="fr">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Qui est-ce ? FDES Edition</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
.card {
|
11 |
+
perspective: 1000px;
|
12 |
+
width: 150px;
|
13 |
+
height: 200px;
|
14 |
+
cursor: pointer;
|
15 |
+
transition: transform 0.3s;
|
16 |
+
}
|
17 |
+
.card:hover {
|
18 |
+
transform: scale(1.05);
|
19 |
+
}
|
20 |
+
.card-inner {
|
21 |
+
position: relative;
|
22 |
+
width: 100%;
|
23 |
+
height: 100%;
|
24 |
+
transform-style: preserve-3d;
|
25 |
+
transition: transform 0.6s;
|
26 |
+
}
|
27 |
+
.card.flipped .card-inner {
|
28 |
+
transform: rotateY(180deg);
|
29 |
+
}
|
30 |
+
.card-front, .card-back {
|
31 |
+
position: absolute;
|
32 |
+
width: 100%;
|
33 |
+
height: 100%;
|
34 |
+
backface-visibility: hidden;
|
35 |
+
border-radius: 10px;
|
36 |
+
display: flex;
|
37 |
+
flex-direction: column;
|
38 |
+
justify-content: center;
|
39 |
+
align-items: center;
|
40 |
+
padding: 10px;
|
41 |
+
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
42 |
+
}
|
43 |
+
.card-back {
|
44 |
+
transform: rotateY(180deg);
|
45 |
+
overflow-y: auto;
|
46 |
+
}
|
47 |
+
.card-icon {
|
48 |
+
font-size: 3rem;
|
49 |
+
margin-bottom: 10px;
|
50 |
+
}
|
51 |
+
.progress-bar {
|
52 |
+
height: 10px;
|
53 |
+
background-color: #e0e0e0;
|
54 |
+
border-radius: 5px;
|
55 |
+
overflow: hidden;
|
56 |
+
}
|
57 |
+
.progress-fill {
|
58 |
+
height: 100%;
|
59 |
+
background-color: #4CAF50;
|
60 |
+
transition: width 0.3s;
|
61 |
+
}
|
62 |
+
@media (max-width: 640px) {
|
63 |
+
.card {
|
64 |
+
width: 100px;
|
65 |
+
height: 150px;
|
66 |
+
}
|
67 |
+
.card-icon {
|
68 |
+
font-size: 2rem;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
</style>
|
72 |
+
</head>
|
73 |
+
<body class="bg-gray-100 min-h-screen">
|
74 |
+
<div class="container mx-auto px-4 py-8">
|
75 |
+
<!-- Header -->
|
76 |
+
<header class="text-center mb-8">
|
77 |
+
<h1 class="text-3xl md:text-4xl font-bold text-green-800 mb-2">Qui est-ce ? FDES Edition</h1>
|
78 |
+
<p class="text-gray-600">Découvrez les impacts environnementaux des produits de construction</p>
|
79 |
+
<div class="mt-4">
|
80 |
+
<span class="inline-block bg-green-100 text-green-800 px-3 py-1 rounded-full text-sm font-semibold">
|
81 |
+
<i class="fas fa-leaf mr-1"></i> Base INIES
|
82 |
+
</span>
|
83 |
+
</div>
|
84 |
+
</header>
|
85 |
+
|
86 |
+
<!-- Game Area -->
|
87 |
+
<div class="bg-white rounded-xl shadow-lg p-6 mb-8">
|
88 |
+
<!-- Game Info -->
|
89 |
+
<div class="flex flex-wrap justify-between items-center mb-6">
|
90 |
+
<div class="mb-4 sm:mb-0">
|
91 |
+
<h2 class="text-xl font-semibold text-gray-800">Tour <span id="turn-count">1</span></h2>
|
92 |
+
<p class="text-gray-600">Cartes restantes: <span id="remaining-cards">24</span></p>
|
93 |
+
</div>
|
94 |
+
<div class="w-full sm:w-auto">
|
95 |
+
<div class="progress-bar">
|
96 |
+
<div class="progress-fill" style="width: 100%"></div>
|
97 |
+
</div>
|
98 |
+
<p class="text-right text-sm text-gray-600 mt-1">Difficulté: Moyenne</p>
|
99 |
+
</div>
|
100 |
+
</div>
|
101 |
+
|
102 |
+
<!-- Cards Grid -->
|
103 |
+
<div id="cards-container" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-4 mb-8">
|
104 |
+
<!-- Cards will be dynamically inserted here -->
|
105 |
+
</div>
|
106 |
+
|
107 |
+
<!-- Question Area -->
|
108 |
+
<div class="bg-gray-50 rounded-lg p-4">
|
109 |
+
<h3 class="text-lg font-semibold mb-3 text-gray-800">Poser une question</h3>
|
110 |
+
|
111 |
+
<div class="flex flex-wrap gap-3 mb-4">
|
112 |
+
<button class="filter-btn bg-green-100 hover:bg-green-200 text-green-800 px-4 py-2 rounded-lg transition" data-filter="category">
|
113 |
+
<i class="fas fa-tag mr-2"></i>Catégorie
|
114 |
+
</button>
|
115 |
+
<button class="filter-btn bg-blue-100 hover:bg-blue-200 text-blue-800 px-4 py-2 rounded-lg transition" data-filter="manufacturer">
|
116 |
+
<i class="fas fa-industry mr-2"></i>Fabricant
|
117 |
+
</button>
|
118 |
+
<button class="filter-btn bg-purple-100 hover:bg-purple-200 text-purple-800 px-4 py-2 rounded-lg transition" data-filter="impact">
|
119 |
+
<i class="fas fa-fire mr-2"></i>Impact environnemental
|
120 |
+
</button>
|
121 |
+
<button class="filter-btn bg-yellow-100 hover:bg-yellow-200 text-yellow-800 px-4 py-2 rounded-lg transition" data-filter="health">
|
122 |
+
<i class="fas fa-heartbeat mr-2"></i>Santé
|
123 |
+
</button>
|
124 |
+
</div>
|
125 |
+
|
126 |
+
<div id="question-options" class="hidden bg-white p-4 rounded-lg shadow-inner mb-4">
|
127 |
+
<!-- Options will be dynamically inserted here -->
|
128 |
+
</div>
|
129 |
+
|
130 |
+
<div class="flex justify-between items-center">
|
131 |
+
<button id="submit-guess" class="bg-red-500 hover:bg-red-600 text-white px-6 py-2 rounded-lg font-medium transition">
|
132 |
+
<i class="fas fa-lightbulb mr-2"></i>Faire une supposition
|
133 |
+
</button>
|
134 |
+
<button id="submit-question" class="bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded-lg font-medium transition hidden">
|
135 |
+
<i class="fas fa-question mr-2"></i>Poser la question
|
136 |
+
</button>
|
137 |
+
</div>
|
138 |
+
</div>
|
139 |
+
</div>
|
140 |
+
|
141 |
+
<!-- Game Instructions -->
|
142 |
+
<div class="bg-white rounded-xl shadow-lg p-6">
|
143 |
+
<h2 class="text-xl font-semibold mb-4 text-gray-800">Comment jouer ?</h2>
|
144 |
+
<div class="grid md:grid-cols-3 gap-4">
|
145 |
+
<div class="bg-blue-50 p-4 rounded-lg">
|
146 |
+
<div class="flex items-center mb-2">
|
147 |
+
<div class="bg-blue-100 p-2 rounded-full mr-3">
|
148 |
+
<i class="fas fa-1 text-blue-600"></i>
|
149 |
+
</div>
|
150 |
+
<h3 class="font-medium text-blue-800">Choisissez un produit</h3>
|
151 |
+
</div>
|
152 |
+
<p class="text-gray-700">Sélectionnez mentalement une carte produit sans la retourner.</p>
|
153 |
+
</div>
|
154 |
+
<div class="bg-green-50 p-4 rounded-lg">
|
155 |
+
<div class="flex items-center mb-2">
|
156 |
+
<div class="bg-green-100 p-2 rounded-full mr-3">
|
157 |
+
<i class="fas fa-2 text-green-600"></i>
|
158 |
+
</div>
|
159 |
+
<h3 class="font-medium text-green-800">Répondez aux questions</h3>
|
160 |
+
</div>
|
161 |
+
<p class="text-gray-700">L'ordinateur pose des questions pour éliminer des options.</p>
|
162 |
+
</div>
|
163 |
+
<div class="bg-purple-50 p-4 rounded-lg">
|
164 |
+
<div class="flex items-center mb-2">
|
165 |
+
<div class="bg-purple-100 p-2 rounded-full mr-3">
|
166 |
+
<i class="fas fa-3 text-purple-600"></i>
|
167 |
+
</div>
|
168 |
+
<h3 class="font-medium text-purple-800">Devinez le produit</h3>
|
169 |
+
</div>
|
170 |
+
<p class="text-gray-700">L'ordinateur tente de deviner votre produit en fonction des réponses.</p>
|
171 |
+
</div>
|
172 |
+
</div>
|
173 |
+
</div>
|
174 |
+
</div>
|
175 |
+
|
176 |
+
<script>
|
177 |
+
// Sample FDES data
|
178 |
+
const products = [
|
179 |
+
{
|
180 |
+
id: 1,
|
181 |
+
name: "Brique terre cuite",
|
182 |
+
category: "Maçonnerie",
|
183 |
+
manufacturer: "Terreal",
|
184 |
+
icon: "fas fa-home",
|
185 |
+
color: "bg-red-100",
|
186 |
+
textColor: "text-red-800",
|
187 |
+
co2: "0.8 kg CO₂ eq/m²",
|
188 |
+
health: "Aucun risque sanitaire connu",
|
189 |
+
recyclability: "90% recyclable"
|
190 |
+
},
|
191 |
+
{
|
192 |
+
id: 2,
|
193 |
+
name: "Béton cellulaire",
|
194 |
+
category: "Maçonnerie",
|
195 |
+
manufacturer: "Siporex",
|
196 |
+
icon: "fas fa-cubes",
|
197 |
+
color: "bg-gray-100",
|
198 |
+
textColor: "text-gray-800",
|
199 |
+
co2: "1.2 kg CO₂ eq/m²",
|
200 |
+
health: "Poussières irritantes",
|
201 |
+
recyclability: "70% recyclable"
|
202 |
+
},
|
203 |
+
{
|
204 |
+
id: 3,
|
205 |
+
name: "Panneau OSB",
|
206 |
+
category: "Bois",
|
207 |
+
manufacturer: "Kronoply",
|
208 |
+
icon: "fas fa-tree",
|
209 |
+
color: "bg-amber-100",
|
210 |
+
textColor: "text-amber-800",
|
211 |
+
co2: "0.5 kg CO₂ eq/m²",
|
212 |
+
health: "Colles sans formaldéhyde",
|
213 |
+
recyclability: "95% valorisable"
|
214 |
+
},
|
215 |
+
{
|
216 |
+
id: 4,
|
217 |
+
name: "Laine de verre",
|
218 |
+
category: "Isolation",
|
219 |
+
manufacturer: "Isover",
|
220 |
+
icon: "fas fa-igloo",
|
221 |
+
color: "bg-blue-100",
|
222 |
+
textColor: "text-blue-800",
|
223 |
+
co2: "1.5 kg CO₂ eq/m²",
|
224 |
+
health: "Protection respiratoire recommandée",
|
225 |
+
recyclability: "60% recyclable"
|
226 |
+
},
|
227 |
+
{
|
228 |
+
id: 5,
|
229 |
+
name: "Plaque de plâtre",
|
230 |
+
category: "Cloison",
|
231 |
+
manufacturer: "Placo",
|
232 |
+
icon: "fas fa-border-style",
|
233 |
+
color: "bg-white",
|
234 |
+
textColor: "text-gray-800",
|
235 |
+
co2: "0.7 kg CO₂ eq/m²",
|
236 |
+
health: "Poussières gypse non toxiques",
|
237 |
+
recyclability: "85% recyclable"
|
238 |
+
},
|
239 |
+
{
|
240 |
+
id: 6,
|
241 |
+
name: "Carrelage céramique",
|
242 |
+
category: "Revêtement",
|
243 |
+
manufacturer: "Novoceram",
|
244 |
+
icon: "fas fa-border-all",
|
245 |
+
color: "bg-indigo-100",
|
246 |
+
textColor: "text-indigo-800",
|
247 |
+
co2: "1.8 kg CO₂ eq/m²",
|
248 |
+
health: "Aucun risque sanitaire",
|
249 |
+
recyclability: "100% recyclable"
|
250 |
+
},
|
251 |
+
{
|
252 |
+
id: 7,
|
253 |
+
name: "Parquet chêne",
|
254 |
+
category: "Revêtement",
|
255 |
+
manufacturer: "Tarkett",
|
256 |
+
icon: "fas fa-border-all",
|
257 |
+
color: "bg-amber-100",
|
258 |
+
textColor: "text-amber-800",
|
259 |
+
co2: "0.9 kg CO₂ eq/m²",
|
260 |
+
health: "Traitement écologique",
|
261 |
+
recyclability: "100% biodégradable"
|
262 |
+
},
|
263 |
+
{
|
264 |
+
id: 8,
|
265 |
+
name: "Laine de roche",
|
266 |
+
category: "Isolation",
|
267 |
+
manufacturer: "Rockwool",
|
268 |
+
icon: "fas fa-igloo",
|
269 |
+
color: "bg-gray-100",
|
270 |
+
textColor: "text-gray-800",
|
271 |
+
co2: "1.6 kg CO₂ eq/m²",
|
272 |
+
health: "Protection respiratoire recommandée",
|
273 |
+
recyclability: "65% recyclable"
|
274 |
+
}
|
275 |
+
];
|
276 |
+
|
277 |
+
// Game state
|
278 |
+
let remainingProducts = [...products];
|
279 |
+
let currentFilter = null;
|
280 |
+
let selectedProduct = null;
|
281 |
+
let turnCount = 1;
|
282 |
+
|
283 |
+
// Initialize the game
|
284 |
+
function initGame() {
|
285 |
+
renderCards();
|
286 |
+
updateGameInfo();
|
287 |
+
|
288 |
+
// Event listeners for filter buttons
|
289 |
+
document.querySelectorAll('.filter-btn').forEach(btn => {
|
290 |
+
btn.addEventListener('click', function() {
|
291 |
+
currentFilter = this.dataset.filter;
|
292 |
+
showQuestionOptions(currentFilter);
|
293 |
+
});
|
294 |
+
});
|
295 |
+
|
296 |
+
// Event listener for submit question button
|
297 |
+
document.getElementById('submit-question').addEventListener('click', processQuestion);
|
298 |
+
|
299 |
+
// Event listener for guess button
|
300 |
+
document.getElementById('submit-guess').addEventListener('click', makeGuess);
|
301 |
+
}
|
302 |
+
|
303 |
+
// Render all product cards
|
304 |
+
function renderCards() {
|
305 |
+
const container = document.getElementById('cards-container');
|
306 |
+
container.innerHTML = '';
|
307 |
+
|
308 |
+
remainingProducts.forEach(product => {
|
309 |
+
const card = document.createElement('div');
|
310 |
+
card.className = 'card';
|
311 |
+
card.dataset.id = product.id;
|
312 |
+
|
313 |
+
card.innerHTML = `
|
314 |
+
<div class="card-inner">
|
315 |
+
<div class="card-front ${product.color} ${product.textColor}">
|
316 |
+
<div class="card-icon">
|
317 |
+
<i class="${product.icon}"></i>
|
318 |
+
</div>
|
319 |
+
<div class="text-center font-medium text-sm">${product.category}</div>
|
320 |
+
</div>
|
321 |
+
<div class="card-back bg-white">
|
322 |
+
<h4 class="font-bold text-center mb-2">${product.name}</h4>
|
323 |
+
<div class="text-xs">
|
324 |
+
<p><span class="font-semibold">Fabricant:</span> ${product.manufacturer}</p>
|
325 |
+
<p><span class="font-semibold">CO₂:</span> ${product.co2}</p>
|
326 |
+
<p><span class="font-semibold">Santé:</span> ${product.health}</p>
|
327 |
+
<p><span class="font-semibold">Recyclage:</span> ${product.recyclability}</p>
|
328 |
+
</div>
|
329 |
+
</div>
|
330 |
+
</div>
|
331 |
+
`;
|
332 |
+
|
333 |
+
container.appendChild(card);
|
334 |
+
});
|
335 |
+
}
|
336 |
+
|
337 |
+
// Update game info display
|
338 |
+
function updateGameInfo() {
|
339 |
+
document.getElementById('remaining-cards').textContent = remainingProducts.length;
|
340 |
+
document.getElementById('turn-count').textContent = turnCount;
|
341 |
+
|
342 |
+
// Update progress bar
|
343 |
+
const progress = (remainingProducts.length / products.length) * 100;
|
344 |
+
document.querySelector('.progress-fill').style.width = `${progress}%`;
|
345 |
+
}
|
346 |
+
|
347 |
+
// Show question options based on filter
|
348 |
+
function showQuestionOptions(filter) {
|
349 |
+
const optionsContainer = document.getElementById('question-options');
|
350 |
+
optionsContainer.innerHTML = '';
|
351 |
+
optionsContainer.classList.remove('hidden');
|
352 |
+
|
353 |
+
document.getElementById('submit-question').classList.remove('hidden');
|
354 |
+
|
355 |
+
let options = [];
|
356 |
+
let questionText = '';
|
357 |
+
|
358 |
+
switch(filter) {
|
359 |
+
case 'category':
|
360 |
+
questionText = 'Le produit appartient-il à la catégorie...';
|
361 |
+
options = [...new Set(products.map(p => p.category))];
|
362 |
+
break;
|
363 |
+
case 'manufacturer':
|
364 |
+
questionText = 'Le produit est-il fabriqué par...';
|
365 |
+
options = [...new Set(products.map(p => p.manufacturer))];
|
366 |
+
break;
|
367 |
+
case 'impact':
|
368 |
+
questionText = 'L\'impact CO₂ du produit est-il...';
|
369 |
+
options = ['Faible (<1 kg CO₂ eq/m²)', 'Moyen (1-1.5 kg CO₂ eq/m²)', 'Élevé (>1.5 kg CO₂ eq/m²)'];
|
370 |
+
break;
|
371 |
+
case 'health':
|
372 |
+
questionText = 'Le produit présente-t-il...';
|
373 |
+
options = ['Aucun risque sanitaire', 'Risques limités', 'Protection nécessaire'];
|
374 |
+
break;
|
375 |
+
}
|
376 |
+
|
377 |
+
optionsContainer.innerHTML = `
|
378 |
+
<h4 class="font-medium mb-3">${questionText}</h4>
|
379 |
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
380 |
+
${options.map(opt => `
|
381 |
+
<label class="flex items-center bg-gray-100 hover:bg-gray-200 rounded-lg p-3 cursor-pointer transition">
|
382 |
+
<input type="radio" name="questionOption" value="${opt}" class="mr-2">
|
383 |
+
${opt}
|
384 |
+
</label>
|
385 |
+
`).join('')}
|
386 |
+
</div>
|
387 |
+
`;
|
388 |
+
}
|
389 |
+
|
390 |
+
// Process the selected question
|
391 |
+
function processQuestion() {
|
392 |
+
const selectedOption = document.querySelector('input[name="questionOption"]:checked');
|
393 |
+
if (!selectedOption) {
|
394 |
+
alert('Veuillez sélectionner une option');
|
395 |
+
return;
|
396 |
+
}
|
397 |
+
|
398 |
+
const optionValue = selectedOption.value;
|
399 |
+
let filteredProducts = [];
|
400 |
+
|
401 |
+
switch(currentFilter) {
|
402 |
+
case 'category':
|
403 |
+
filteredProducts = remainingProducts.filter(p => p.category === optionValue);
|
404 |
+
break;
|
405 |
+
case 'manufacturer':
|
406 |
+
filteredProducts = remainingProducts.filter(p => p.manufacturer === optionValue);
|
407 |
+
break;
|
408 |
+
case 'impact':
|
409 |
+
if (optionValue.includes('Faible')) {
|
410 |
+
filteredProducts = remainingProducts.filter(p => parseFloat(p.co2) < 1);
|
411 |
+
} else if (optionValue.includes('Moyen')) {
|
412 |
+
filteredProducts = remainingProducts.filter(p => parseFloat(p.co2) >= 1 && parseFloat(p.co2) <= 1.5);
|
413 |
+
} else {
|
414 |
+
filteredProducts = remainingProducts.filter(p => parseFloat(p.co2) > 1.5);
|
415 |
+
}
|
416 |
+
break;
|
417 |
+
case 'health':
|
418 |
+
if (optionValue.includes('Aucun')) {
|
419 |
+
filteredProducts = remainingProducts.filter(p => p.health.includes('Aucun'));
|
420 |
+
} else if (optionValue.includes('limités')) {
|
421 |
+
filteredProducts = remainingProducts.filter(p => !p.health.includes('Aucun') && !p.health.includes('Protection'));
|
422 |
+
} else {
|
423 |
+
filteredProducts = remainingProducts.filter(p => p.health.includes('Protection'));
|
424 |
+
}
|
425 |
+
break;
|
426 |
+
}
|
427 |
+
|
428 |
+
// Computer makes a guess if only one product remains
|
429 |
+
if (filteredProducts.length === 1) {
|
430 |
+
setTimeout(() => {
|
431 |
+
alert(`L'ordinateur pense que vous avez sélectionné: ${filteredProducts[0].name}`);
|
432 |
+
endGame(true);
|
433 |
+
}, 500);
|
434 |
+
return;
|
435 |
+
}
|
436 |
+
|
437 |
+
// If no products match, computer learns the answer was no
|
438 |
+
if (filteredProducts.length === 0) {
|
439 |
+
alert(`Aucun produit ne correspond à cette caractéristique. L'ordinateur élimine ces options.`);
|
440 |
+
} else {
|
441 |
+
remainingProducts = filteredProducts;
|
442 |
+
turnCount++;
|
443 |
+
updateGameInfo();
|
444 |
+
renderCards();
|
445 |
+
}
|
446 |
+
|
447 |
+
// Reset question UI
|
448 |
+
document.getElementById('question-options').classList.add('hidden');
|
449 |
+
document.getElementById('submit-question').classList.add('hidden');
|
450 |
+
}
|
451 |
+
|
452 |
+
// Player makes a guess
|
453 |
+
function makeGuess() {
|
454 |
+
if (remainingProducts.length === 0) {
|
455 |
+
alert('Aucun produit restant à deviner');
|
456 |
+
return;
|
457 |
+
}
|
458 |
+
|
459 |
+
const options = remainingProducts.map(p => p.name).join('\n');
|
460 |
+
const guess = prompt(`Faites votre supposition parmi ces produits:\n\n${options}`);
|
461 |
+
|
462 |
+
if (guess) {
|
463 |
+
const found = remainingProducts.find(p => p.name === guess);
|
464 |
+
if (found) {
|
465 |
+
alert(`Correct! Vous avez deviné: ${guess}`);
|
466 |
+
endGame(false);
|
467 |
+
} else {
|
468 |
+
alert('Incorrect. Continuez à poser des questions.');
|
469 |
+
}
|
470 |
+
}
|
471 |
+
}
|
472 |
+
|
473 |
+
// End the game
|
474 |
+
function endGame(computerWon) {
|
475 |
+
if (computerWon) {
|
476 |
+
alert('L\'ordinateur a gagné ! Voulez-vous rejouer ?');
|
477 |
+
} else {
|
478 |
+
alert('Vous avez gagné ! Voulez-vous rejouer ?');
|
479 |
+
}
|
480 |
+
|
481 |
+
if (confirm('Nouvelle partie ?')) {
|
482 |
+
resetGame();
|
483 |
+
}
|
484 |
+
}
|
485 |
+
|
486 |
+
// Reset the game
|
487 |
+
function resetGame() {
|
488 |
+
remainingProducts = [...products];
|
489 |
+
turnCount = 1;
|
490 |
+
currentFilter = null;
|
491 |
+
selectedProduct = null;
|
492 |
+
|
493 |
+
document.getElementById('question-options').classList.add('hidden');
|
494 |
+
document.getElementById('submit-question').classList.add('hidden');
|
495 |
+
|
496 |
+
renderCards();
|
497 |
+
updateGameInfo();
|
498 |
+
}
|
499 |
+
|
500 |
+
// Initialize the game when page loads
|
501 |
+
window.addEventListener('DOMContentLoaded', initGame);
|
502 |
+
</script>
|
503 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=GabrielVidal/qui-fdes" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
504 |
+
</html>
|