From 98e921d187a4952257d93d96d361f5359b7ffd68 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 4 Jun 2019 15:54:08 -0600 Subject: [PATCH] Return badge info from Player->toArray() --- lib/Player.lib.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Player.lib.php b/lib/Player.lib.php index 9446bed..35e4c9a 100644 --- a/lib/Player.lib.php +++ b/lib/Player.lib.php @@ -18,6 +18,7 @@ class Player { private $lastping = 0; private $stealth = true; public $stats = null; + private $badges = []; public function __construct(\User $user) { global $database; @@ -39,6 +40,8 @@ class Player { $this->lastping = strtotime($profile["lastping"]); $this->stealth = $profile["stealth"] == true; $this->exists = true; + + $this->badges = $database->select("player_badges", ["[>]badges" => "badgeid"], ["id", "name", "desc", "icon", "color", "background", "gotdate (date)"], ["accountid" => $user->getUID()]); } else { $this->exists = false; } @@ -48,6 +51,10 @@ class Player { return $this->exists; } + public function getBadges(): array { + return $this->badges; + } + public function toArray(): array { //"accountid (id)", "nickname (name)", "level", "energy", "maxenergy", "teamid" return [ @@ -56,7 +63,8 @@ class Player { "level" => floor($this->level), "energy" => $this->energy->getEnergy(), "maxenergy" => $this->energy->getMaxEnergy(), - "teamid" => $this->getTeamID() + "teamid" => $this->getTeamID(), + "badges" => $this->getBadges() ]; }