diff --git a/api/actions/getplace.php b/api/actions/getplace.php new file mode 100644 index 0000000..0febfa6 --- /dev/null +++ b/api/actions/getplace.php @@ -0,0 +1,26 @@ + 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; + } + $artifacts = $database->select("artifacts", ["[>]locations" => "locationid"], ["currentlife", "maxlife", "itemid"]); + $data["artifacts"] = $artifacts; +} + +exitWithJson(["status" => "OK", "place" => $data]); \ No newline at end of file diff --git a/api/apisettings.php b/api/apisettings.php index 7ec2d5f..89f689f 100644 --- a/api/apisettings.php +++ b/api/apisettings.php @@ -59,6 +59,12 @@ $APIS = [ "radius (optional)" => "numeric" ] ], + "getplace" => [ + "load" => "getplace.php", + "vars" => [ + "id" => "/[0-9]+/" + ] + ], "getchat" => [ "load" => "getchat.php", "vars" => [