2022-04-26 19:55:10 +00:00
|
|
|
<?php $app = require '../../../app/inc.php';
|
2022-03-07 10:11:33 +00:00
|
|
|
|
2022-03-30 08:51:46 +00:00
|
|
|
// uh oh.. stinky
|
|
|
|
|
2022-04-14 20:59:42 +00:00
|
|
|
$baton_reader = $app->model('BatonReader');
|
2022-01-24 10:54:42 +00:00
|
|
|
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST')
|
|
|
|
{
|
2022-03-30 08:51:46 +00:00
|
|
|
if (isset($_POST['cardnumber']) && strlen((string)$_POST['cardnumber']) !== 0)
|
2022-01-24 10:54:42 +00:00
|
|
|
{
|
2022-03-30 08:51:46 +00:00
|
|
|
$cardnumber = (string)$_POST['cardnumber'];
|
2022-01-26 13:38:22 +00:00
|
|
|
|
2022-03-19 21:48:04 +00:00
|
|
|
try {
|
2022-05-08 20:00:11 +00:00
|
|
|
$code = $baton_reader->receive($cardnumber, $app->config['baton_cooldown']);
|
2022-03-14 10:36:45 +00:00
|
|
|
switch ($code) {
|
|
|
|
case 0:
|
|
|
|
$app->session->flash('Opprettet nytt lag', 'success');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2022-03-16 12:37:24 +00:00
|
|
|
$app->session->flash('Startet telling', 'info');
|
2022-03-14 10:36:45 +00:00
|
|
|
break;
|
2022-03-19 21:48:04 +00:00
|
|
|
|
2022-03-14 10:36:45 +00:00
|
|
|
case 2:
|
2022-03-16 12:37:24 +00:00
|
|
|
$app->session->flash('Runde gikk for fort!', 'danger');
|
2022-03-14 10:36:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2022-03-16 12:37:24 +00:00
|
|
|
$app->session->flash('Passerte en runde', 'info');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
$app->session->flash('Passerte en runde, ny rekord!', 'success');
|
2022-03-14 10:36:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$app->session->flash('Uhhh?? Dette skulle ikke skje', 'danger');
|
|
|
|
break;
|
2022-02-14 10:23:05 +00:00
|
|
|
}
|
2022-03-19 21:48:04 +00:00
|
|
|
} catch (InvalidArgumentException $e) {
|
|
|
|
$app->session->flash("Noe gikk galt: {$e->getMessage()}", "danger");
|
2022-01-26 13:38:22 +00:00
|
|
|
}
|
2022-03-19 21:48:04 +00:00
|
|
|
} else {
|
2022-01-27 21:08:06 +00:00
|
|
|
$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-04-26 19:55:10 +00:00
|
|
|
$app->view('pages/race/configure/simulator');
|
2022-01-24 10:54:42 +00:00
|
|
|
$app->view('template/footer');
|