Return badge info from Player->toArray()

master
Skylar Ittner 5 years ago
parent 97921fc8c8
commit 98e921d187

@ -18,6 +18,7 @@ class Player {
private $lastping = 0; private $lastping = 0;
private $stealth = true; private $stealth = true;
public $stats = null; public $stats = null;
private $badges = [];
public function __construct(\User $user) { public function __construct(\User $user) {
global $database; global $database;
@ -39,6 +40,8 @@ class Player {
$this->lastping = strtotime($profile["lastping"]); $this->lastping = strtotime($profile["lastping"]);
$this->stealth = $profile["stealth"] == true; $this->stealth = $profile["stealth"] == true;
$this->exists = true; $this->exists = true;
$this->badges = $database->select("player_badges", ["[>]badges" => "badgeid"], ["id", "name", "desc", "icon", "color", "background", "gotdate (date)"], ["accountid" => $user->getUID()]);
} else { } else {
$this->exists = false; $this->exists = false;
} }
@ -48,6 +51,10 @@ class Player {
return $this->exists; return $this->exists;
} }
public function getBadges(): array {
return $this->badges;
}
public function toArray(): array { public function toArray(): array {
//"accountid (id)", "nickname (name)", "level", "energy", "maxenergy", "teamid" //"accountid (id)", "nickname (name)", "level", "energy", "maxenergy", "teamid"
return [ return [
@ -56,7 +63,8 @@ class Player {
"level" => floor($this->level), "level" => floor($this->level),
"energy" => $this->energy->getEnergy(), "energy" => $this->energy->getEnergy(),
"maxenergy" => $this->energy->getMaxEnergy(), "maxenergy" => $this->energy->getMaxEnergy(),
"teamid" => $this->getTeamID() "teamid" => $this->getTeamID(),
"badges" => $this->getBadges()
]; ];
} }

Loading…
Cancel
Save