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