placestats.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Get the stats for a place. Useful for reloading stats after doing something.
  4. */
  5. require 'required.php';
  6. if (is_empty($VARS['locationid'])) {
  7. sendError("Missing internal location ID.", true);
  8. }
  9. $data['status'] = 'OK';
  10. if (!$database->has('locations', ['locationid' => $VARS['locationid']])) {
  11. sendError("No stats found.", true);
  12. }
  13. $gameinfo = $database->select('locations', ["[>]players" => ["owneruuid" => "uuid"]], ['locations.locationid', 'locations.teamid', 'locations.owneruuid', 'players.nickname', 'locations.currentlife', 'locations.maxlife'], ['locations.locationid' => $VARS['locationid']])[0];
  14. if ($gameinfo['owneruuid'] == null) {
  15. $gameinfo['nickname'] = null;
  16. }
  17. $gameinfo['owneruuid'] = "";
  18. // calculate artifact score
  19. $gameinfo['artifact'] = 0;
  20. if ($gameinfo['currentlife'] > 100) {
  21. $templife = $gameinfo['currentlife'];
  22. while ($templife > 100) {
  23. $gameinfo['artifact'] ++;
  24. $templife -= 75;
  25. }
  26. }
  27. $data['stats'] = $gameinfo;
  28. echo json_encode($data);