324 lines
12 KiB
PHP
Executable File
324 lines
12 KiB
PHP
Executable File
<?php
|
|
|
|
//error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
|
|
|
|
chdir('./missions/');
|
|
function fireDepartment($data)
|
|
{
|
|
$fd = [];
|
|
$fd["num_LF"] = 0;
|
|
$fd["num_ELW_1"] = 0;
|
|
$fd["num_ELW_2"] = 0;
|
|
$fd["num_DLK"] = 0;
|
|
$fd["num_RW"] = 0;
|
|
$fd["num_FwK"] = 0;
|
|
$fd["num_GW_A"] = 0;
|
|
$fd["num_GW_G"] = 0;
|
|
$fd["num_GW_Oel"] = 0;
|
|
$fd["num_GW_Mess"] = 0;
|
|
$fd["num_SW"] = 0;
|
|
$fd["num_GW_Hoeh"] = 0;
|
|
$fd["num_Dekon_P"] = 0;
|
|
$fd["num_FLF"] = 0;
|
|
$fd["num_Rettungstreppe"] = 0;
|
|
$fd["num_GW_Werkfeuerwehr"] = 0;
|
|
$fd["num_ULF_mit_Loescharm"] = 0;
|
|
$fd["num_Turboloescher"] = 0;
|
|
|
|
foreach ($data as $key => $value) {
|
|
$value = intval($value);
|
|
if ($key == "Benötigte Dekon-P" || $key == "Dekon P Anforderungswahrscheinlichkeit") {
|
|
if ($key == "Dekon P Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_Dekon_P"] = max($fd["num_Dekon_P"], $value);
|
|
} elseif ($key == "Benötigte Drehleitern" || $key == "Drehleiter Anforderungswahrscheinlichkeit") {
|
|
if ($key == "Drehleiter Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_DLK"] = max($fd["num_DLK"], $value);
|
|
|
|
} elseif ($key == "Benötigte ELW 1" || $key == "ELW 1 Anforderungswahrscheinlichkeit") {
|
|
if ($key == "ELW 1 Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_ELW_1"] = max($fd["num_ELW_1"], $value);
|
|
} elseif ($key == "Benötigte ELW 2" || $key == "ELW 2 Anforderungswahrscheinlichkeit") {
|
|
if ($key == "ELW 2 Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_ELW_2"] = max($fd["num_ELW_2"], $value);
|
|
} elseif ($key == "Benötigte Feuerwehrkräne (FwK)" || $key == "FwK Anforderungswahrscheinlichkeit") {
|
|
if ($key == "FwK Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_FwK"] = max($fd["num_FwK"], $value);
|
|
} elseif ($key == "Benötigte Flugfeldlöschfahrzeuge") {
|
|
$fd["num_FLF"] = max($fd["num_FLF"], $value);
|
|
} elseif ($key == "Benötigte GW L 2 Wasser" || $key == "GW-L2-Wasser Anforderungswahrscheinlichkeit") {
|
|
if ($key == "GW-L2-Wasser Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_SW"] = max($fd["num_SW"], $value);
|
|
} elseif ($key == "Benötigte GW-A" || $key == "GW-A Anforderungswahrscheinlichkeit") {
|
|
if ($key == "GW-A Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_GW_A"] = max($fd["num_GW_A"], $value);
|
|
} elseif ($key == "Benötigte GW-Gefahrgut" || $key == "GW-Gefahrgut Anforderungswahrscheinlichkeit") {
|
|
if ($key == "GW-Gefahrgut Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_GW_G"] = max($fd["num_GW_G"], $value);
|
|
} elseif ($key == "Benötigte GW-Höhenrettung" || $key == "GW-Höhenrettung Anforderungswahrscheinlichkeit") {
|
|
if ($key == "GW-Höhenrettung Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_GW_Hoeh"] = max($fd["num_GW_Hoeh"], $value);
|
|
} elseif ($key == "Benötigte GW-Mess" || $key == "GW-Mess Anforderungswahrscheinlichkeit") {
|
|
if ($key == "GW-Mess Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_GW_Mess"] = max($fd["num_GW_Mess"], $value);
|
|
} elseif ($key == "Benötigte GW-Werkfeuerwehr") {
|
|
$fd["num_GW_Werkfeuerwehr"] = max($fd["num_GW_Werkfeuerwehr"], $value);
|
|
} elseif ($key == "Benötigte GW-Öl" || $key == "GW-Öl Anforderungswahrscheinlichkeit") {
|
|
if ($key == "GW-Öl Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_GW_Oel"] = max($fd["num_GW_Oel"], $value);
|
|
} elseif ($key == "Benötigte Löschfahrzeuge" || $key == "LF Anforderungswahrscheinlichkeit") {
|
|
if ($key == "LF Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_LF"] = max($fd["num_LF"], $value);
|
|
} elseif ($key == "Benötigte Rettungstreppen") {
|
|
$fd["num_Rettungstreppe"] = max($fd["num_Rettungstreppe"], $value);
|
|
} elseif ($key == "Benötigte Rüstwagen" || $key == "Rüstwagen Anforderungswahrscheinlichkeit") {
|
|
if ($key == "Rüstwagen Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$fd["num_RW"] = max($fd["num_RW"], $value);
|
|
} elseif ($key == "Benötigte Teleskopmasten") {
|
|
$fd["num_DLK"] = max($fd["num_DLK"], $value);
|
|
} elseif ($key == "Benötigte Turbolöscher") {
|
|
$fd["num_Turboloescher"] = max($fd["num_Turboloescher"], $value);
|
|
} elseif ($key == "Benötigte ULF mit Löscharm") {
|
|
$fd["num_ULF_mit_Loescharm"] = max($fd["num_ULF_mit_Loescharm"], $value);
|
|
}
|
|
}
|
|
return $fd;
|
|
}
|
|
|
|
function emsDepartment($data)
|
|
{
|
|
$pd = [];
|
|
|
|
$pd["use_KTW"] = false;
|
|
$pd["use_RTW"] = false;
|
|
$pd["use_NEF"] = false;
|
|
$pd["use_RTH"] = false;
|
|
$pd["use_LNA"] = false;
|
|
$pd["use_OrgL"] = false;
|
|
$pd["use_SEG_FULL"] = false;
|
|
$pd["use_SEG_ELW1_Only"] = false;
|
|
|
|
$patienten = 0;
|
|
foreach ($data as $key => $value) {
|
|
$value = intval($value);
|
|
if ($key == "Mindest Patientenanzahl" || $key == "Maximale Patientenanzahl") {
|
|
$patienten = max($patienten, $value);
|
|
}
|
|
if ($key == "Benötigte GW-San") {
|
|
$pd["use_SEG_FULL"] = true;
|
|
} elseif ($key == "Benötigte RTW" || ($key == "Wahrscheinlichkeit, dass ein Patient transportiert werden muss" && $value > 40)) {
|
|
$pd["use_RTW"] = true;
|
|
} elseif ($key == "NEF Anforderungswahrscheinlichkeit" && $value > 40) {
|
|
$pd["use_NEF"] = true;
|
|
} elseif ($key == "RTH Anforderungswahrscheinlichkeit" && $value > 30) {
|
|
$pd["use_RTH"] = true;
|
|
}
|
|
}
|
|
|
|
if ($patienten > 0) {
|
|
$pd["use_RTW"] = true;
|
|
}
|
|
if ($patienten >= 5) {
|
|
$pd["use_LNA"] = true;
|
|
$pd["use_SEG_FULL"] = true;
|
|
}
|
|
if ($patienten >= 10) {
|
|
$pd["use_OrgL"] = true;
|
|
}
|
|
if ($data['Name'] == "Krankentransport") {
|
|
$pd["use_KTW"] = true;
|
|
$pd["use_RTW"] = false;
|
|
$pd["use_NEF"] = false;
|
|
$pd["use_RTH"] = false;
|
|
$pd["use_LNA"] = false;
|
|
$pd["use_OrgL"] = false;
|
|
$pd["use_SEG_FULL"] = false;
|
|
$pd["use_SEG_ELW1_Only"] = false;
|
|
}
|
|
|
|
return $pd;
|
|
}
|
|
|
|
function policeDepartment($data)
|
|
{
|
|
$pd = [];
|
|
$pd["num_FuStW"] = 0;
|
|
$pd["num_leBefKw"] = 0;
|
|
$pd["num_GruKw"] = 0;
|
|
$pd["num_FueKw"] = 0;
|
|
$pd["num_GefKw"] = 0;
|
|
$pd["num_WaWe"] = 0;
|
|
$pd["num_PHu"] = 0;
|
|
$pd["num_SEK_ZF"] = 0;
|
|
$pd["num_SEK_MTF"] = 0;
|
|
$pd["num_MEK_ZF"] = 0;
|
|
$pd["num_MEK_MTF"] = 0;
|
|
|
|
foreach ($data as $key => $value) {
|
|
$value = intval($value);
|
|
if ($key == "Benötigte FüKw") {
|
|
$pd["num_FueKw"] = max($pd["num_FueKw"], $value);
|
|
} elseif ($key == "Benötigte GefKw") {
|
|
$pd["num_GefKw"] = max($pd["num_GefKw"], $value);
|
|
} elseif ($key == "Benötigte GruKw") {
|
|
$pd["num_GruKw"] = max($pd["num_GruKw"], $value);
|
|
} elseif ($key == "Benötigte MEK-Fahrzeuge") {
|
|
if ($value < 5) {
|
|
$pd["num_MEK_ZF"] = 3;
|
|
$pd["num_MEK_MTF"] = 1;
|
|
} else {
|
|
$pd["num_MEK_ZF"] = 6;
|
|
$pd["num_MEK_MTF"] = 2;
|
|
}
|
|
} elseif ($key == "Benötigte Polizeihubschrauber") {
|
|
$pd["num_PHu"] = max($pd["num_PHu"], $value);
|
|
} elseif ($key == "Benötigte SEK-Fahrzeuge") {
|
|
if ($value < 5) {
|
|
$pd["num_SEK_ZF"] = 3;
|
|
$pd["num_SEK_MTF"] = 1;
|
|
} else {
|
|
$pd["num_SEK_ZF"] = 6;
|
|
$pd["num_SEK_MTF"] = 2;
|
|
}
|
|
} elseif ($key == "Benötigte Streifenwagen" || $key == "Streifenwagen Anforderungswahrscheinlichkeit") {
|
|
if ($key == "Streifenwagen Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$pd["num_FuStW"] = max($pd["num_FuStW"], $value);
|
|
} elseif ($key == "Benötigte Wasserwerfer") {
|
|
$pd["num_WaWe"] = max($pd["num_WaWe"], $value);
|
|
} elseif ($key == "Benötigte leBefKw") {
|
|
$pd["num_leBefKw"] = max($pd["num_leBefKw"], $value);
|
|
}
|
|
}
|
|
|
|
return $pd;
|
|
}
|
|
|
|
function tesDepartment($data)
|
|
{
|
|
$rd = [];
|
|
$rd["num_GKW"] = 0;
|
|
$rd["num_MzKW"] = 0;
|
|
$rd["num_MTW_TZ"] = 0;
|
|
$rd["num_LKW_K9"] = 0;
|
|
$rd["num_BRmG_R"] = 0;
|
|
$rd["num_Anh_DLE"] = 0;
|
|
$rd["num_MLW_5"] = 0;
|
|
$rd["num_LKW_7Lkr"] = 0;
|
|
|
|
foreach ($data as $key => $value) {
|
|
$value = intval($value);
|
|
if ($key == "Anhänger Drucklufterzeugung") {
|
|
$rd["num_Anh_DLE"] = max($rd["num_Anh_DLE"], $value);
|
|
} elseif ($key == "BRmG R") {
|
|
$rd["num_BRmG_R"] = max($rd["num_BRmG_R"], $value);
|
|
} elseif ($key == "Benötigte GKW") {
|
|
$rd["num_GKW"] = max($rd["num_GKW"], $value);
|
|
} elseif ($key == "Benötigte MTW-TZ") {
|
|
$rd["num_MTW_TZ"] = max($rd["num_MTW_TZ"], $value);
|
|
} elseif ($key == "Benötigte MzKW") {
|
|
$rd["num_MzKW"] = max($rd["num_MzKW"], $value);
|
|
} elseif ($key == "LKW K 9") {
|
|
$rd["num_LKW_K9"] = max($rd["num_LKW_K9"], $value);
|
|
}
|
|
}
|
|
|
|
if (($rd["num_BRmG_R"] + $rd["num_GKW"] + $rd["num_MTW_TZ"] + $rd["num_MzKW"] + $rd["num_LKW_K9"]) > 0) {
|
|
// 20% speed up with a full car
|
|
$rd["num_MLW_5"] = 1;
|
|
}
|
|
|
|
return $rd;
|
|
}
|
|
|
|
function wsDepartment($data)
|
|
{
|
|
$rd = [];
|
|
|
|
$rd["num_GW_W"] = 0; // only need as required for boots and personal
|
|
$rd["num_GW_T"] = 0;
|
|
$rd["num_MzB"] = 0;
|
|
|
|
foreach ($data as $key => $value) {
|
|
$value = intval($value);
|
|
if ($key == "Benötigte Boote") {
|
|
$rd["num_MzB"] = max($rd["num_MzB"], $value);
|
|
} elseif ($key == "Benötigte GW-Taucher" || $key == "GW-Taucher Anforderungswahrscheinlichkeit") {
|
|
if ($key == "GW-Taucher Anforderungswahrscheinlichkeit") {
|
|
$value = 1;
|
|
}
|
|
$rd["num_GW_T"] = max($rd["num_GW_T"], $value);
|
|
}
|
|
}
|
|
$rd["num_GW_W"] = $rd["num_GW_T"] = max($rd["num_GW_W"], $rd["num_GW_T"], $rd["num_MzB"]);
|
|
return $rd;
|
|
}
|
|
|
|
$concat = [];
|
|
|
|
foreach (glob("*.json") as $filename) {
|
|
if ($filename == 'allTables.json' ||
|
|
$filename == 'prices.json') {
|
|
continue;
|
|
}
|
|
$data = json_decode(file_get_contents($filename), true);
|
|
|
|
$mission_id = str_replace(".json", '', $filename);
|
|
|
|
$mission = [];
|
|
$mission['id'] = $mission_id;
|
|
$mission['type'] = $mission_id;
|
|
$mission['name'] = $data['Name'];
|
|
$fd = fireDepartment($data);
|
|
if (array_sum($fd) > 0) {
|
|
$mission['fire_department'] = $fd;
|
|
}
|
|
$pd = policeDepartment($data);
|
|
if (array_sum($pd) > 0) {
|
|
$mission['police_department'] = $pd;
|
|
}
|
|
$ems = emsDepartment($data);
|
|
if (array_sum($ems) > 0) {
|
|
$mission['emergency_medical_service'] = $ems;
|
|
}
|
|
$tes = tesDepartment($data);
|
|
if (array_sum($tes) > 0) {
|
|
$mission['technical_emergency_service'] = $tes;
|
|
}
|
|
$ws = wsDepartment($data);
|
|
if (array_sum($ws) > 0) {
|
|
$mission['water_rescue'] = $ws;
|
|
}
|
|
|
|
$concat[$mission_id] = $mission;
|
|
|
|
}
|
|
|
|
file_put_contents('../../all_missions.json', "JSON.parse(`".json_encode($concat, JSON_PRETTY_PRINT)."`)");
|