Server/api/actions/getplace.php

34 lines
1.0 KiB
PHP
Raw Normal View History

2019-05-22 14:10:12 -06:00
<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
$data = [
"teamid" => null,
"ownerid" => null,
"currentlife" => 0,
"maxlife" => 0,
"artifacts" => []
];
if ($database->has("locations", ["osmid" => $VARS["id"]])) {
$gameprops = $database->get("locations", ["teamid", "ownerid", "currentlife", "maxlife"], ["osmid" => $VARS["id"]]);
foreach ($gameprops as $key => $value) {
$data[$key] = $value;
}
2019-05-28 00:33:39 -06:00
$artifacts = $database->select("artifacts", [
"[>]locations" => "locationid",
"[>]items" => "itemid"
], [
2019-05-28 00:59:18 -06:00
"artifacts.artuuid (id)", "artifacts.currentlife (energy)", "artifacts.maxlife (maxenergy)", "artifacts.itemid", "items.icon", "items.color"
2019-05-28 00:33:39 -06:00
], [
"locations.osmid" => $VARS["id"]
]);
2019-05-22 14:10:12 -06:00
$data["artifacts"] = $artifacts;
}
2019-05-28 00:33:39 -06:00
exitWithJson(["status" => "OK", "place" => $data]);