correction-ulysse #2
@@ -8,3 +8,6 @@ color:#2E8B57;
|
|||||||
.Loss{
|
.Loss{
|
||||||
color:#FF6347;
|
color:#FF6347;
|
||||||
}
|
}
|
||||||
|
.Draw{
|
||||||
|
color:#DAA520;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,20 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
$images = ["rock.png","paper.png","scissors.png"];
|
$images = ["rock.png", "paper.png", "scissors.png"];
|
||||||
$isPlaying = true;
|
$rules = [
|
||||||
|
0 => [0 => "Draw", 1 => "Loss", 2 => "Win"],
|
||||||
|
1 => [0 => "Win", 1 => "Draw", 2 => "Loss"],
|
||||||
|
2 => [0 => "Loss", 1 => "Win", 2 => "Draw"],
|
||||||
|
];
|
||||||
|
|
||||||
$playerChoice = 0;
|
$playerChoice = filter_input(
|
||||||
$computerChoice = 1;
|
INPUT_GET,
|
||||||
|
'choice',
|
||||||
|
FILTER_VALIDATE_INT,
|
||||||
|
['options' => ['min_range' => 0, 'max_range' => 2]]
|
||||||
|
);
|
||||||
|
|
||||||
$message = "Win";
|
$isPlaying = ($playerChoice !== null && $playerChoice !== false);
|
||||||
$class = "Win";
|
|
||||||
|
|
||||||
$imagePlayer = $images[$playerChoice];
|
if ($isPlaying) {
|
||||||
$imageComputer = $images[$computerChoice];
|
$computerChoice = mt_rand(0, 2);
|
||||||
|
$message = $rules[$playerChoice][$computerChoice];
|
||||||
include './views/header.php';
|
$class = $message;
|
||||||
if ($isPlaying){
|
$imagePlayer = $images[$playerChoice];
|
||||||
include './views/game.php';
|
$imageComputer = $images[$computerChoice];
|
||||||
include './views/message.php';
|
|
||||||
}
|
}
|
||||||
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