-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats_conditions.php
332 lines (263 loc) · 10 KB
/
stats_conditions.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
<?php
//-----------------------//
//remove me after include//
//-----------------------//
//include the db
require_once('Connections/dbDescent.php');
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
//include functions
include 'includes/function_logout.php';
include 'includes/function_createProgressBar.php';
include 'includes/function_getSQLValueString.php';
include 'includes/function_getCampaignLabel.php';
function calcQuestWins($overlord, $heroes){
$total = $overlord + $heroes;
if ($overlord != 0){
$OverlordPerc = ($overlord / $total) * 100;
$olText = 'Overlord: ' . $overlord . ' Win(s)';
}
if ($heroes != 0){
$HeroPerc = ($heroes / $total) * 100;
$hText = 'Heroes: ' . $heroes . ' Win(s)';
}
if ($heroes == 0){
$HeroPerc = 0;
$hText = 'Heroes: ' . $heroes . ' Win(s)';
}
if ($overlord == 0){
$OverlordPerc = 0;
$olText = 'Overlord: ' . $overlord .' Win(s)';
}
$QuestWins = array(
"OverlordPerc" => $OverlordPerc,
"OverlordText" => $olText,
"HeroPerc" => $HeroPerc,
"HeroText" => $hText,
);
return $QuestWins;
}
//select the database
mysql_select_db($database_dbDescent, $dbDescent);
// Get Games
$query_rsAllGames = sprintf("SELECT * FROM tbgames ORDER BY game_id ASC");
$rsAllGames = mysql_query($query_rsAllGames, $dbDescent) or die(mysql_error());
$row_rsAllGames = mysql_fetch_assoc($rsAllGames);
$totalRows_rsAllGames = mysql_num_rows($rsAllGames);
$totalGames = 0;
do {
$totalGames++;
} while ($row_rsAllGames = mysql_fetch_assoc($rsAllGames));
// Select Monsters
$query_rsMonsters = sprintf("SELECT * FROM tbmonsters INNER JOIN tbcampaign ON tbmonsters.monster_exp_id = tbcampaign.cam_id ORDER BY monster_name");
$rsMonsters = mysql_query($query_rsMonsters, $dbDescent) or die(mysql_error());
$row_rsMonsters = mysql_fetch_assoc($rsMonsters);
$totalRows_rsMonsters = mysql_num_rows($rsMonsters);
$allMonsters = array();
do {
$conditions = explode(",", $row_rsMonsters['monster_conditions']);
$allMonsters[] = array(
"id" => $row_rsMonsters['monster_id'],
"name" => $row_rsMonsters['monster_name'],
"expansion" => $row_rsMonsters['cam_name'],
"traits" => explode(",", $row_rsMonsters['monster_traits']),
"size" => $row_rsMonsters['monster_type'],
"conditions" => $conditions,
);
} while ($row_rsMonsters = mysql_fetch_assoc($rsMonsters));
$query_rsEachQuest = sprintf("SELECT * FROM tbquests_progress WHERE progress_quest_winner is not NULL");
$rsEachQuest = mysql_query($query_rsEachQuest, $dbDescent) or die(mysql_error());
$row_rsEachQuest = mysql_fetch_assoc($rsEachQuest);
$totalRows_rsEachQuest = mysql_num_rows($rsEachQuest);
$MonstersUsed = array();
$totalEncounters = 0;
do {
if ($row_rsEachQuest['progress_enc1_monsters'] != NULL){
$MonsEncounter1 = explode(",", $row_rsEachQuest['progress_enc1_monsters']);
$totalEncounters++;
}
if ($row_rsEachQuest['progress_enc2_monsters'] != NULL){
$MonsEncounter2 = explode(",", $row_rsEachQuest['progress_enc2_monsters']);
$totalEncounters++;
}
foreach ($MonsEncounter1 as $m1){
$MonstersUsed[] = $m1;
}
if(isset($MonsEncounter2)){
foreach ($MonsEncounter2 as $m2){
$MonstersUsed[] = $m2;
}
}
} while ($row_rsEachQuest = mysql_fetch_assoc($rsEachQuest));
$MonstersUsedCounted = array_count_values($MonstersUsed);
// echo '<pre>';
// var_dump($MonstersUsedCounted);
// echo '</pre>';
arsort($MonstersUsedCounted);
// echo '<pre>';
// var_dump($MonstersUsedCountedSort);
// echo '</pre>';
$traits = array("civilized","cold","dark","hot","building","water","mountain","wilderness","cursed","cave",);
$size = array("small","medium","huge","massive",);
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="content.css">
<title>Descent 2nd Edition Campaign Tracker</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<?php
include 'navbar.php';
include 'banner.php';
?>
<div class="container grey">
<div class="row">
<div id="" class="col-md-6">
<div class="row">
<div class="col-md-12"> </div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">Most popular monsters</h2>
</div>
<div class="panel-body"><?php
foreach ($MonstersUsedCounted as $key => $muc){
$monsterPerc = ($muc / $totalEncounters) * 100;
foreach($allMonsters as $am){
if ($am['id'] == $key && $am['size'] != "lieutenant"){ ?>
<div class="row stats-row">
<div class="col-xs-12">
<div class="row">
<div class="col-md-6">
<p><strong><?php echo $am['name']; ?></strong></p>
</div>
<div class="col-md-6 text-right"><?php
getCampaignLabel($am['expansion'], "normal"); ?>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="progress">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo round($monsterPerc);?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo round($monsterPerc);?>%;">
<span class="sr-only"><?php echo round($monsterPerc);?>%</span>
<?php echo round($monsterPerc);?>% of Encounters
</div>
</div>
</div>
</div>
<p></p>
</div>
</div><?php
}
}
} ?>
</div>
</div>
</div>
</div>
</div>
<div id="" class="col-md-6">
<div class="row">
<div class="col-md-12"> </div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">Monster Traits</h2>
</div>
<div class="panel-body"><?php
foreach($traits as $t){ ?>
<div class="row stats-row">
<div class="col-xs-12">
<div class="row">
<div class="col-md-6">
<p><strong><?php echo ucwords($t); ?></strong></p>
</div>
<div class="col-md-6 text-right">
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="row"><?php
foreach ($allMonsters as $am){
if (in_array($t, $am['traits'])){
echo '<div class="col-sm-4 col-xs-6">';
getCampaignLabel($am['expansion'], "mini");
echo " " . $am['name'];
echo '</div>';
}
} ?>
</div>
</div>
</div>
<p></p>
</div>
</div><?php
} ?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12"> </div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">Monster Size</h2>
</div>
<div class="panel-body"><?php
foreach($size as $s){ ?>
<div class="row stats-row">
<div class="col-xs-12">
<div class="row">
<div class="col-md-6">
<p><strong><?php echo ucwords($s); ?></strong></p>
</div>
<div class="col-md-6 text-right">
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="row"><?php
foreach ($allMonsters as $am){
if ($s == $am['size']){
echo '<div class="col-sm-4 col-xs-6">';
getCampaignLabel($am['expansion'], "mini");
echo " " . $am['name'];
echo '</div>';
}
} ?>
</div>
</div>
</div>
<p></p>
</div>
</div><?php
} ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
/*
echo '<pre>';
var_dump($statsArray);
echo '</pre>';
*/
?>