Retour à 2iia.com
Pierre, Feuille, Ciseaux
Code à copier
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Pierre, Feuille, Ciseaux</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
margin: 0;
margin-top: 30px !important;
}
@media (max-width: 768px) {
body {
flex-direction: column;
height: auto;
padding: 20px;
margin-top: 150 !important;
}
}
.game {
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 400px;
text-align: center;
}
h1 {
font-size: 24px;
color: #333 !important;
}
h2 {
font-size: 20px;
color: #555 !important;
margin-top: 20px;
}
label {
display: block;
margin: 10px 0 5px;
font-weight: bold;
color: #333 !important;
}
select {
width: 100%;
padding: 8px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
color: #333 !important;
}
input[type="submit"],
button {
background-color: rgb(46, 26, 112);
color: white;
padding: 10px;
border: none;
border-radius: 5px;
cursor: pointer;
width: 100%;
margin-top: 10px;
color: white !important;
}
input[type="submit"]:hover,
button:hover {
background-color: rgb(72, 68, 190);
color: white !important;
}
p {
margin-top: 15px;
font-size: 18px;
color: #333 !important;
}
pre {
background-color: #f8f8f8;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
text-align: left;
max-height: 200px;
overflow-y: auto;
}
code {
font-family: 'Courier New', Courier, monospace;
font-size: 14px;
}
</style>
</head>
<body>
<div class="game">
<br>
<a href="http://www.2iia.com" style="display: inline-block; background-color: #ff6200; color: white; padding: 15px 40px; border-radius: 5px; text-decoration: none; font-size: 16px; margin-bottom: 20px; text-align: center; margin: 0 auto; ">Retour à 2iia.com</a>
<br><br>
<h1>Pierre, Feuille, Ciseaux</h1>
<?php
session_start();
if (!isset($_SESSION['player_score'])) {
$_SESSION['player_score'] = 0;
$_SESSION['computer_score'] = 0;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$choices = ["pierre", "feuille", "ciseaux"];
$player_choice = $_POST["choice"];
$computer_choice = $choices[array_rand($choices)];
if ($player_choice == $computer_choice) {
$result = "Égalité !";
} elseif (
($player_choice == "pierre" && $computer_choice == "ciseaux") ||
($player_choice == "feuille" && $computer_choice == "pierre") ||
($player_choice == "ciseaux" && $computer_choice == "feuille")
) {
$result = "Vous gagnez !";
$_SESSION['player_score']++;
} else {
$result = "L'ordinateur gagne !";
$_SESSION['computer_score']++;
}
echo "<p>Vous : $player_choice | Ordinateur : $computer_choice</p>";
echo "<p>$result</p>";
echo "<p>Score - Vous : {$_SESSION['player_score']} | Ordinateur : {$_SESSION['computer_score']}</p>";
}
?>
<form method="POST" action="">
<label>Choisissez :</label>
<select name="choice" required>
<option value="pierre">Pierre</option>
<option value="feuille">Feuille</option>
<option value="ciseaux">Ciseaux</option>
</select><br>
<input type="submit" value="Jouer">
</form>
<h2>Code à copier</h2>
<pre><code id="code-to-copy"><?php echo htmlspecialchars(file_get_contents(__FILE__)); ?></code></pre>
<button onclick="copyCode()">Copier le code</button>
</div>
<script>
function copyCode() {
var code = document.getElementById("code-to-copy").innerText;
navigator.clipboard.writeText(code);
alert("Code copié !");
}
</script>
</body>
</html>