diff --git a/R3.01/tp/tp3/chifoumi/css/style.css b/R3.01/tp/tp3/chifoumi/css/style.css index 51fbf56..cd05b20 100644 --- a/R3.01/tp/tp3/chifoumi/css/style.css +++ b/R3.01/tp/tp3/chifoumi/css/style.css @@ -8,3 +8,6 @@ color:#2E8B57; .Loss{ color:#FF6347; } +.Draw{ +color:#DAA520; +} diff --git a/R3.01/tp/tp3/chifoumi/index.php b/R3.01/tp/tp3/chifoumi/index.php index 7845b33..6045fd4 100644 --- a/R3.01/tp/tp3/chifoumi/index.php +++ b/R3.01/tp/tp3/chifoumi/index.php @@ -1,20 +1,31 @@ [0 => "Draw", 1 => "Loss", 2 => "Win"], + 1 => [0 => "Win", 1 => "Draw", 2 => "Loss"], + 2 => [0 => "Loss", 1 => "Win", 2 => "Draw"], +]; -$playerChoice = 0; -$computerChoice = 1; +$playerChoice = filter_input( + INPUT_GET, + 'choice', + FILTER_VALIDATE_INT, + ['options' => ['min_range' => 0, 'max_range' => 2]] +); -$message = "Win"; -$class = "Win"; +$isPlaying = ($playerChoice !== null && $playerChoice !== false); -$imagePlayer = $images[$playerChoice]; -$imageComputer = $images[$computerChoice]; - -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';