<?php
$ROCK = 0;
$PAPER = 1;
$SCISSORS = 2;

$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"],
];

$playerChoice = filter_input(
    INPUT_GET,
    'choice',
    FILTER_VALIDATE_INT,
    ['options' => ['min_range' => 0, 'max_range' => 2]]
);

$isPlaying = ($playerChoice !== null && $playerChoice !== false);

if ($isPlaying) {
    $computerChoice = mt_rand(0, 2);
    $message = $rules[$playerChoice][$computerChoice];
    $class = $message;
    $imagePlayer = $images[$playerChoice];
    $imageComputer = $images[$computerChoice];
}

include_once './views/header.php';
if ($isPlaying) {
    include_once './views/game.php';
    include_once './views/message.php';
}
include_once './views/footer.php';
