From 395552b8f1ad35a111704b95fec29e32148c7320 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Mon, 27 May 2019 23:40:03 -0600 Subject: [PATCH] Rewrite getprofile to use Player class --- api/actions/getprofile.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/api/actions/getprofile.php b/api/actions/getprofile.php index 1bf697c..01a4a67 100644 --- a/api/actions/getprofile.php +++ b/api/actions/getprofile.php @@ -7,18 +7,16 @@ */ if (empty($VARS["id"])) { - $accountid = getRequestUser()->getUID(); + $player = new Player(getRequestUser()); } else { - $accountid = $VARS["id"]; + $player = new Player(new User($VARS["id"])); } -if ($database->has("players", ["accountid" => $accountid])) { - $profile = $database->get("players", ["accountid (id)", "nickname (name)", "level", "energy", "maxenergy", "teamid"], ["accountid" => $accountid]); +if ($player->exists()) { + exitWithJson([ + "status" => "OK", + "profile" => $player->toArray() + ]); } else { sendJsonResp($Strings->get("Player does not exist.", false), "ERROR"); -} - -exitWithJson([ - "status" => "OK", - "profile" => $profile -]); +} \ No newline at end of file