-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
144 lines (129 loc) · 6.13 KB
/
index.php
File metadata and controls
144 lines (129 loc) · 6.13 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
use Service\BattleManager;
use Service\Container;
use Model\BrokenShip;
require __DIR__.'/bootstrap.php';
$container = new Container($configuration);
$shipLoader = $container->getShipLoader();
$ships = $shipLoader->getShips();
$brokenShip = new BrokenShip('Just a hunk of metal');
$ships[] = $brokenShip;
$battleTypes = BattleManager::getAllBattleTypesWithDescription();
$ships->removeAllBrokenShips();
$errorMessage = '';
if (isset($_GET['error'])) {
switch ($_GET['error']) {
case 'missing_data':
$errorMessage = 'Don\'t forget to select some ships to battle!';
break;
case 'bad_ships':
$errorMessage = 'You\'re trying to fight with a ship that\'s unknown to the galaxy?';
break;
case 'bad_quantities':
$errorMessage = 'You pick strange numbers of ships to battle - try again.';
break;
default:
$errorMessage = 'There was a disturbance in the force. Try again.';
}
}
?>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OO Battleships</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<?php if ($errorMessage): ?>
<div>
<?php echo $errorMessage; ?>
</div>
<?php endif; ?>
<body>
<div class="container">
<div class="page-header">
<h1>OO Battleships of Space</h1>
</div>
<table class="table table-hover">
<caption><i class="fa fa-rocket"></i> These ships are ready for their next Mission</caption>
<thead>
<tr>
<th>Ship</th>
<th>Weapon Power</th>
<th>Jedi Factor</th>
<th>Strength</th>
<th>Status</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<?php foreach ($ships as $ship): ?>
<tr>
<td><?php echo $ship->getName(); ?></td>
<td><?php echo $ship->getWeaponPower(); ?></td>
<td><?php echo $ship->getJediFactor(); ?></td>
<td><?php echo $ship->getStrength(); ?></td>
<td>
<?php if ($ship->isFunctional()): ?>
<i class="fa fa-sun-o"></i>
<?php else: ?>
<i class="fa fa-cloud"></i>
<?php endif; ?>
</td>
<td><?php echo $ship->getType()?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="battle-box center-block border">
<div>
<form method="POST" action="/oo/battle.php">
<h2 class="text-center">The Mission</h2>
<input class="center-block form-control text-field" type="text" name="ship1_quantity" placeholder="Enter Number of Ships" />
<select class="center-block form-control btn drp-dwn-width btn-default btn-lg dropdown-toggle" name="ship1_id">
<option value="">Choose a Ship</option>
<?php foreach ($ships as $ship): ?>
<?php if ($ship->isFunctional()): ?>
<option value="<?php echo $ship->getId(); ?>"><?php echo $ship->getNameAndSpecs(); ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
<br>
<p class="text-center">AGAINST</p>
<br>
<input class="center-block form-control text-field" type="text" name="ship2_quantity" placeholder="Enter Number of Ships" />
<select class="center-block form-control btn drp-dwn-width btn-default btn-lg dropdown-toggle" name="ship2_id">
<option value="">Choose a Ship</option>
<?php foreach ($ships as $ship): ?>
<?php if ($ship->isFunctional()): ?>
<option value="<?php echo $ship->getId(); ?>"><?php echo $ship->getNameAndSpecs(); ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
<br>
<div class="text-center">
<label for="battle_type">Battle Type</label>
<select name="battle_type" id="battle_type" class="form-control drp-dwn-width center-block">
<?php foreach ($battleTypes as $battleType => $typeText) : ?>
<option value="<?php echo $battleType ?>"><?php echo $typeText ?></option>
<?php endforeach;?>
</select>
</div>
<br/>
<button class="btn btn-md btn-danger center-block" type="submit">Engage</button>
</form>
</div>
</div>
</div>
</body>
</html>