Rewrite getprofile to use Player class
This commit is contained in:
parent
92df403312
commit
395552b8f1
@ -7,18 +7,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (empty($VARS["id"])) {
|
if (empty($VARS["id"])) {
|
||||||
$accountid = getRequestUser()->getUID();
|
$player = new Player(getRequestUser());
|
||||||
} else {
|
} else {
|
||||||
$accountid = $VARS["id"];
|
$player = new Player(new User($VARS["id"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($database->has("players", ["accountid" => $accountid])) {
|
if ($player->exists()) {
|
||||||
$profile = $database->get("players", ["accountid (id)", "nickname (name)", "level", "energy", "maxenergy", "teamid"], ["accountid" => $accountid]);
|
exitWithJson([
|
||||||
|
"status" => "OK",
|
||||||
|
"profile" => $player->toArray()
|
||||||
|
]);
|
||||||
} else {
|
} else {
|
||||||
sendJsonResp($Strings->get("Player does not exist.", false), "ERROR");
|
sendJsonResp($Strings->get("Player does not exist.", false), "ERROR");
|
||||||
}
|
}
|
||||||
|
|
||||||
exitWithJson([
|
|
||||||
"status" => "OK",
|
|
||||||
"profile" => $profile
|
|
||||||
]);
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user