2020-05-17 22:30:22 +02:00
|
|
|
<?php namespace MapGuesser\Controller;
|
|
|
|
|
|
|
|
use MapGuesser\Util\Geo\Bounds;
|
|
|
|
use MapGuesser\Util\Geo\Position;
|
2020-05-19 03:17:40 +02:00
|
|
|
use MapGuesser\View\HtmlView;
|
|
|
|
use MapGuesser\View\ViewBase;
|
2020-05-17 23:35:10 +02:00
|
|
|
use mysqli;
|
2020-05-17 22:30:22 +02:00
|
|
|
|
2020-05-19 16:13:57 +02:00
|
|
|
class GameController implements ControllerInterface
|
2020-05-17 22:30:22 +02:00
|
|
|
{
|
2020-05-19 03:17:40 +02:00
|
|
|
public function run(): ViewBase
|
2020-05-17 22:30:22 +02:00
|
|
|
{
|
2020-05-17 23:35:10 +02:00
|
|
|
$mysql = new mysqli($_ENV['DB_HOST'], $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $_ENV['DB_NAME']);
|
|
|
|
|
|
|
|
// demo map
|
|
|
|
$mapId = 1;
|
|
|
|
|
2020-05-18 00:23:45 +02:00
|
|
|
$stmt = $mysql->prepare('SELECT bound_south_lat, bound_west_lng, bound_north_lat, bound_east_lng FROM maps WHERE id=?');
|
|
|
|
$stmt->bind_param("i", $mapId);
|
|
|
|
$stmt->execute();
|
|
|
|
$map = $stmt->get_result()->fetch_assoc();
|
|
|
|
|
|
|
|
$bounds = Bounds::createDirectly($map['bound_south_lat'], $map['bound_west_lng'], $map['bound_north_lat'], $map['bound_east_lng']);
|
2020-05-17 22:30:22 +02:00
|
|
|
|
2020-05-19 03:17:40 +02:00
|
|
|
$data = compact('bounds');
|
2020-05-19 16:13:57 +02:00
|
|
|
return new HtmlView('game', $data);
|
2020-05-17 22:30:22 +02:00
|
|
|
}
|
|
|
|
}
|