2022-03-15 17:20:50 +00:00
|
|
|
<?php $app = require '../../app/inc.php';
|
2022-03-07 10:11:33 +00:00
|
|
|
|
|
|
|
// TODO: refactor
|
|
|
|
|
2022-03-10 15:52:59 +00:00
|
|
|
$cardreader = $app->model('Cardreader');
|
2022-01-24 10:54:42 +00:00
|
|
|
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST')
|
|
|
|
{
|
2022-02-15 10:24:06 +00:00
|
|
|
if (isset($_POST['cardnumber']) && strlen($_POST['cardnumber']) !== 0)
|
2022-01-24 10:54:42 +00:00
|
|
|
{
|
2022-01-27 21:08:06 +00:00
|
|
|
$cardnumber = $_POST['cardnumber'];
|
2022-01-26 13:38:22 +00:00
|
|
|
|
2022-02-14 10:23:05 +00:00
|
|
|
if (!(strlen($cardnumber) > 32)) {
|
2022-03-14 10:36:45 +00:00
|
|
|
|
|
|
|
$code = $cardreader->receive($cardnumber, 30);
|
|
|
|
switch ($code) {
|
|
|
|
case 0:
|
|
|
|
$app->session->flash('Opprettet nytt lag', 'success');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
$app->session->flash('Startet telling', 'success');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
$app->session->flash('Passerte en runde', 'success');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
$app->session->flash('Runde gikk for fort!', 'danger');
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$app->session->flash('Uhhh?? Dette skulle ikke skje', 'danger');
|
|
|
|
break;
|
2022-02-14 10:23:05 +00:00
|
|
|
}
|
2022-03-14 10:36:45 +00:00
|
|
|
|
2022-01-26 13:38:22 +00:00
|
|
|
} else {
|
2022-02-14 10:23:05 +00:00
|
|
|
$app->session->flash('Kortnummer for langt!', 'danger');
|
2022-01-26 13:38:22 +00:00
|
|
|
}
|
2022-01-27 21:08:06 +00:00
|
|
|
} else {
|
|
|
|
$app->session->flash('Kortnummer kan ikke være tom!', 'danger');
|
2022-01-24 10:54:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$app->view('template/header', ['title' => 'Simulator']);
|
2022-03-15 17:20:50 +00:00
|
|
|
$app->view('pages/race/simulator');
|
2022-01-24 10:54:42 +00:00
|
|
|
$app->view('template/footer');
|