From 76b5d78106cd4c0c1dbb9564a643705f575215c6 Mon Sep 17 00:00:00 2001 From: beu Date: Mon, 24 Jan 2022 14:51:37 +0100 Subject: [PATCH] fix #4 & fix last round in "All Rounds Data" --- MatchManagerSuite/MatchManagerGSheet.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/MatchManagerSuite/MatchManagerGSheet.php b/MatchManagerSuite/MatchManagerGSheet.php index a45dd0b..cf18138 100644 --- a/MatchManagerSuite/MatchManagerGSheet.php +++ b/MatchManagerSuite/MatchManagerGSheet.php @@ -66,7 +66,7 @@ class MatchManagerGSheet implements CallbackListener, CommandListener, Plugin { "All Rounds Data"=> [ "ScoreTable_endColumnIndex" => 17, "TeamsScoreTable_startColumnIndex" => 18, - "TeamsScoreTable_endColumnIndex" => 24, + "TeamsScoreTable_endColumnIndex" => 26, "ScoreTable_BeginLetter" => "D", "ScoreTable_EndLetter" => "Q", "TeamsScoreTable_BeginLetter" => "S", @@ -433,13 +433,14 @@ class MatchManagerGSheet implements CallbackListener, CommandListener, Plugin { public function UpdateGSheetData(String $matchid, Array $currentscore, Array $currentteamsscore) { if ($this->refreshTokenIfNeeded()) { $sheetname = $this->getSheetName(); + $matchstatus = $this->matchstatus; $data = new \stdClass; $data->valueInputOption = "RAW"; $data->data[0] = new \stdClass; $data->data[0]->range = "'" . $sheetname . "'!B2"; - $data->data[0]->values = array(array($this->matchstatus),array($this->MatchManagerCore->getCountMap()),array($this->MatchManagerCore->getCountRound()),array($this->maniaControl->getPlayerManager()->getPlayerCount()),array($this->maniaControl->getPlayerManager()->getSpectatorCount())); + $data->data[0]->values = array(array($matchstatus),array($this->MatchManagerCore->getCountMap()),array($this->MatchManagerCore->getCountRound()),array($this->maniaControl->getPlayerManager()->getPlayerCount()),array($this->maniaControl->getPlayerManager()->getSpectatorCount())); $data->data[1] = new \stdClass; $data->data[1]->range = "'" . $sheetname . "'!A9"; @@ -469,7 +470,7 @@ class MatchManagerGSheet implements CallbackListener, CommandListener, Plugin { $asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON); $asyncHttpRequest->setHeaders(array("Authorization: Bearer " . $this->access_token)); $asyncHttpRequest->setContent(json_encode($data)); - $asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname, $currentscore, $currentteamsscore) { + $asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname, $currentscore, $currentteamsscore, $matchstatus) { if ($error) { Logger::logError('Error: ' . $error); return; @@ -480,8 +481,7 @@ class MatchManagerGSheet implements CallbackListener, CommandListener, Plugin { return; } - if ($this->currentdatamode == "All Rounds Data" && $this->matchstatus == "running") { - + if ($this->currentdatamode == "All Rounds Data" && $matchstatus == "running") { $newcurrentscore = []; foreach ($currentscore as $score) { array_push($newcurrentscore,array_merge([$this->MatchManagerCore->getMapNumber() , $this->MatchManagerCore->getRoundNumber()], $score)); @@ -541,14 +541,17 @@ class MatchManagerGSheet implements CallbackListener, CommandListener, Plugin { } function onCallbackEndRound(String $matchid, Array $currentscore, Array $currentteamsscore) { + Logger::Log('onCallbackEndRound'); $this->matchstatus = "running"; $this->UpdateGSheetData($matchid, $currentscore, $currentteamsscore); } function onCallbackEndMatch(String $matchid, Array $currentscore, Array $currentteamsscore) { + Logger::Log('onCallbackEndMatch'); $this->matchstatus = "ended"; $this->UpdateGSheetData($matchid, $currentscore, $currentteamsscore); } function onCallbackStopMatch(String $matchid, Array $currentscore, Array $currentteamsscore) { + Logger::Log('onCallbackStopMatch'); $this->matchstatus = "stopped"; $this->UpdateGSheetData($matchid, $currentscore, $currentteamsscore); } @@ -768,4 +771,4 @@ class MatchManagerGSheet implements CallbackListener, CommandListener, Plugin { $asyncHttpRequest->postData(1000); } } -} \ No newline at end of file +}