correction-ulysse (#2)

# Correction pour les TP1 TP2 et TP3

Je n'ai pas testé la connexion à la DB pour le moment car je ne peux pas me co sur https://dwarves.iut-fbleau.fr/phpmyadmin

Co-authored-by: JARNOUEN DE VILLARTAY Ulysse (SAFRAN AIRCRAFT ENGINES) <ulysse.jarnouen-de-villartay@safrangroup.com>
Reviewed-on: monnerat/web_2025#2
This commit is contained in:
2026-04-15 15:34:46 +02:00
parent 045ec81ae2
commit a4580652f8
22 changed files with 692 additions and 215 deletions
+3
View File
@@ -8,3 +8,6 @@ color:#2E8B57;
.Loss{
color:#FF6347;
}
.Draw{
color:#DAA520;
}
+29 -14
View File
@@ -1,20 +1,35 @@
<?php
$images = ["rock.png","paper.png","scissors.png"];
$isPlaying = true;
$ROCK = 0;
$PAPER = 1;
$SCISSORS = 2;
$playerChoice = 0;
$computerChoice = 1;
$images = ["rock.png", "paper.png", "scissors.png"];
$rules = [
$ROCK => [$ROCK => "Draw", $PAPER => "Loss", $SCISSORS => "Win"],
$PAPER => [$ROCK => "Win", $PAPER => "Draw", $SCISSORS => "Loss"],
$SCISSORS => [$ROCK => "Loss", $PAPER => "Win", $SCISSORS => "Draw"],
];
$message = "Win";
$class = "Win";
$playerChoice = filter_input(
INPUT_GET,
'choice',
FILTER_VALIDATE_INT,
['options' => ['min_range' => 0, 'max_range' => 2]]
);
$imagePlayer = $images[$playerChoice];
$imageComputer = $images[$computerChoice];
$isPlaying = ($playerChoice !== null && $playerChoice !== false);
include './views/header.php';
if ($isPlaying){
include './views/game.php';
include './views/message.php';
if ($isPlaying) {
$computerChoice = mt_rand(0, 2);
$message = $rules[$playerChoice][$computerChoice];
$class = $message;
$imagePlayer = $images[$playerChoice];
$imageComputer = $images[$computerChoice];
}
include './views/footer.php';
?>
include_once './views/header.php';
if ($isPlaying) {
include_once './views/game.php';
include_once './views/message.php';
}
include_once './views/footer.php';