-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator_test.php
371 lines (358 loc) · 18.8 KB
/
generator_test.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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>D&D Generator - Characters</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<!-- ICO -->
<link rel="shortcut icon" type="image/x-icon" href="./img/favicon.ico">
</head>
<style>
* {
/* border: 1px solid black; */
color: white;
}
body {
background-image: url("./img/background.png");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
}
</style>
<?php
include 'php/connect.php';
include 'php/character.php';
$conn = CreateConnection();
$character = null;
if (isset($_GET['gen'])) {
$character = new Character($conn);
$character->SetGender($_GET['gender']);
$character->SetSelectedRace($_GET['race']);
$character->SetSelectedAbilities($_GET['ab_scores']);
$character->SetSelectedClass($_GET['class']);
$character->SetSelectedPersonality($_GET['personality']);
$character->Generate();
}
?>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="index.html">
<img src="./img/logo_trasparent.png" alt="" width="50" height="50">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-link" aria-current="page" href="index.html">Home</a>
<a class="nav-link active" href="#">Generator</a>
<a class="nav-link" href="#">Features</a>
</div>
</div>
</div>
</nav>
<div class="container bg-dark">
<br>
<div class="row">
<br>
<!-- <iframe name="votar" style="display:none;"></iframe> -->
<form action="" method="GET" class="border-bottom pb-3" target="">
<div class="row">
<div class="col">
<p class="mb-1">Select Race:</p>
<select class="form-select mb-1" aria-label="Race Selector" name="race">
<option value="-1" selected>Random Race</option>
<?php
$myQuery = "SELECT ID,name FROM races";
$races = $conn->query($myQuery);
if ($races->num_rows > 0) {
while ($single_rc = $races->fetch_assoc()) {
echo '<option value="' . $single_rc["ID"] . '">' . $single_rc["name"] . '</option>';
}
}
?>
</select>
<p class="mb-1">Select Class:</p>
<select class="form-select mb-1" aria-label="Race Selector" name="class">
<option value="-1" selected>Random Class</option>
<?php
$myQuery = "SELECT ID,name FROM classes";
$races = $conn->query($myQuery);
if ($races->num_rows > 0) {
while ($single_rc = $races->fetch_assoc()) {
echo '<option value="' . $single_rc["ID"] . '">' . $single_rc["name"] . '</option>';
}
}
?>
</select>
<p class="mb-1">Select Personality:</p>
<select class="form-select mb-1" aria-label="Race Selector" name="personality">
<option value="-1" selected>Random Personality</option>
<?php
$myQuery = "SELECT ID,name FROM personality";
$races = $conn->query($myQuery);
if ($races->num_rows > 0) {
while ($single_rc = $races->fetch_assoc()) {
echo '<option value="' . $single_rc["ID"] . '">' . $single_rc["name"] . '</option>';
}
}
?>
</select>
</div>
<div class="col">
<div class="form-check">
<input class="form-check-input" type="radio" name="ab_scores" id="flexCheckChecked" value="S" checked>
<label class="form-check-label" for="flexRadioDefault1">
Random Abilities
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="ab_scores" id="flexCheckChecked" value="D">
<label class="form-check-label" for="flexRadioDefault1">
Determed Ability Scores
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="ab_scores" id="flexCheckDefault" value="R">
<label class="form-check-label" for="flexRadioDefault2">
Random Ability Scores
</label>
</div>
</div>
<div class="col">
<div class="form-check">
<input class="form-check-input" type="radio" name="gender" id="flexCheckChecked" value="R" checked>
<label class="form-check-label" for="flexRadioDefault1">
Random Gender
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="gender" id="flexCheckChecked" value="1">
<label class="form-check-label" for="flexRadioDefault1">
Male
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="gender" id="flexCheckDefault" value="0">
<label class="form-check-label" for="flexRadioDefault2">
Female
</label>
</div>
</div>
</div>
<div class="row">
<div class="d-grid gap-2 d-md-block">
<button type="submit" class="btn btn-primary btn-block" name="gen" value="1">Generate</button>
<button type="reset" class="btn btn-primary bg-danger border-danger btn-block">Reset Filters</button>
<button class="btn btn-primary bg-warning border-warning btn-block" onclick="generator_test.php">Clear</button>
</div>
</div>
</form>
</div>
<br>
<div class="row">
<div class="col-sm-4">
<?php
echo '<img src="';
if (isset($_GET['gen'])) {
echo 'img/races/' . strtolower($character->GetRaceName()) . '.jpg';
}
echo '" class="rounded" alt="" width="100%">'
?>
</div>
<div class="col-sm-4">
<div class="h4 pb-2 mb-4 border-bottom">
Identity
</div>
<?php
if ($character != null) {
echo "<p>Name: " . $character->GetName() . "</p>";
if (!$character->GetLastname() == -30) {
echo "<p>Lastname: " . $character->GetLastname() . "</p>";
}
echo "<p>Race: " . $character->GetRaceName() . "</p>";
if ($character->GetMainRaceID() != null) {
echo "<p>Is a subrace</p>";
}
echo "<p>Age: " . $character->GetTraits()["age"] . "</p>";
} else {
echo "<p>Not generated yet</p>";
}
?>
</div>
<div class="col-sm-4">
<div class="h4 pb-2 mb-4 border-bottom">
Traits
</div>
<?php
if ($character != null) {
echo "<p>Gender: " . $character->GetGender() . "</p>";
echo "<p>Weight: " . $character->GetTraits()["weight"] . " kg</p>";
echo "<p>Height: " . $character->GetTraits()["height"] . " cm</p>";
echo "<p>Skin Color: " . $character->GetTraits()["skin"] . "</p>";
echo "<p>Eyes Color: " . $character->GetTraits()["eyes"] . "</p>";
if ($character->GetTraits()["hair"] != "") {
echo "<p>Hair Color: " . $character->GetTraits()["hair"] . "</p>";
}
} else {
echo "<p>Not generated yet</p>";
}
?>
</div>
</div>
<div class="row pt-3">
<div class="row">
<div class="col-sm-4">
<div class="h4 pb-2 mb-4 border-bottom">
Ability Scores
<button data-bs-toggle="collapse" data-bs-target="#scores_section_v" class="btn"><img src="./img/arrow_down_w.png" width="30" height="30"></button>
</div>
<div class="col collapse" id="scores_section_v">
<?php
if ($character != null) {
echo "<p>Strenght: " . $character->GetAbilityScores()[0] . "</p>";
echo "<p>Dexterity: " . $character->GetAbilityScores()[1] . "</p>";
echo "<p>Constitution: " . $character->GetAbilityScores()[2] . "</p>";
echo "<p>Intelligence: " . $character->GetAbilityScores()[3] . "</p>";
echo "<p>Wisdom: " . $character->GetAbilityScores()[4] . "</p>";
echo "<p>Charisma: " . $character->GetAbilityScores()[5] . "</p>";
} else {
echo "<p>Not generated yet</p>";
}
?>
</div>
</div>
<div class="col-sm-4">
<div class="h4 pb-2 mb-4 border-bottom">
Class
<button data-bs-toggle="collapse" data-bs-target="#class_section_v" class="btn"><img src="./img/arrow_down_w.png" width="30" height="30"></button>
</div>
<div class="col collapse" id="class_section_v">
<?php
if ($character != null) {
echo "<p>Class Name: " . $character->GetClassArray()["name"] . "</p>";
echo "<p>Class Description: " . $character->GetClassArray()["desc"] . "</p>";
echo "<p>Primary Ability: " . $character->GetClassArray()["primary"] . "</p>";
echo "<p>Hit Dice: " . $character->GetClassArray()["hit_dice"] . "</p>";
echo "<p>Saving Throws: ";
if (!count($character->GetClassArray()["throws"]["sv_throws"]) == 0) {
for ($i = 0; $i < count($character->GetClassArray()["throws"]["sv_throws"]); $i++) {
echo $character->GetClassArray()["throws"]["sv_throws"][$i];
if (array_key_exists($i + 1, $character->GetClassArray()["throws"]["sv_throws"])) {
echo ", ";
}
}
} else {
echo "no one";
}
echo "</p>";
echo "<p>Armor Proficency: ";
if (!count($character->GetClassArray()["armor_weapons"]["armor"]) == 0) {
for ($i = 0; $i < count($character->GetClassArray()["armor_weapons"]["armor"]); $i++) {
echo $character->GetClassArray()["armor_weapons"]["armor"][$i];
if (array_key_exists($i + 1, $character->GetClassArray()["armor_weapons"]["armor"])) {
echo " armor, ";
} else {
echo " armor";
}
}
} else {
echo "no one";
}
echo "</p>";
echo "<p>Weapon Proficency: ";
if (!count($character->GetClassArray()["armor_weapons"]["weapons"]) == 0) {
for ($i = 0; $i < count($character->GetClassArray()["armor_weapons"]["weapons"]); $i++) {
echo $character->GetClassArray()["armor_weapons"]["weapons"][$i];
if (array_key_exists($i + 1, $character->GetClassArray()["armor_weapons"]["weapons"])) {
echo ", ";
}
}
} else {
echo "no one";
}
echo "</p>";
} else {
echo "<p>Not generated yet</p>";
}
?>
</div>
</div>
<div class="col-sm-4">
<div class="h4 pb-2 mb-4 border-bottom">
Racial Traits
<button data-bs-toggle="collapse" data-bs-target="#racial_traits_section_v" class="btn"><img src="./img/arrow_down_w.png" width="30" height="30"></button>
</div>
<div class="col collapse" id="racial_traits_section_v">
<div class="col">
<?php
if ($character != null) {
echo '<table class="table border border-0">';
$items = $character->GetRacialTraits();
for ($i = 0; $i < count($items[0]); $i++) {
echo '<tr><th class="border-top border-bottom">' . $items[0][$i] . '</th><td class="border-top border-bottom">' . $items[1][$i] . '</td></tr>';
}
echo '</table>';
} else {
echo "<p>Not generated yet</p>";
}
?>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="h4 pb-2 mb-4 border-bottom">
Background
<button data-bs-toggle="collapse" data-bs-target="#background_section_v" class="btn"><img src="./img/arrow_down_w.png" width="30" height="30"></button>
</div>
<div class="col collapse" id="background_section_v">
<div class="col">
<?php
if ($character != null) {
echo "<p>Personality: " . $character->GetPersonalityValues()["name"] . "</p>";
echo "<p>Personality Traits: " . $character->GetBackgrounds()["personalityTrait"] . "</p>";
echo "<p>Privilege: " . $character->GetBackgrounds()["feature"] . "</p>";
echo "<p>Ideals: " . $character->GetBackgrounds()["ideal"] . "</p>";
echo "<p>Bons: " . $character->GetBackgrounds()["bond"] . "</p>";
echo "<p>Flaws: " . $character->GetBackgrounds()["flaw"] . "</p>";
} else {
echo "<p>Not generated yet</p>";
}
?>
</p>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="h4 pb-2 mb-4 border-bottom text-muted">
Coming in future
<button data-bs-toggle="collapse" data-bs-target="#personality_section_v" class="btn"><img src="./img/arrow_down_w.png" width="30" height="30"></button>
</div>
<div class="col collapse" id="personality_section_v">
<div class="col">
<!-- COMING IN V2 -->
</div>
</div>
</div>
<div class="col-sm-4">
<div class="h4 pb-2 mb-4 border-bottom text-muted">
Coming in future
<button data-bs-toggle="collapse" data-bs-target="#temp_section_v" class="btn"><img src="./img/arrow_down_w.png" width="30" height="30"></button>
</div>
<div class="col collapse" id="temp_section_v">
<div class="col">
<!-- COMING IN V2 -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- BOOSTRAP SCRIPT -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
</body>
</html>