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: #2
This commit was merged in pull request #2.
This commit is contained in:
@@ -8,3 +8,6 @@ color:#2E8B57;
|
||||
.Loss{
|
||||
color:#FF6347;
|
||||
}
|
||||
.Draw{
|
||||
color:#DAA520;
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user