<?php

include(__DIR__ . "/config.php");
include(__DIR__ . "/autoload_namespace.php");

$rolls = array();
$graphics = array();
$dice = new \Rasb14\Dice\DiceGraphic();

for ($i = 0; $i < 6; $i++) {
    array_push($rolls, $dice->roll());
    array_push($graphics, $dice->graphic());
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Page Title</title>
    <link rel="stylesheet" href="style.css">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
    <h1>Rolling six graphic dices</h1>
    <p>
        <?php foreach ($graphics as $value) : ?>
            <i class="dice-sprite <?= $value ?>"></i>
        <?php endforeach; ?>
    </p>
    <p class="dice-utf8">
        <?php foreach ($graphics as $value) : ?>
            <i class="<?= $value ?>"></i>
        <?php endforeach; ?>
    </p>
    <p>Sum: <?= array_sum($rolls) ?></p>
    <p>Average: <?= (array_sum($rolls) / count($rolls)) ?></p>
</body>
</html>
