rework score storage
This commit is contained in:
parent
0977d3a256
commit
96bb860326
@ -341,6 +341,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
private $scriptSettings = array();
|
private $scriptSettings = array();
|
||||||
|
|
||||||
private $currentscore = array();
|
private $currentscore = array();
|
||||||
|
private $preendroundscore = array();
|
||||||
private $currentteamsscore = array();
|
private $currentteamsscore = array();
|
||||||
private $playerpause = array();
|
private $playerpause = array();
|
||||||
private $pausetimer = 0;
|
private $pausetimer = 0;
|
||||||
@ -407,6 +408,8 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
$this->initTables();
|
$this->initTables();
|
||||||
|
|
||||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . "This new version has a lot of code refactoring, please contact me if you encounter any bug via discord @Beu#1337 or Twitter @AmazingBeu");
|
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . "This new version has a lot of code refactoring, please contact me if you encounter any bug via discord @Beu#1337 or Twitter @AmazingBeu");
|
||||||
|
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . "If you retrieve data from this plugin (via gsheet or others), be careful, the data format has changed");
|
||||||
|
|
||||||
|
|
||||||
//Settings
|
//Settings
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_AUTHLEVEL, AuthenticationManager::getPermissionLevelNameArray(AuthenticationManager::AUTH_LEVEL_ADMIN), "Admin level needed to use the plugin");
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_AUTHLEVEL, AuthenticationManager::getPermissionLevelNameArray(AuthenticationManager::AUTH_LEVEL_ADMIN), "Admin level needed to use the plugin");
|
||||||
@ -438,6 +441,8 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_SCORES, $this, 'handleEndRoundCallback');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_SCORES, $this, 'handleEndRoundCallback');
|
||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_STARTROUNDSTART, $this, 'handleBeginRoundCallback');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_STARTROUNDSTART, $this, 'handleBeginRoundCallback');
|
||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_WARMUPSTARTROUND, $this, 'handleStartWarmUpCallback');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_WARMUPSTARTROUND, $this, 'handleStartWarmUpCallback');
|
||||||
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_STARTMATCHSTART, $this, 'handleStartMatchStartCallback');
|
||||||
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_BEGINMAP, $this, 'handleBeginMapCallback');
|
||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_BEGINMATCH, $this, 'handleBeginMatchCallback');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_BEGINMATCH, $this, 'handleBeginMatchCallback');
|
||||||
|
|
||||||
// Register Socket commands
|
// Register Socket commands
|
||||||
@ -493,9 +498,15 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
`rank` INT(4) NOT NULL,
|
`rank` INT(4) NOT NULL,
|
||||||
`login` VARCHAR(30) NOT NULL,
|
`login` VARCHAR(30) NOT NULL,
|
||||||
`matchpoints` INT(10) NOT NULL,
|
`matchpoints` INT(10) NOT NULL,
|
||||||
|
`mappoints` INT(10) NOT NULL,
|
||||||
`roundpoints` INT(10) NOT NULL,
|
`roundpoints` INT(10) NOT NULL,
|
||||||
`time` INT(10) NOT NULL,
|
`bestracetime` INT(10) NOT NULL,
|
||||||
`teamid` VARCHAR(30) NOT NULL
|
`bestracecheckpoints` VARCHAR(1000) NOT NULL,
|
||||||
|
`bestlaptime` INT(10) NOT NULL,
|
||||||
|
`bestlapcheckpoints` VARCHAR(1000) NOT NULL,
|
||||||
|
`prevracetime` INT(10) NOT NULL,
|
||||||
|
`prevracecheckpoints` VARCHAR(1000) NOT NULL,
|
||||||
|
`teamid` INT(3) NOT NULL
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;';
|
||||||
$mysqli->query($query);
|
$mysqli->query($query);
|
||||||
if ($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
@ -504,14 +515,46 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
$query = 'CREATE TABLE IF NOT EXISTS `' . self::DB_TEAMSDATA . '` (
|
$query = 'CREATE TABLE IF NOT EXISTS `' . self::DB_TEAMSDATA . '` (
|
||||||
`matchid` VARCHAR(100) NOT NULL,
|
`matchid` VARCHAR(100) NOT NULL,
|
||||||
`timestamp` INT(10) NOT NULL,
|
`timestamp` INT(10) NOT NULL,
|
||||||
`id` VARCHAR(30) NOT NULL,
|
`rank` INT(3) NOT NULL,
|
||||||
|
`id` INT(3) NOT NULL,
|
||||||
`team` VARCHAR(30) NOT NULL,
|
`team` VARCHAR(30) NOT NULL,
|
||||||
`points` INT(10) NOT NULL
|
`matchpoints` INT(10) NOT NULL,
|
||||||
|
`mappoints` INT(10) NOT NULL,
|
||||||
|
`roundpoints` INT(10) NOT NULL
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;';
|
||||||
$mysqli->query($query);
|
$mysqli->query($query);
|
||||||
if ($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
trigger_error($mysqli->error, E_USER_ERROR);
|
trigger_error($mysqli->error, E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update table data
|
||||||
|
$mysqliconfig = $this->maniaControl->getDatabase()->getConfig();
|
||||||
|
$query = 'IF NOT EXISTS( SELECT NULL
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE `table_name` = "' . self::DB_ROUNDSDATA . '"
|
||||||
|
AND `table_schema` = "' . $mysqliconfig->name . '"
|
||||||
|
AND `column_name` = "mappoints") THEN
|
||||||
|
|
||||||
|
ALTER TABLE `' . self::DB_ROUNDSDATA . '`
|
||||||
|
ADD COLUMN `mappoints` INT(10) NOT NULL AFTER `matchpoints`,
|
||||||
|
CHANGE `time` `bestracetime` INT(10) NOT NULL,
|
||||||
|
ADD COLUMN `bestracecheckpoints` VARCHAR(1000) NOT NULL AFTER `bestracetime`,
|
||||||
|
ADD COLUMN `bestlaptime` INT(10) NOT NULL AFTER `bestracecheckpoints`,
|
||||||
|
ADD COLUMN `bestlapcheckpoints` VARCHAR(1000) NOT NULL AFTER `bestlaptime`,
|
||||||
|
ADD COLUMN `prevracetime` INT(10) NOT NULL AFTER `bestlapcheckpoints`,
|
||||||
|
ADD COLUMN `prevracecheckpoints` VARCHAR(1000) NOT NULL AFTER `prevracetime`,
|
||||||
|
MODIFY `teamid` INT(3) NOT NULL;
|
||||||
|
ALTER TABLE `' . self::DB_TEAMSDATA . '`
|
||||||
|
ADD COLUMN `rank` INT(3) NOT NULL,
|
||||||
|
MODIFY `id` INT(3) NOT NULL,
|
||||||
|
CHANGE `points` `matchpoints` INT(10) NOT NULL,
|
||||||
|
ADD COLUMN `mappoints` INT(10) NOT NULL AFTER `matchpoints`,
|
||||||
|
ADD COLUMN `roundpoints` INT(10) NOT NULL AFTER `mappoints`;
|
||||||
|
END IF;';
|
||||||
|
$mysqli->query($query);
|
||||||
|
if ($mysqli->error) {
|
||||||
|
trigger_error($mysqli->error, E_USER_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMatchStatus() {
|
public function getMatchStatus() {
|
||||||
@ -611,7 +654,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
$this->maniaControl->getSettingManager()->initSetting($this, $key, self::SETTINGS_MODE_LIST[$key]['default'], self::SETTINGS_MODE_LIST[$key]['description']);
|
$this->maniaControl->getSettingManager()->initSetting($this, $key, self::SETTINGS_MODE_LIST[$key]['default'], self::SETTINGS_MODE_LIST[$key]['description']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($settingsmode == 'Maps from file & Settings from plugin' || $settingsmode == 'All from the plugin') {
|
if ($settingsmode == 'Maps from file & Settings from plugin' || $settingsmode == 'All from the plugin') {
|
||||||
$gmsettings = $this->getGMSettings($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_GAMEMODE_BASE), $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_CUSTOM_GAMEMODE));
|
$gmsettings = $this->getGMSettings($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_GAMEMODE_BASE), $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_CUSTOM_GAMEMODE));
|
||||||
|
|
||||||
@ -645,6 +687,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
$this->matchrecover = false;
|
$this->matchrecover = false;
|
||||||
$this->pointstorecover = array();
|
$this->pointstorecover = array();
|
||||||
$this->currentscore = array();
|
$this->currentscore = array();
|
||||||
|
$this->preendroundscore = array();
|
||||||
$this->settingsloaded = false;
|
$this->settingsloaded = false;
|
||||||
$this->mapsshuffled = false;
|
$this->mapsshuffled = false;
|
||||||
$this->mapshidden = false;
|
$this->mapshidden = false;
|
||||||
@ -659,6 +702,10 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
$this->settings_nbwinner = 2;
|
$this->settings_nbwinner = 2;
|
||||||
$this->settings_nbmapsbymatch = 0;
|
$this->settings_nbmapsbymatch = 0;
|
||||||
$this->settings_pointlimit = 100;
|
$this->settings_pointlimit = 100;
|
||||||
|
|
||||||
|
$this->currentgmbase = "";
|
||||||
|
$this->currentcustomgm = "";
|
||||||
|
$this->currentsettingmode = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -673,7 +720,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
$gmsettings[$gamemodename] = $info['value'];
|
$gmsettings[$gamemodename] = $info['value'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var_dump($gmsettings);
|
|
||||||
$this->maniaControl->getClient()->setModeScriptSettings($gmsettings);
|
$this->maniaControl->getClient()->setModeScriptSettings($gmsettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,7 +745,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
if (preg_match('/^(\s*)\#Setting\s+(S_\S+)\s+(\S+)\s*(as\s|)(_\(|)("|\'|)([^\'"]*)("\)|\'\)|"|\'| |)/', $line, $matches)) {
|
if (preg_match('/^(\s*)\#Setting\s+(S_\S+)\s+(\S+)\s*(as\s|)(_\(|)("|\'|)([^\'"]*)("\)|\'\)|"|\'| |)/', $line, $matches)) {
|
||||||
$gamesettingname = $matches[2];
|
$gamesettingname = $matches[2];
|
||||||
$defaultvalue = $matches[3];
|
$defaultvalue = $matches[3];
|
||||||
if (is_float($matches[3]+0)) {
|
if (is_numeric($matches[3]) && is_float($matches[3]+0)) {
|
||||||
$type = "float";
|
$type = "float";
|
||||||
} else if (is_numeric($matches[3])) {
|
} else if (is_numeric($matches[3])) {
|
||||||
$type = "integer";
|
$type = "integer";
|
||||||
@ -817,7 +863,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
// Prepare maps in case of "All from the plugin" mode
|
// Prepare maps in case of "All from the plugin" mode
|
||||||
if ($this->currentsettingmode == 'All from the plugin' && strlen($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MODE_MAPS)) >= 1) {
|
if ($this->currentsettingmode == 'All from the plugin' && strlen($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MODE_MAPS)) >= 1) {
|
||||||
$maps = explode(',', $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MODE_MAPS));
|
$maps = explode(',', $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MODE_MAPS));
|
||||||
|
|
||||||
foreach ($maps as $map) {
|
foreach ($maps as $map) {
|
||||||
try {
|
try {
|
||||||
$mapInfo = new Map($this->maniaControl->getClient()->getMapInfo($map));
|
$mapInfo = new Map($this->maniaControl->getClient()->getMapInfo($map));
|
||||||
@ -827,7 +872,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MODE_SHUFFLE)) {
|
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MODE_SHUFFLE)) {
|
||||||
//shuffle
|
|
||||||
$this->mapsshuffled = true;
|
$this->mapsshuffled = true;
|
||||||
shuffle($maps);
|
shuffle($maps);
|
||||||
}
|
}
|
||||||
@ -877,7 +921,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
$this->maniaControl->getClient()->removeMap($map->fileName);
|
$this->maniaControl->getClient()->removeMap($map->fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->maniaControl->getClient()->InsertPlaylistFromMatchSettings($maplist); // TODO check if "All from file" if settings are loaded or not
|
$this->maniaControl->getClient()->InsertPlaylistFromMatchSettings($maplist);
|
||||||
} elseif ($this->currentsettingmode == 'All from the plugin') {
|
} elseif ($this->currentsettingmode == 'All from the plugin') {
|
||||||
if ($this->hidenextmaps) {
|
if ($this->hidenextmaps) {
|
||||||
$this->maniaControl->getClient()->addMap($this->maps[0]);
|
$this->maniaControl->getClient()->addMap($this->maps[0]);
|
||||||
@ -937,16 +981,17 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
* Function called to end the match
|
* Function called to end the match
|
||||||
*/
|
*/
|
||||||
public function MatchEnd() {
|
public function MatchEnd() {
|
||||||
|
|
||||||
if ($this->currentmap->mapType == "TrackMania\TM_Royal") {
|
|
||||||
$scriptName = "Trackmania/TM_RoyalTimeAttack_Online.Script.txt" ;
|
|
||||||
} else {
|
|
||||||
$scriptName = "Trackmania/TM_TimeAttack_Online.Script.txt" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->getClient()->setScriptName($scriptName);
|
// Load TimeAttack gamemode if possible
|
||||||
|
if ($this->currentmap->mapType == "TrackMania\TM_Race") {
|
||||||
|
$scriptname = "Trackmania/TM_TimeAttack_Online.Script.txt" ;
|
||||||
|
} else if ($this->currentmap->mapType == "TrackMania\TM_Royal") {
|
||||||
|
$scriptname = "Trackmania/TM_RoyalTimeAttack_Online.Script.txt" ;
|
||||||
|
}
|
||||||
|
if (isset($scriptname)) {
|
||||||
|
Logger::log("Loading script: " . $scriptname);
|
||||||
|
$this->maniaControl->getClient()->setScriptName($scriptname);
|
||||||
|
}
|
||||||
// MYSQL DATA INSERT
|
// MYSQL DATA INSERT
|
||||||
$settings = json_encode($this->maniaControl->getClient()->getModeScriptSettings());
|
$settings = json_encode($this->maniaControl->getClient()->getModeScriptSettings());
|
||||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||||
@ -961,7 +1006,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
|
|
||||||
// End notifications
|
// End notifications
|
||||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . "Match finished");
|
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . "Match finished");
|
||||||
Logger::log("Loading script: $scriptName");
|
|
||||||
Logger::log("Match finished");
|
Logger::log("Match finished");
|
||||||
|
|
||||||
$this->resetMatchVariables();
|
$this->resetMatchVariables();
|
||||||
@ -979,22 +1023,26 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
*/
|
*/
|
||||||
public function MatchStop() {
|
public function MatchStop() {
|
||||||
Logger::log("Match stop");
|
Logger::log("Match stop");
|
||||||
if ($this->currentmap->mapType == "TrackMania\TM_Royal") {
|
|
||||||
$scriptName = "Trackmania/TM_RoyalTimeAttack_Online.Script.txt" ;
|
|
||||||
} else {
|
|
||||||
$scriptName = "Trackmania/TM_TimeAttack_Online.Script.txt" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Trigger Callback
|
// Trigger Callback
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_STOPMATCH, $this->matchid, $this->currentscore, $this->currentteamsscore);
|
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_STOPMATCH, $this->matchid, $this->currentscore, $this->currentteamsscore);
|
||||||
|
|
||||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Match stopped by an Admin!');
|
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Match stopped by an Admin!');
|
||||||
$this->maniaControl->getClient()->setScriptName($scriptName);
|
|
||||||
Logger::log("Loading script: $scriptName");
|
// Load TimeAttack gamemode if possible
|
||||||
|
if ($this->currentmap->mapType == "TrackMania\TM_Race") {
|
||||||
|
$scriptname = "Trackmania/TM_TimeAttack_Online.Script.txt" ;
|
||||||
|
} else if ($this->currentmap->mapType == "TrackMania\TM_Royal") {
|
||||||
|
$scriptname = "Trackmania/TM_RoyalTimeAttack_Online.Script.txt" ;
|
||||||
|
}
|
||||||
|
if (isset($scriptname)) {
|
||||||
|
Logger::log("Loading script: " . $scriptname);
|
||||||
|
$this->maniaControl->getClient()->setScriptName($scriptname);
|
||||||
|
}
|
||||||
|
|
||||||
$this->resetMatchVariables();
|
$this->resetMatchVariables();
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . 'Can not stop match: ' . $e->getMessage());
|
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . 'Can not stop match: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
@ -1223,13 +1271,12 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle callback "BeginMatch"
|
* Handle XMLRPC callback "Maniaplanet.StartMatch_Start"
|
||||||
*/
|
*/
|
||||||
public function handleBeginMatchCallback() {
|
public function handleStartMatchStartCallback() {
|
||||||
Logger::log("handleBeginMatchCallback");
|
Logger::log("handleStartMatchStartCallback");
|
||||||
|
|
||||||
if ($this->matchStarted === true) {
|
if ($this->matchStarted) {
|
||||||
if (!($this->settingsloaded)) {
|
|
||||||
Logger::log("Loading settings");
|
Logger::log("Loading settings");
|
||||||
$this->settingsloaded = true;
|
$this->settingsloaded = true;
|
||||||
|
|
||||||
@ -1239,10 +1286,45 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->updateGMvariables();
|
$this->updateGMvariables();
|
||||||
|
} else if ($this->postmatch) {
|
||||||
|
$this->postmatch = false;
|
||||||
|
|
||||||
Logger::log("Restarting Map for load settings");
|
Logger::log("Load PostMatch Game mode Settings");
|
||||||
|
$postmatchsettings = [
|
||||||
|
self::SETTING_MATCH_S_FORCELAPSNB => 0,
|
||||||
|
self::SETTING_MATCH_S_RESPAWNBEHAVIOUR => 0,
|
||||||
|
self::SETTING_MATCH_S_WARMUPNB => 0,
|
||||||
|
self::SETTING_MATCH_S_TIMELIMIT => 600
|
||||||
|
];
|
||||||
|
$currentgmsettings = $this->maniaControl->getClient()->getModeScriptSettings();
|
||||||
|
foreach ($postmatchsettings as $gamesettingname => $value) {
|
||||||
|
if (!array_key_exists($gamesettingname,$currentgmsettings)) {
|
||||||
|
unset($postmatchsettings[$gamesettingname]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->maniaControl->getClient()->setModeScriptSettings($postmatchsettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Maniacontrol callback "BeginMatch"
|
||||||
|
*/
|
||||||
|
public function handleBeginMatchCallback() {
|
||||||
|
Logger::log("handleStartMatchStartCallback");
|
||||||
|
|
||||||
|
if ($this->matchStarted && !$this->settingsloaded) {
|
||||||
|
Logger::log("Restarting map to restart match data");
|
||||||
$this->maniaControl->getClient()->restartMap();
|
$this->maniaControl->getClient()->restartMap();
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Maniacontrol callback "BeginMap"
|
||||||
|
*/
|
||||||
|
public function handleBeginMapCallback() {
|
||||||
|
Logger::log("handleBeginMapCallback");
|
||||||
|
if ($this->matchStarted) {
|
||||||
$this->nbmaps++;
|
$this->nbmaps++;
|
||||||
$this->nbrounds = 0;
|
$this->nbrounds = 0;
|
||||||
|
|
||||||
@ -1265,7 +1347,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($this->settings_nbmapsbymatch > 0 && $i < $this->settings_nbmapsbymatch - 1 && $this->nbmaps < $this->settings_nbmapsbymatch) || ($this->settings_nbmapsbymatch <= 0 && ($totalnbmaps >= 2 || count($this->maps) >= 2))) { // TODO manage maps in queue added by an admin
|
if (($this->settings_nbmapsbymatch > 0 && $i < $this->settings_nbmapsbymatch - 1 && $this->nbmaps < $this->settings_nbmapsbymatch) || ($this->settings_nbmapsbymatch <= 0 && ($totalnbmaps >= 2 || count($this->maps) >= 2))) { // TODO manage maps in queue added by an admin
|
||||||
$message = $this->chatprefix . '$<$o$iNext Maps:$>';
|
$message = $this->chatprefix . '$<$o$iNext Maps:$>';
|
||||||
|
|
||||||
@ -1321,32 +1402,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_BEGINMAP,$this->matchid, $currentstatus, $this->currentmap);
|
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_BEGINMAP,$this->matchid, $currentstatus, $this->currentmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->postmatch) {
|
|
||||||
$scriptName = $this->maniaControl->getClient()->getScriptName()['CurrentValue'];
|
|
||||||
Logger::log("scriptName: " . $scriptName);
|
|
||||||
if ($scriptName == "Trackmania/TM_TimeAttack_Online.Script.txt" || $scriptName == "Trackmania/TM_RoyalTimeAttack_Online.Script.txt") {
|
|
||||||
$this->postmatch = false;
|
|
||||||
|
|
||||||
Logger::log("Load Script Settings");
|
|
||||||
$postmatchsettings = [
|
|
||||||
self::SETTING_MATCH_S_FORCELAPSNB => 0,
|
|
||||||
self::SETTING_MATCH_S_RESPAWNBEHAVIOUR => 0,
|
|
||||||
self::SETTING_MATCH_S_TIMELIMIT => 600
|
|
||||||
];
|
|
||||||
if ($scriptName == "Trackmania/TM_TimeAttack_Online.Script.txt") {
|
|
||||||
$postmatchsettings[self::SETTING_MATCH_S_WARMUPNB] = 0;
|
|
||||||
}
|
|
||||||
$this->maniaControl->getClient()->setModeScriptSettings($postmatchsettings);
|
|
||||||
|
|
||||||
Logger::log("Restarting Map for load settings");
|
|
||||||
$this->maniaControl->getClient()->restartMap();
|
|
||||||
} else {
|
|
||||||
// Depending of the load of the server and the match gamemode, the script could be not loaded, this is a workaround to reload thhe script
|
|
||||||
$this->maniaControl->getClient()->restartMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle callback "WarmUp.StartRound"
|
* Handle callback "WarmUp.StartRound"
|
||||||
@ -1396,90 +1451,91 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
Logger::log("handleEndRoundCallback-" . $structure->getSection());
|
Logger::log("handleEndRoundCallback-" . $structure->getSection());
|
||||||
if ($this->matchStarted && $this->settingsloaded && !$this->postmatch) {
|
if ($this->matchStarted && $this->settingsloaded && !$this->postmatch) {
|
||||||
Logger::log("Section: " . $structure->getSection());
|
Logger::log("Section: " . $structure->getSection());
|
||||||
if ($structure->getSection() == "EndMatch") {
|
if ($structure->getSection() == "EndMatchEarly") {
|
||||||
$this->MatchEnd();
|
$this->MatchEnd();
|
||||||
} elseif ($structure->getSection() == "EndMap") {
|
} elseif ($structure->getSection() == "EndMap" && $this->hidenextmaps && isset($this->maps[$this->nbmaps])) {
|
||||||
if ($this->hidenextmaps && isset($this->maps[$this->nbmaps])) {
|
|
||||||
$this->maniaControl->getClient()->addMap($this->maps[$this->nbmaps]);
|
$this->maniaControl->getClient()->addMap($this->maps[$this->nbmaps]);
|
||||||
}
|
} elseif ($structure->getSection() == "PreEndRound") {
|
||||||
} else {
|
$this->preendroundscore = $structure->getPlayerScores();
|
||||||
|
} elseif ($structure->getSection() == "EndRound") {
|
||||||
$timestamp = time();
|
$timestamp = time();
|
||||||
|
|
||||||
if ($structure->getSection() == "PreEndRound" && in_array($this->currentgmbase, ["Cup", "Teams", "Rounds"])) {
|
|
||||||
$realSection = true;
|
|
||||||
} elseif ($structure->getSection() == "EndRound" && in_array($this->currentgmbase, ["Champion", "Knockout", "Laps", "TimeAttack", "RoyalTimeAttack"])) {
|
|
||||||
$realSection = true;
|
|
||||||
} else {
|
|
||||||
$realSection = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($realSection) {
|
|
||||||
if ($this->nbmaps != 0 and ($this->nbrounds != $this->settings_nbroundsbymap || $this->nbrounds == 0 )) {
|
if ($this->nbmaps != 0 and ($this->nbrounds != $this->settings_nbroundsbymap || $this->nbrounds == 0 )) {
|
||||||
$database = "";
|
//
|
||||||
|
// Players Scores
|
||||||
|
//
|
||||||
$this->currentscore = array();
|
$this->currentscore = array();
|
||||||
$results = $structure->getPlayerScores();
|
$results = $structure->getPlayerScores();
|
||||||
|
|
||||||
// Resort scores
|
|
||||||
if ($structure->getSection() == "PreEndRound") {
|
|
||||||
usort($results, function ($a, $b) { return -($a->getMatchPoints() + $a->getRoundPoints() <=> $b->getMatchPoints() + $b->getRoundPoints()); });
|
|
||||||
}
|
|
||||||
|
|
||||||
$pointsrepartition = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_S_POINTSREPARTITION);
|
|
||||||
$pointsrepartition = explode(',', $pointsrepartition);
|
|
||||||
|
|
||||||
$dbquery = 'INSERT INTO `' . self::DB_ROUNDSDATA . '` (`matchid`,`timestamp`,`rank`,`login`,`matchpoints`,`roundpoints`,`time`,`teamid`) VALUES ';
|
|
||||||
$rank = 1;
|
|
||||||
|
|
||||||
foreach ($results as $result) {
|
|
||||||
$player = $result->getPlayer();
|
|
||||||
$time = $result->getPrevRaceTime();
|
|
||||||
|
|
||||||
if (in_array($this->currentgmbase, ["Champion", "Cup", "Knockout", "Teams", "Rounds"]) && !($result->getMatchPoints() == 0 && ($player->isSpectator || $player->isFakePlayer()))) {
|
|
||||||
$roundpoints = $result->getRoundPoints();
|
|
||||||
$points = $result->getMatchPoints();
|
|
||||||
|
|
||||||
if ($this->currentgmbase == "Champion") {
|
|
||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, $points , $result->getMapPoints(), $time, "")));
|
|
||||||
} elseif ($this->currentgmbase == "Cup") {
|
|
||||||
// Bypass false winner because of the sum of points
|
|
||||||
if ($points + $roundpoints > $this->settings_pointlimit && $roundpoints > 0) {
|
|
||||||
if ($points == $this->settings_pointlimit) { // new winner
|
|
||||||
var_dump("settings_pointlimit: " . $this->settings_pointlimit . " / settings_nbwinners: " . $this->settings_nbwinners . " / nbwinners: " . $this->nbwinners);
|
|
||||||
$matchpoints = $this->settings_pointlimit + 1 + $this->settings_nbwinners - $this->nbwinners;
|
|
||||||
$this->nbwinners++;
|
|
||||||
} else {
|
|
||||||
$matchpoints = $this->settings_pointlimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$matchpoints = $points + $roundpoints;
|
|
||||||
}
|
|
||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, $matchpoints, $roundpoints, $time, "-1")));
|
|
||||||
if ($roundpoints > 0) $atleastonefinished = true; // Round is skipped if no one finishes only in cup mode
|
|
||||||
} elseif ($this->currentgmbase == "Rounds" ) {
|
|
||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, ($points + $roundpoints), $roundpoints, $time, "-1")));
|
|
||||||
} elseif ($this->currentgmbase == "Teams") {
|
|
||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, ($points + $roundpoints), $roundpoints, $time, $player->teamId)));
|
|
||||||
} elseif ($this->currentgmbase == "Knockout") {
|
|
||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, $points, "-1", $time, "-1"))); //TODO check
|
|
||||||
}
|
|
||||||
} elseif (in_array($this->currentgmbase, ["Laps", "TimeAttack", "RoyalTimeAttack"]) && !(($time == 0 || $time == -1) && ($player->isSpectator || $player->isFakePlayer()))) {
|
|
||||||
$besttime = $result->getBestRaceTime();
|
|
||||||
|
|
||||||
if ($this->currentgmbase == "RoyalTimeAttack") {
|
if ($this->currentgmbase == "RoyalTimeAttack") {
|
||||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . "No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
|
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . "No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
|
||||||
Logger::Log("No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
|
Logger::Log("No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
|
||||||
}
|
}
|
||||||
if ($this->currentgmbase == "Laps" || $this->currentgmbase == "RoyalTimeAttack") {
|
|
||||||
$nbcp = count($result->getBestRaceCheckpoints());
|
//$rank = 1;
|
||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, $nbcp, "-1", $besttime, "-1")));
|
foreach ($results as $result) {
|
||||||
} elseif ($this->currentgmbase == "TimeAttack") {
|
$rank = $result->getRank();
|
||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, "-1", "-1", $besttime, "-1")));
|
$player = $result->getPlayer();
|
||||||
|
$matchpoints = $result->getMatchPoints();
|
||||||
|
$mappoints = $result->getMapPoints();
|
||||||
|
$roundpoints = $result->getRoundPoints();
|
||||||
|
$bestracetime = $result->getBestRaceTime();
|
||||||
|
$bestracecheckpoints = implode(",", $result->getBestRaceCheckpoints());
|
||||||
|
$bestlaptime = $result->getBestLapTime();
|
||||||
|
$bestlapcheckpoints = implode(",", $result->getBestLapCheckpoints());
|
||||||
|
$prevracetime = $result->getPrevRaceTime();
|
||||||
|
$prevracecheckpoints = implode(",", $result->getPrevRaceCheckpoints());
|
||||||
|
|
||||||
|
if (count($this->preendroundscore) > 0) {
|
||||||
|
foreach ($this->preendroundscore as $k => $preendroundresult) {
|
||||||
|
if ($preendroundresult->getPlayer() === $player) {
|
||||||
|
if ($roundpoints == 0 && $preendroundresult->getRoundPoints() != 0) {
|
||||||
|
$roundpoints = $preendroundresult->getRoundPoints();
|
||||||
}
|
}
|
||||||
}
|
if ($mappoints == 0 && $preendroundresult->getMapPoints() != 0) {
|
||||||
$rank++;
|
$mappoints = $preendroundresult->getMapPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unset($this->preendroundscore[$k]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->currentscore = array_merge($this->currentscore, array(
|
||||||
|
array($rank, $player->login, $matchpoints, $mappoints, $roundpoints, $bestracetime, $bestracecheckpoints, $bestlaptime, $bestlapcheckpoints, $prevracetime, $prevracecheckpoints, $player->teamId)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Teams Scores
|
||||||
|
//
|
||||||
|
$this->currentteamsscore = array();
|
||||||
|
$teamresults = $structure->getTeamScores();
|
||||||
|
|
||||||
|
if (count($teamresults) > 1) {
|
||||||
|
// Resort scores
|
||||||
|
usort($teamresults, function ($a, $b) { return -($a->getMatchPoints() <=> $b->getMatchPoints()); });
|
||||||
|
|
||||||
|
$rank = 1;
|
||||||
|
foreach ($teamresults as $teamresult) {
|
||||||
|
$teamid = $teamresult->getTeamId();
|
||||||
|
$teamname = $teamresult->getName();
|
||||||
|
$matchpoints = $teamresult->getMatchPoints();
|
||||||
|
$mappoints = $teamresult->getMapPoints();
|
||||||
|
$roundpoints = $teamresult->getRoundPoints();
|
||||||
|
|
||||||
|
$this->currentteamsscore = array_merge($this->currentteamsscore, array(
|
||||||
|
array($rank, $teamid, $teamname, $matchpoints, $mappoints, $roundpoints)
|
||||||
|
));
|
||||||
|
$rank++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// End Round Routines
|
||||||
|
//
|
||||||
|
$this->preendroundscore = array();
|
||||||
if (!$this->pauseon && !$this->skipround) {
|
if (!$this->pauseon && !$this->skipround) {
|
||||||
if ($this->currentgmbase != "Cup" || ($this->currentgmbase == "Cup" && isset($atleastonefinished) && $atleastonefinished)) { // Round is skipped if no one finishes only in cup mode
|
if ($this->currentgmbase != "Cup" || ($this->currentgmbase == "Cup" && isset($atleastonefinished) && $atleastonefinished)) { // Round is skipped if no one finishes only in cup mode
|
||||||
$this->nbrounds++;
|
$this->nbrounds++;
|
||||||
@ -1493,7 +1549,9 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
Logger::log("Round without elimination");
|
Logger::log("Round without elimination");
|
||||||
}
|
}
|
||||||
|
|
||||||
// MYSQL DATA INSERT
|
//
|
||||||
|
// MySQL queries
|
||||||
|
//
|
||||||
$settings = json_encode($this->maniaControl->getClient()->getModeScriptSettings());
|
$settings = json_encode($this->maniaControl->getClient()->getModeScriptSettings());
|
||||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||||
|
|
||||||
@ -1507,6 +1565,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Round data
|
// Round data
|
||||||
|
$dbquery = 'INSERT INTO `' . self::DB_ROUNDSDATA . '` (`matchid`,`timestamp`,`rank`,`login`,`matchpoints`,`mappoints`,`roundpoints`,`bestracetime`,`bestracecheckpoints`,`bestlaptime`,`bestlapcheckpoints`,`prevracetime`,`prevracecheckpoints`,`teamid`) VALUES ';
|
||||||
foreach ($this->currentscore as $value) {
|
foreach ($this->currentscore as $value) {
|
||||||
$dbquery .= '("' . $this->matchid . '","' . $timestamp . '","' . implode('","',$value) . '"),';
|
$dbquery .= '("' . $this->matchid . '","' . $timestamp . '","' . implode('","',$value) . '"),';
|
||||||
}
|
}
|
||||||
@ -1516,28 +1575,11 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
trigger_error($mysqli->error);
|
trigger_error($mysqli->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::log("Rounds finished: " . $this->nbrounds);
|
// Teams Rounds data
|
||||||
|
if (count($teamresults) > 1) {
|
||||||
// Trigger Callback
|
$teamdbquery = 'INSERT INTO `' . self::DB_TEAMSDATA . '` (`matchid`,`timestamp`,`rank`,`id`,`team`,`matchpoints`,`mappoints`,`roundpoints`) VALUES ';
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_ENDROUND, $this->matchid, $this->currentscore, []);
|
foreach ($this->currentteamsscore as $value) {
|
||||||
}
|
$teamdbquery .= '("' . $this->matchid . '","' . $timestamp . '","' . implode('","',$value) . '"),';
|
||||||
} elseif ($structure->getSection() == "EndRound" && $this->currentgmbase == "Teams") {
|
|
||||||
|
|
||||||
// Teams Specific variables
|
|
||||||
$teamresults = $structure->getTeamScores();
|
|
||||||
$this->currentteamsscore = array();
|
|
||||||
|
|
||||||
// Resort scores
|
|
||||||
usort($results, function ($a, $b) { return -($a->getMatchPoints() <=> $b->getMatchPoints()); });
|
|
||||||
|
|
||||||
$teamdbquery = 'INSERT INTO `' . self::DB_TEAMSDATA . '` (`matchid`,`timestamp`,`id`,`team`,`points`) VALUES ';
|
|
||||||
$this->currentteamsscore = [];
|
|
||||||
$rank = 1;
|
|
||||||
|
|
||||||
foreach ($teamresults as $teamresult) {
|
|
||||||
$this->currentteamsscore = array_merge($this->currentteamsscore, array(array($rank, $teamresult->getTeamId(), $teamresult->getName(), $teamresult->getMatchPoints())));
|
|
||||||
$teamdbquery .= '("' . $this->matchid . '","' . $timestamp . '","' . $teamresult->getTeamId() . '","' . $teamresult->getName() . '","' . $teamresult->getMatchPoints() . '"),';
|
|
||||||
$rank++;
|
|
||||||
}
|
}
|
||||||
$teamdbquery = substr($teamdbquery, 0, -1);
|
$teamdbquery = substr($teamdbquery, 0, -1);
|
||||||
|
|
||||||
@ -1547,6 +1589,9 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
if ($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
trigger_error($mysqli->error);
|
trigger_error($mysqli->error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::log("Rounds finished: " . $this->nbrounds);
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_ENDROUND, $this->matchid, $this->currentscore, $this->currentteamsscore);
|
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_ENDROUND, $this->matchid, $this->currentscore, $this->currentteamsscore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,7 +426,7 @@ class MatchManagerGSheet implements CallbackListener, CommandListener, Plugin {
|
|||||||
$data->data[2]->values = $currentscore;
|
$data->data[2]->values = $currentscore;
|
||||||
|
|
||||||
$data->data[3] = new \stdClass;
|
$data->data[3] = new \stdClass;
|
||||||
$data->data[3]->range = "'" . $sheetname . "'!K2";
|
$data->data[3]->range = "'" . $sheetname . "'!Q2";
|
||||||
$data->data[3]->values = $currentteamsscore;
|
$data->data[3]->values = $currentteamsscore;
|
||||||
|
|
||||||
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, 'https://sheets.googleapis.com/v4/spreadsheets/' . $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET) . '/values:batchUpdate');
|
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, 'https://sheets.googleapis.com/v4/spreadsheets/' . $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET) . '/values:batchUpdate');
|
||||||
@ -589,7 +589,7 @@ class MatchManagerGSheet implements CallbackListener, CommandListener, Plugin {
|
|||||||
$data->requests[$i]->repeatCell->range->startRowIndex = 0;
|
$data->requests[$i]->repeatCell->range->startRowIndex = 0;
|
||||||
$data->requests[$i]->repeatCell->range->endRowIndex = 1;
|
$data->requests[$i]->repeatCell->range->endRowIndex = 1;
|
||||||
$data->requests[$i]->repeatCell->range->startColumnIndex = 3;
|
$data->requests[$i]->repeatCell->range->startColumnIndex = 3;
|
||||||
$data->requests[$i]->repeatCell->range->endColumnIndex = 9;
|
$data->requests[$i]->repeatCell->range->endColumnIndex = 15;
|
||||||
$data->requests[$i]->repeatCell->cell = new \stdClass;
|
$data->requests[$i]->repeatCell->cell = new \stdClass;
|
||||||
$data->requests[$i]->repeatCell->cell->userEnteredFormat = new \stdClass;
|
$data->requests[$i]->repeatCell->cell->userEnteredFormat = new \stdClass;
|
||||||
$data->requests[$i]->repeatCell->cell->userEnteredFormat->backgroundColor = new \stdClass;
|
$data->requests[$i]->repeatCell->cell->userEnteredFormat->backgroundColor = new \stdClass;
|
||||||
@ -609,8 +609,8 @@ class MatchManagerGSheet implements CallbackListener, CommandListener, Plugin {
|
|||||||
$data->requests[$i]->repeatCell->range->sheetId = $sheetid;
|
$data->requests[$i]->repeatCell->range->sheetId = $sheetid;
|
||||||
$data->requests[$i]->repeatCell->range->startRowIndex = 0;
|
$data->requests[$i]->repeatCell->range->startRowIndex = 0;
|
||||||
$data->requests[$i]->repeatCell->range->endRowIndex = 1;
|
$data->requests[$i]->repeatCell->range->endRowIndex = 1;
|
||||||
$data->requests[$i]->repeatCell->range->startColumnIndex = 10;
|
$data->requests[$i]->repeatCell->range->startColumnIndex = 16;
|
||||||
$data->requests[$i]->repeatCell->range->endColumnIndex = 14;
|
$data->requests[$i]->repeatCell->range->endColumnIndex = 22;
|
||||||
$data->requests[$i]->repeatCell->cell = new \stdClass;
|
$data->requests[$i]->repeatCell->cell = new \stdClass;
|
||||||
$data->requests[$i]->repeatCell->cell->userEnteredFormat = new \stdClass;
|
$data->requests[$i]->repeatCell->cell->userEnteredFormat = new \stdClass;
|
||||||
$data->requests[$i]->repeatCell->cell->userEnteredFormat->backgroundColor = new \stdClass;
|
$data->requests[$i]->repeatCell->cell->userEnteredFormat->backgroundColor = new \stdClass;
|
||||||
@ -633,7 +633,7 @@ class MatchManagerGSheet implements CallbackListener, CommandListener, Plugin {
|
|||||||
Logger::logError('Error while Sending data: ' . print_r($error, true));
|
Logger::logError('Error while Sending data: ' . print_r($error, true));
|
||||||
}
|
}
|
||||||
// Clear Scoreboards data
|
// Clear Scoreboards data
|
||||||
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, 'https://sheets.googleapis.com/v4/spreadsheets/' . $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET) . '/values/' . urlencode("'". $sheetname . "'") . '!A1:N300:clear');
|
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, 'https://sheets.googleapis.com/v4/spreadsheets/' . $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET) . '/values/' . urlencode("'". $sheetname . "'") . '!A1:V300:clear');
|
||||||
$asyncHttpRequest->setHeaders(array("Authorization: Bearer " . $this->access_token));
|
$asyncHttpRequest->setHeaders(array("Authorization: Bearer " . $this->access_token));
|
||||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname) {
|
$asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname) {
|
||||||
$data = json_decode($json);
|
$data = json_decode($json);
|
||||||
@ -650,11 +650,11 @@ class MatchManagerGSheet implements CallbackListener, CommandListener, Plugin {
|
|||||||
|
|
||||||
$data->data[1] = new \stdClass;
|
$data->data[1] = new \stdClass;
|
||||||
$data->data[1]->range = "'" . $sheetname . "'!D1";
|
$data->data[1]->range = "'" . $sheetname . "'!D1";
|
||||||
$data->data[1]->values = array(array("Rank","Login", "MatchPoints", "RoundPoints","Time","Team"));
|
$data->data[1]->values = array(array("Rank","Login", "MatchPoints", "MapPoints", "RoundPoints","BestRaceTime","BestRaceCheckpoints","BestLaptime","BestLapCheckpoints","PrevRaceTime","PrevRaceCheckpoints","Team"));
|
||||||
|
|
||||||
$data->data[2] = new \stdClass;
|
$data->data[2] = new \stdClass;
|
||||||
$data->data[2]->range = "'" . $sheetname . "'!K1";
|
$data->data[2]->range = "'" . $sheetname . "'!Q1";
|
||||||
$data->data[2]->values = array(array("Rank","Team ID", "Name", "MatchPoints"));
|
$data->data[2]->values = array(array("Rank","Team ID", "Name", "MatchPoints", "MapPoints", "RoundPoints"));
|
||||||
|
|
||||||
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, 'https://sheets.googleapis.com/v4/spreadsheets/' . $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET) . '/values:batchUpdate');
|
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, 'https://sheets.googleapis.com/v4/spreadsheets/' . $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET) . '/values:batchUpdate');
|
||||||
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON);
|
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON);
|
||||||
|
@ -426,12 +426,21 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
|||||||
$pointlimit = $this->MatchManagerCore->getMatchPointsLimit();
|
$pointlimit = $this->MatchManagerCore->getMatchPointsLimit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->gmbase == "Teams") {
|
||||||
|
// Sort if possible
|
||||||
|
if (count($currentscore) > 1) {
|
||||||
|
usort($currentscore, function($a, $b) {
|
||||||
|
return $b[3] - $a[3];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// Sort if possible
|
// Sort if possible
|
||||||
if (count($currentscore) > 1) {
|
if (count($currentscore) > 1) {
|
||||||
usort($currentscore, function($a, $b) {
|
usort($currentscore, function($a, $b) {
|
||||||
return $b[2] - $a[2];
|
return $b[2] - $a[2];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$lines = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERWIDGET_LIVE_LINESCOUNT);
|
$lines = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERWIDGET_LIVE_LINESCOUNT);
|
||||||
$posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERWIDGET_LIVE_POSX);
|
$posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERWIDGET_LIVE_POSX);
|
||||||
@ -451,11 +460,16 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->gmbase == "Teams") {
|
||||||
|
$points = $score[3];
|
||||||
|
} else {
|
||||||
$points = $score[2];
|
$points = $score[2];
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($pointlimit)) {
|
if (isset($pointlimit)) {
|
||||||
if ($score[2] > $pointlimit) {
|
if ($points > $pointlimit) {
|
||||||
$points = '$0f0Winner';
|
$points = '$0f0Winner';
|
||||||
} elseif ($score[2] == $pointlimit) {
|
} elseif ($points == $pointlimit) {
|
||||||
$points = '$f00Finalist';
|
$points = '$f00Finalist';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user