-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
executable file
·115 lines (93 loc) · 2.64 KB
/
api.php
File metadata and controls
executable file
·115 lines (93 loc) · 2.64 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
<?php
header('Content-Type: application/json');
$dataString = file_get_contents("data/blueprints.json");
$dataFull = json_decode($dataString);
$dataUnits = [];
$dataMissiles = [];
$locData = json_decode(file_get_contents("data/localization.json"), true);
foreach($dataFull as $thisUnit){
if ($thisUnit->BlueprintType == "UnitBlueprint"){
$dataUnits[]=$thisUnit;
}
else if ($thisUnit->BlueprintType == "ProjectileBlueprint"){
$dataMissiles[]=$thisUnit;
}
}
if (isset($_GET['id']) || isset($_GET['searchunit'])){
$requested = $_GET["id"];
$searchName = $_GET["searchunit"];
$uOI = null;
for ($i = 0; $i < sizeOf($dataUnits); $i++){
$element = $dataUnits[$i];
$id = $element->Id;
$name = $id .= " ";
/*
//Nicknames
switch ($id){
case "XSL0401 ":
$name .= "chicken ";
break;
case "UAL0401 ":
$name .= "gc ";
break;
case "UAA0310 ":
$name .= "donut ";
}
//Endof
$name .= ($element->General->FactionName).' '.getTech($element);
if (property_exists($element->General, 'UnitName')){
$name .= ' "'.($element->General->UnitName).'" ';
}
if (property_exists($element, 'Description')){
$name .= ($element->Description);
}
//All the names
if (strpos(strtolower($name), "extractor") !== false){
$name .= " mex mexes ";
}
if (strpos(strtolower($name), "strategic missile launcher") !== false){
$name .= " nuke SML ";
}
if (strpos(strtolower($name), "strategic missile defense") !== false){
$name .= " SMD ";
}
if (strpos(strtolower($name), "tactical missile launcher") !== false){
$name .= " TML ";
}
if (strpos(strtolower($name), "tactical missile defense") !== false){
$name .= " TMD ";
}
if (strpos(strtolower($name), "power generator") !== false && getTech($element) == "T1 "){
$name .= " pgen ";
}
//endof
*/
if ($id == $requested || strpos(strtolower($name), strtolower($searchName)) !== false){
$uOI = $element;
$uOI = (array)$uOI;
$uOI['ApiName'] = $name;
$uOI = (object)$uOI;
break;
}
}
echo json_encode($uOI);
exit;
}
function getTech($unit){
$unitTech = "";
$unitCat = $unit->Categories;
if (in_array ('TECH1', $unitCat)){
$unitTech = "T1 ";
}
else if (in_array ('TECH2', $unitCat)){
$unitTech = "T2 ";
}
else if (in_array ('TECH3', $unitCat)){
$unitTech = "T3 ";
}
else if (in_array ('EXPERIMENTAL', $unitCat)){
$unitTech = "Experimental ";
}
return $unitTech;
}
?>