Untitled

mail@pastecode.io avatar
unknown
php
2 years ago
3.1 kB
2
Indexable
Never
<?php
// early prototype
// http://localhost/api/?amt=1000&type=concrete&eid=QRGravel
//  returns: [41667,"Gravel",5,"QRGravel"] (JSON Array)
// TODO:
// Use POST instead of GET (Just easier to test without writing JS code)
// Check Array for errors in converting 
// use ceil() same was ceil10() used in JS code w/ -1
$amountWanted = $_GET['amt'];
$calcType = $_GET["type"];
$filter = $_GET["eid"];
$concreteCalc = array(// calc for value : item name : weight : embedID
    // Logs
    array($amountWanted, "Logs", 60, "Logs"),
    array($amountWanted * 10, "Sawdust", 3, "Logs"),
    // Toxic Waste Calcs
    array(ceil($amountWanted / 4), "Toxic Waste", 110, "TWRequired"),
    array(ceil($amountWanted / 4) * 4, "Acid", 5, "TWAcid"),
    array(ceil($amountWanted / 4) * 2, "Scrap Lead", 15, "TWSLM"),
    array(ceil($amountWanted / 4) * 2, "Scrap Mercury", 15, "TWSM"),
    // Treated Water LS Route
    array($amountWanted, "Unfiltered Water", 100, "TreatedWUnfil"),
    array($amountWanted, "Treated Water", 100, "TreatWRequired"),
    array($amountWanted, "Acid", 5, "TreatedWAcid"),
    // Treated Water LC Route
    array($amountWanted, "Treated Water", 100, "LCTWRequired"),
    array($amountWanted, "Auto Parts", 100, "LCTWCar"),
    array($amountWanted, "Military Goods", 100, "LCTWMG"),
    array($amountWanted, "Export Goods", 100, "LCTWEG"),
    array($amountWanted, "Liberty City Token", 0, "LCTWToken"),
    // Quarry Rubble Calcs
    array(ceil(($amountWanted * 25) / 0.6), "Quarry Rubble", 150, "QRRequired"),
    array(ceil(($amountWanted * 25) / 0.6), "Raw Ore Mix", 15, "QROM"),
    array(ceil(($amountWanted * 25) / 0.6), "Gravel", 5, "QRGravel"),
    array(ceil(($amountWanted * 25) / 0.6), "Raw Emeralds", 10, "QREmerald"),
    // Gravel to Sand Filtration
    array(ceil(($amountWanted * 25) / 0.6), "Gravel", 5, "GRRequired"),
    array(ceil(($amountWanted * 25) / 0.6) / 10 * 6, "Sand", 5, "GRSand"),
    array(ceil(($amountWanted * 25) / 0.6) / 10 * 4, "Flint", 5, "GRFlint"),
    // Cement Mix
    array($amountWanted * 5, "Cement Mix", 25, "CMRequired"),
    array($amountWanted * 25, "Sand", 5, "CMSand"),
    array($amountWanted * 10, "Sawdust", 3, "CMSawdust"),
    // Concrete Calcs
    array($amountWanted, "Concrete", 160, "ConRequired"),
    array($amountWanted, "Treated Water", 100, "ConTW"), // Change ID to ConTW
    array($amountWanted * 5, "Cement Mix", 25, "ConMix"),
    // Trips placeholders
    array(ceil(($amountWanted * 25) / 0.6), "QRTrips", 150, "QRTrips"),
    array($amountWanted, "TWTrips", 100, "TWTrips"),
    array($amountWanted, "TreatedWTripsLosSantos", 100, "TreatedWTrips"),
    array($amountWanted, "LogsTrips to Sawmill", 60, "LogsTrips")
);
function returnJSONArray($array, $filter)
{
    for ($i = 0; $i < count($array); $i++) {
        if ($array[$i][3] == $filter) {
            return json_encode($array[$i]);
        }
    }
}
switch ($calcType) {
    case "concrete":
        echo returnJSONArray($concreteCalc, $filter);
        break;
}
?>