-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.php
44 lines (31 loc) · 1.08 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare(strict_types = 1);
require "./vendor/autoload.php";
use Hyperdrive\GalaxyAtlasBuilder;
use Hyperdrive\HyperdriveNavigator;
use League\CLImate\CLImate;
$cli = new CLImate();
$atlas = GalaxyAtlasBuilder::buildFromYaml("./resources/routes.yaml");
$hyperdrive = new HyperdriveNavigator($atlas);
$target = $hyperdrive->getRandomPlanet();
$cli->info("Your target is the $target.");
$planet = $hyperdrive->getRandomPlanet();
while (true) {
$planet = $hyperdrive->getCurrentPlanet();
if ($planet === $target) {
$cli->info("You reached the $target!");
break;
}
$cli->info("You're on the $planet. You can jump to:");
$options = $planet->getNeighbours()->toArray() + ["" => "[show more option]"];
$result = $cli->radio("Select jump target planet", $options)->prompt();
if (!$result) {
$options = ["return" => "return", "quit" => "quit application"];
$result = $cli->radio("Select option", $options)->prompt();
if ($result === "quit") {
break;
}
continue;
}
$hyperdrive->jumpTo($result);
}