Spaces:
Running

salade / index.html
tceci's picture
Add 3 files
e46793c verified
Raw History Blame Contribute Delete
23.1 kB
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Le Grand Jeu de la Salade Niçoise</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Roboto:wght@400;700&display=swap');
body {
font-family: 'Roboto', sans-serif;
background-color: #f8f4e9;
color: #333;
}
h1, h2, h3 {
font-family: 'Playfair Display', serif;
}
.ingredient-card {
transition: all 0.3s ease;
transform-style: preserve-3d;
}
.ingredient-card:hover {
transform: translateY(-5px) rotate(2deg);
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.flip-card {
perspective: 1000px;
}
.flip-card-inner {
transition: transform 0.6s;
transform-style: preserve-3d;
}
.flip-card.flipped .flip-card-inner {
transform: rotateY(180deg);
}
.flip-card-front, .flip-card-back {
backface-visibility: hidden;
}
.flip-card-back {
transform: rotateY(180deg);
}
.progress-bar {
transition: width 0.5s ease;
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
20%, 40%, 60%, 80% { transform: translateX(5px); }
}
.shake {
animation: shake 0.5s;
}
.pulse {
animation: pulse 1.5s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
.hidden {
display: none !important;
}
</style>
</head>
<body class="min-h-screen">
<!-- Introduction Screen -->
<div id="intro-screen" class="fixed inset-0 bg-blue-900 bg-opacity-90 flex flex-col items-center justify-center z-50 text-white p-6">
<div class="max-w-3xl text-center">
<h1 class="text-5xl md:text-6xl font-bold mb-6">Le Grand Jeu de la Salade Niçoise</h1>
<img src="https://images.unsplash.com/photo-1607532941433-304659e8198a?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80" alt="Salade Niçoise" class="w-full max-h-96 object-cover rounded-lg shadow-xl mb-8">
<p class="text-xl mb-8">Préparez la salade niçoise parfaite en évitant les pièges et en résolvant les énigmes culinaires !</p>
<button id="start-game" class="bg-yellow-500 hover:bg-yellow-600 text-blue-900 font-bold py-3 px-8 rounded-full text-xl transition duration-300 transform hover:scale-105">
Commencer le jeu <i class="fas fa-utensils ml-2"></i>
</button>
</div>
</div>
<!-- Main Game Screen -->
<div id="game-screen" class="hidden container mx-auto px-4 py-8">
<!-- Header -->
<header class="flex flex-col md:flex-row justify-between items-center mb-8">
<div>
<h1 class="text-3xl md:text-4xl font-bold text-blue-900">Salade Niçoise Challenge</h1>
<p class="text-gray-600">Sélectionnez les bons ingrédients pour créer la recette authentique</p>
</div>
<div class="mt-4 md:mt-0 flex items-center space-x-4">
<div class="bg-white p-3 rounded-lg shadow">
<div class="flex items-center">
<i class="fas fa-heart text-red-500 text-xl mr-2"></i>
<span id="lives" class="font-bold text-xl">3</span>
</div>
</div>
<div class="bg-white p-3 rounded-lg shadow">
<div class="flex items-center">
<i class="fas fa-star text-yellow-500 text-xl mr-2"></i>
<span id="score" class="font-bold text-xl">0</span>
</div>
</div>
</div>
</header>
<!-- Progress Bar -->
<div class="mb-8">
<div class="flex justify-between mb-2">
<span>Progression</span>
<span id="progress-text">0/5</span>
</div>
<div class="w-full bg-gray-200 rounded-full h-4">
<div id="progress-bar" class="progress-bar h-4 rounded-full bg-gradient-to-r from-blue-400 to-blue-600" style="width: 0%"></div>
</div>
</div>
<!-- Current Step -->
<div id="current-step" class="bg-white rounded-lg shadow-lg p-6 mb-8">
<h2 class="text-2xl font-bold text-blue-900 mb-4">Étape 1 : Les Légumes</h2>
<p class="mb-4">La salade niçoise authentique contient des légumes frais du sud de la France. Sélectionnez les bons ingrédients !</p>
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mt-6">
<!-- Cards will be inserted here by JavaScript -->
</div>
</div>
<!-- Riddle Section (hidden by default) -->
<div id="riddle-section" class="hidden bg-white rounded-lg shadow-lg p-6 mb-8">
<h2 class="text-2xl font-bold text-blue-900 mb-4">Énigme du Chef</h2>
<p id="riddle-text" class="mb-6 text-lg italic">Je suis rond comme la lune, rouge comme le soleil, et je donne du goût à votre salade. Qui suis-je ?</p>
<div class="grid grid-cols-2 gap-4">
<button class="riddle-option bg-gray-100 hover:bg-gray-200 p-4 rounded-lg transition">Tomate</button>
<button class="riddle-option bg-gray-100 hover:bg-gray-200 p-4 rounded-lg transition">Poivron</button>
<button class="riddle-option bg-gray-100 hover:bg-gray-200 p-4 rounded-lg transition">Oignon</button>
<button class="riddle-option bg-gray-100 hover:bg-gray-200 p-4 rounded-lg transition">Radis</button>
</div>
</div>
<!-- Trap Section (hidden by default) -->
<div id="trap-section" class="hidden bg-white rounded-lg shadow-lg p-6 mb-8">
<h2 class="text-2xl font-bold text-red-600 mb-4">Attention Piège !</h2>
<p id="trap-text" class="mb-6">Un faux pas culinaire ! Vous avez sélectionné un ingrédient non traditionnel.</p>
<div class="flex justify-center">
<button id="continue-button" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-6 rounded-full transition">
Continuer <i class="fas fa-arrow-right ml-2"></i>
</button>
</div>
</div>
<!-- Final Screen (hidden by default) -->
<div id="final-screen" class="hidden fixed inset-0 bg-blue-900 bg-opacity-90 flex flex-col items-center justify-center z-50 text-white p-6">
<div class="max-w-3xl text-center">
<h1 class="text-5xl md:text-6xl font-bold mb-6" id="final-title">Félicitations !</h1>
<img id="final-image" src="https://images.unsplash.com/photo-1607532941433-304659e8198a?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80" alt="Salade Niçoise" class="w-full max-h-96 object-cover rounded-lg shadow-xl mb-8">
<p class="text-xl mb-4" id="final-message">Vous avez réussi à préparer une délicieuse salade niçoise authentique !</p>
<p class="text-2xl font-bold mb-8">Score final: <span id="final-score">0</span> points</p>
<button id="play-again" class="bg-yellow-500 hover:bg-yellow-600 text-blue-900 font-bold py-3 px-8 rounded-full text-xl transition duration-300 transform hover:scale-105">
Rejouer <i class="fas fa-redo ml-2"></i>
</button>
</div>
</div>
</div>
<script>
// Game data
const gameData = {
steps: [
{
title: "Étape 1 : Les Légumes",
description: "La salade niçoise authentique contient des légumes frais du sud de la France. Sélectionnez les bons ingrédients !",
correct: ["Tomates", "Poivrons verts", "Oignons rouges", "Fèves"],
incorrect: ["Carottes", "Concombre", "Champignons", "Maïs"],
riddle: {
question: "Je suis rond comme la lune, rouge comme le soleil, et je donne du goût à votre salade. Qui suis-je ?",
options: ["Tomate", "Poivron", "Oignon", "Radis"],
answer: "Tomate"
}
},
{
title: "Étape 2 : Les Protéines",
description: "Choisissez les protéines traditionnelles de la salade niçoise.",
correct: ["Thon", "Œufs durs", "Anchois"],
incorrect: ["Poulet", "Jambon", "Saumon", "Tofu"],
trap: "Attention ! Le poulet n'est pas traditionnel dans la salade niçoise."
},
{
title: "Étape 3 : Les Herbes et Assaisonnements",
description: "Sélectionnez les herbes et assaisonnements authentiques.",
correct: ["Basilic", "Huile d'olive", "Ail", "Vinaigre de vin"],
incorrect: ["Persil", "Mayonnaise", "Sauce soja", "Moutarde"],
riddle: {
question: "Je suis verte et parfumée, symbole de la Provence, indispensable dans votre salade. Qui suis-je ?",
options: ["Menthe", "Basilic", "Ciboulette", "Estragon"],
answer: "Basilic"
}
},
{
title: "Étape 4 : Les Suppléments",
description: "Quels sont les suppléments traditionnels ?",
correct: ["Olives noires de Nice", "Câpres"],
incorrect: ["Croûtons", "Pommes de terre", "Avocat", "Fromage"],
trap: "Les pommes de terre sont un ajout moderne, pas traditionnel !"
},
{
title: "Étape 5 : La Présentation",
description: "Comment présenter votre salade niçoise ?",
correct: ["Ingrédients séparés", "Sans mélanger", "Dans un grand plat"],
incorrect: ["Tout mélangé", "En verrine", "Avec une sauce épaisse"],
riddle: {
question: "La vraie salade niçoise se mange sans moi, pourtant beaucoup m'ajoutent. Qui suis-je ?",
options: ["Vinaigrette", "Laitue", "Pommes de terre", "Mayonnaise"],
answer: "Pommes de terre"
}
}
],
currentStep: 0,
score: 0,
lives: 3,
progress: 0,
selectedIngredients: []
};
// DOM Elements
const introScreen = document.getElementById('intro-screen');
const gameScreen = document.getElementById('game-screen');
const startGameBtn = document.getElementById('start-game');
const currentStepEl = document.getElementById('current-step');
const riddleSection = document.getElementById('riddle-section');
const trapSection = document.getElementById('trap-section');
const finalScreen = document.getElementById('final-screen');
const playAgainBtn = document.getElementById('play-again');
const livesEl = document.getElementById('lives');
const scoreEl = document.getElementById('score');
const progressBar = document.getElementById('progress-bar');
const progressText = document.getElementById('progress-text');
const finalScoreEl = document.getElementById('final-score');
const finalTitleEl = document.getElementById('final-title');
const finalMessageEl = document.getElementById('final-message');
const finalImageEl = document.getElementById('final-image');
// Start game
startGameBtn.addEventListener('click', () => {
introScreen.classList.add('hidden');
gameScreen.classList.remove('hidden');
loadStep(0);
});
// Play again
playAgainBtn.addEventListener('click', () => {
finalScreen.classList.add('hidden');
gameData.currentStep = 0;
gameData.score = 0;
gameData.lives = 3;
gameData.progress = 0;
gameData.selectedIngredients = [];
updateScore();
loadStep(0);
});
// Load a game step
function loadStep(stepIndex) {
const step = gameData.steps[stepIndex];
// Update UI
currentStepEl.querySelector('h2').textContent = step.title;
currentStepEl.querySelector('p').textContent = step.description;
// Clear previous cards
const cardsContainer = currentStepEl.querySelector('.grid');
cardsContainer.innerHTML = '';
// Combine correct and incorrect ingredients and shuffle them
const allIngredients = [...step.correct, ...step.incorrect].sort(() => Math.random() - 0.5);
// Create cards for each ingredient
allIngredients.forEach(ingredient => {
const card = document.createElement('div');
card.className = 'flip-card ingredient-card bg-white rounded-lg shadow-md overflow-hidden cursor-pointer';
card.innerHTML = `
<div class="flip-card-inner h-full">
<div class="flip-card-front h-full flex flex-col">
<div class="h-40 bg-gray-100 flex items-center justify-center">
<i class="fas fa-question text-4xl text-gray-400"></i>
</div>
<div class="p-4 flex-grow flex items-center justify-center">
<h3 class="text-lg font-bold text-center">${ingredient}</h3>
</div>
</div>
<div class="flip-card-back h-full flex flex-col">
<div class="h-40 bg-blue-100 flex items-center justify-center">
<i class="fas fa-${step.correct.includes(ingredient) ? 'check text-green-500' : 'times text-red-500'} text-4xl"></i>
</div>
<div class="p-4 flex-grow flex items-center justify-center bg-blue-50">
<p class="text-center">${step.correct.includes(ingredient) ? 'Ingrédient traditionnel' : 'Intrus !'}</p>
</div>
</div>
</div>
`;
card.addEventListener('click', () => selectIngredient(ingredient, stepIndex, card));
cardsContainer.appendChild(card);
});
// Update progress
progressText.textContent = `${stepIndex + 1}/${gameData.steps.length}`;
progressBar.style.width = `${(stepIndex / gameData.steps.length) * 100}%`;
}
// Handle ingredient selection
function selectIngredient(ingredient, stepIndex, card) {
const step = gameData.steps[stepIndex];
// Flip the card
card.classList.add('flipped');
// Check if ingredient is correct
if (step.correct.includes(ingredient)) {
// Correct ingredient
gameData.selectedIngredients.push(ingredient);
card.classList.add('bg-green-50');
// Check if all correct ingredients are selected
if (gameData.selectedIngredients.length === step.correct.length) {
gameData.score += 10 * (stepIndex + 1);
updateScore();
// Check if there's a riddle for this step
if (step.riddle) {
setTimeout(() => showRiddle(step.riddle), 1500);
} else {
nextStep(stepIndex);
}
}
} else {
// Incorrect ingredient - trap
card.classList.add('shake', 'bg-red-50');
gameData.lives--;
updateScore();
if (gameData.lives <= 0) {
setTimeout(() => gameOver(), 1000);
} else {
setTimeout(() => showTrap(step.trap || "Cet ingrédient n'est pas traditionnel dans la salade niçoise !"), 1000);
}
}
}
// Show riddle
function showRiddle(riddle) {
currentStepEl.classList.add('hidden');
riddleSection.classList.remove('hidden');
document.getElementById('riddle-text').textContent = riddle.question;
const options = document.querySelectorAll('.riddle-option');
options.forEach((option, index) => {
option.textContent = riddle.options[index];
option.addEventListener('click', () => checkRiddleAnswer(option, riddle.answer));
});
}
// Check riddle answer
function checkRiddleAnswer(selectedOption, correctAnswer) {
const options = document.querySelectorAll('.riddle-option');
options.forEach(option => {
option.disabled = true;
if (option.textContent === correctAnswer) {
option.classList.add('bg-green-100', 'border-2', 'border-green-500');
} else {
option.classList.add('bg-gray-200');
}
});
if (selectedOption.textContent === correctAnswer) {
selectedOption.classList.add('pulse');
gameData.score += 20;
updateScore();
setTimeout(() => nextStep(gameData.currentStep), 1500);
} else {
selectedOption.classList.add('bg-red-100', 'border-2', 'border-red-500', 'shake');
gameData.lives--;
updateScore();
if (gameData.lives <= 0) {
setTimeout(() => gameOver(), 1500);
} else {
setTimeout(() => {
riddleSection.classList.add('hidden');
loadStep(gameData.currentStep);
}, 1500);
}
}
}
// Show trap
function showTrap(message) {
currentStepEl.classList.add('hidden');
trapSection.classList.remove('hidden');
document.getElementById('trap-text').textContent = message;
}
// Continue button in trap section
document.getElementById('continue-button').addEventListener('click', () => {
trapSection.classList.add('hidden');
loadStep(gameData.currentStep);
});
// Go to next step
function nextStep(currentStepIndex) {
gameData.selectedIngredients = [];
riddleSection.classList.add('hidden');
if (currentStepIndex < gameData.steps.length - 1) {
gameData.currentStep++;
loadStep(gameData.currentStep);
currentStepEl.classList.remove('hidden');
} else {
gameComplete();
}
}
// Update score and lives
function updateScore() {
scoreEl.textContent = gameData.score;
livesEl.textContent = gameData.lives;
// Update lives color based on remaining lives
if (gameData.lives <= 1) {
livesEl.classList.add('text-red-500');
livesEl.classList.remove('text-yellow-500', 'text-green-500');
} else if (gameData.lives === 2) {
livesEl.classList.add('text-yellow-500');
livesEl.classList.remove('text-red-500', 'text-green-500');
} else {
livesEl.classList.add('text-green-500');
livesEl.classList.remove('text-red-500', 'text-yellow-500');
}
}
// Game complete
function gameComplete() {
finalScreen.classList.remove('hidden');
finalScoreEl.textContent = gameData.score;
finalTitleEl.textContent = 'Félicitations !';
finalMessageEl.textContent = 'Vous avez réussi à préparer une délicieuse salade niçoise authentique !';
finalImageEl.src = 'https://images.unsplash.com/photo-1607532941433-304659e8198a?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80';
}
// Game over
function gameOver() {
finalScreen.classList.remove('hidden');
finalScoreEl.textContent = gameData.score;
finalTitleEl.textContent = 'Game Over';
finalMessageEl.textContent = 'Oh non ! Votre salade niçoise n\'est pas authentique... Essayez encore !';
finalImageEl.src = 'https://images.unsplash.com/photo-1574926054530-540480c974c3?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80';
}
</script>
<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=tceci/salade" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>