forked from krzysztofrewak/hyperdrive-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·86 lines (69 loc) · 2.58 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
declare(strict_types = 1);
require "./vendor/autoload.php";
use Hyperdrive\Entity\Person;
use Hyperdrive\Entity\Quest;
use Hyperdrive\Entity\Task;
use Hyperdrive\GalaxyAtlasBuilder;
use Hyperdrive\Game;
use Hyperdrive\Traps\Pitfall;
use Hyperdrive\Traps\Trap;
use Hyperdrive\HyperdriveNavigator;
use Hyperdrive\Quests\DefeatEnemy;
use Hyperdrive\Quests\SpendTokens;
use Hyperdrive\Quests\UseWeapon;
use Hyperdrive\Quests\VisitPlanets;
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->getName());
$planet = $hyperdrive->getRandomPlanet();
$person = new Person();
$spaceShip = new Hyperdrive\Ship\SpaceShip();
$trap = new Trap();
$task = new Task();
$quest = new Quest(new DefeatEnemy(),new SpendTokens(), new UseWeapon(), new VisitPlanets());
$pitfall = new Pitfall();
$game = new Game();
$game->startGame();
$player = $game->getPlayer();
$task->itemToTransport($atlas,$spaceShip,$cli,$planet,$trap);
while (true) {
$planet = $hyperdrive->getCurrentPlanet();
$pitfall->trap($hyperdrive,$spaceShip,$quest,$person,$player);
$task->shipInformation($spaceShip,$cli);
$task->questMissions($quest,$spaceShip,$person,$planet,$player);
echo "\nToken count: ".$person->getToken()."\n";
if(mb_strtolower(mb_substr($planet->getName(), -1)) == 'a') {
$trap->completeShipStatus($spaceShip,$person);
}
if($person->getToken() <= 0) {
$cli->info("Sorry you have no token: ".$person->getToken());
break;
}else if ($spaceShip->getCondition() <= 0 || $spaceShip->getFuel() <= 0) {
$cli->info("You have problem with Space Ship, You can't go on ");
break;
}
else if ($planet === $target) {
$cli->info("You reached the ".$target->getName()."!");
break;
}
$cli->info("You're on the ".$planet->getName(). " 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", "logs" => "show Logs", "quit" => "quit application"];
$result = $cli->radio("Select option", $options)->prompt();
if ($result === "quit") {
break;
}else if($result === "logs") {
$person->getLogs();
continue;
}
continue;
}
$task->setPersonItems($person, $planet);
$hyperdrive->jumpTo($result);
}