From 129053e951b3f86549278924bb7c8a6f7f3153b6 Mon Sep 17 00:00:00 2001 From: Beu Date: Wed, 12 Jul 2023 17:26:49 +0200 Subject: [PATCH] Add TeamId from OnScoresStructure --- .../TrackMania/Models/PlayerScore.php | 21 +++++++++++++++++++ .../TrackMania/OnScoresStructure.php | 7 +++++++ 2 files changed, 28 insertions(+) diff --git a/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php b/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php index f0a633fa..bac44f71 100644 --- a/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php +++ b/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php @@ -16,6 +16,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore; */ class PlayerScore extends CommonPlayerScore { + private $teamid; private $bestRaceTime; private $bestLapTime; private $stuntScore; @@ -28,6 +29,26 @@ class PlayerScore extends CommonPlayerScore { private $prevRaceCheckpoints; private $prevStuntsScore; + /** + * Returns the TeamId + * + * @api + * @return int + */ + public function getTeamId() { + return $this->teamid; + } + + /** + * Sets the TeamId + * + * @api + * @param int $teamid + */ + public function setTeamId($teamid) { + $this->teamid = $teamid; + } + /** * Returns the Rank * diff --git a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php index 52c1a9b0..538bad45 100644 --- a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php @@ -70,6 +70,13 @@ class OnScoresStructure extends CommonScoresStructure { $playerScore->setPrevStuntsScore($jsonPlayer->prevstuntsscore); } + // New attribute added in TM2020 + if (property_exists($jsonPlayer, 'team')) { + // player->teamid can be wrong if the mode forced the team, so this is the best value + $player->teamId = $jsonPlayer->team; + $playerScore->setTeamId($jsonPlayer->team); + } + $this->playerScores[$jsonPlayer->login] = $playerScore; } }