fix score sorting & minor fix
This commit is contained in:
parent
951409f221
commit
2ab065a819
@ -39,7 +39,7 @@ use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
|||||||
class MatchManagerCore implements ManialinkPageAnswerListener, CallbackListener, CommandListener, TimerListener, CommunicationListener, Plugin {
|
class MatchManagerCore implements ManialinkPageAnswerListener, CallbackListener, CommandListener, TimerListener, CommunicationListener, Plugin {
|
||||||
|
|
||||||
const PLUGIN_ID = 152;
|
const PLUGIN_ID = 152;
|
||||||
const PLUGIN_VERSION = 1.2;
|
const PLUGIN_VERSION = 1.3;
|
||||||
const PLUGIN_NAME = 'MatchManager Core';
|
const PLUGIN_NAME = 'MatchManager Core';
|
||||||
const PLUGIN_AUTHOR = 'Beu';
|
const PLUGIN_AUTHOR = 'Beu';
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ class MatchManagerCore implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
'gamemode' => ['Champion', 'Cup', 'Knockout', 'Teams', 'Rounds'],
|
'gamemode' => ['Champion', 'Cup', 'Knockout', 'Teams', 'Rounds'],
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'default' => 5,
|
'default' => 5,
|
||||||
'description' => 'Number of rounds par map (0 = unlimited) (multiple maps doesn\'t work in KO)' ],
|
'description' => 'Number of rounds par map (0 = unlimited)' ],
|
||||||
self::SETTING_MATCH_S_ROUNDSWITHAPHASECHANGE => [
|
self::SETTING_MATCH_S_ROUNDSWITHAPHASECHANGE => [
|
||||||
'gamemode' => ['Champion'],
|
'gamemode' => ['Champion'],
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
@ -855,7 +855,6 @@ class MatchManagerCore implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
$scriptName .= "_Online.Script.txt";
|
$scriptName .= "_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);
|
||||||
|
|
||||||
@ -1309,7 +1308,6 @@ class MatchManagerCore implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
if ($current) {
|
if ($current) {
|
||||||
$current = false;
|
$current = false;
|
||||||
} elseif (($this->nbmaps + $i) <= ($this->settings_nbmapsbymatch)) {
|
} elseif (($this->nbmaps + $i) <= ($this->settings_nbmapsbymatch)) {
|
||||||
Logger::log("i: " . $i);
|
|
||||||
if ($i > 0) {
|
if ($i > 0) {
|
||||||
if ($i == 1) {
|
if ($i == 1) {
|
||||||
$message = $this->chatprefix . '$<$o$iNext Maps:$>';
|
$message = $this->chatprefix . '$<$o$iNext Maps:$>';
|
||||||
@ -1487,7 +1485,9 @@ class MatchManagerCore implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
$database = "";
|
$database = "";
|
||||||
$this->currentscore = array();
|
$this->currentscore = array();
|
||||||
$results = $structure->getPlayerScores();
|
$results = $structure->getPlayerScores();
|
||||||
$scores = array();
|
|
||||||
|
// Resort scores
|
||||||
|
usort($results, function ($a, $b) { return -($a->getMatchPoints() + $a->getRoundPoints() <=> $b->getMatchPoints() + $b->getRoundPoints()); });
|
||||||
|
|
||||||
// CUP Specific variables
|
// CUP Specific variables
|
||||||
$this->nbwinners = 0;
|
$this->nbwinners = 0;
|
||||||
@ -1499,9 +1499,9 @@ class MatchManagerCore implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
$pointsrepartition = explode(',', $pointsrepartition);
|
$pointsrepartition = explode(',', $pointsrepartition);
|
||||||
|
|
||||||
$dbquery = 'INSERT INTO `' . self::DB_ROUNDSDATA . '` (`matchid`,`timestamp`,`rank`,`login`,`matchpoints`,`roundpoints`,`time`,`teamid`) VALUES ';
|
$dbquery = 'INSERT INTO `' . self::DB_ROUNDSDATA . '` (`matchid`,`timestamp`,`rank`,`login`,`matchpoints`,`roundpoints`,`time`,`teamid`) VALUES ';
|
||||||
|
$rank = 1;
|
||||||
|
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
$rank = $result->getRank();
|
|
||||||
$player = $result->getPlayer();
|
$player = $result->getPlayer();
|
||||||
$time = $result->getPrevRaceTime();
|
$time = $result->getPrevRaceTime();
|
||||||
|
|
||||||
@ -1529,6 +1529,7 @@ class MatchManagerCore implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, "-1", "-1", $besttime, "-1")));
|
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, "-1", "-1", $besttime, "-1")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$rank++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::log('Count number of players finish: '. count($this->times));
|
Logger::log('Count number of players finish: '. count($this->times));
|
||||||
@ -1578,11 +1579,15 @@ class MatchManagerCore implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
$teamresults = $structure->getTeamScores();
|
$teamresults = $structure->getTeamScores();
|
||||||
$this->currentteamsscore = array();
|
$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 ';
|
$teamdbquery = 'INSERT INTO `' . self::DB_TEAMSDATA . '` (`matchid`,`timestamp`,`id`,`team`,`points`) VALUES ';
|
||||||
$this->currentteamsscore = [];
|
$this->currentteamsscore = [];
|
||||||
$rank = 1;
|
$rank = 1;
|
||||||
|
|
||||||
foreach ($teamresults as $teamresult) {
|
foreach ($teamresults as $teamresult) {
|
||||||
$this->currentteamsscore = array_merge($this->currentteamsscore, array(array($rank, $teamresult->getTeamId(), $teamresult->getMatchPoints())));
|
$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() . '"),';
|
$teamdbquery .= '("' . $this->matchid . '","' . $timestamp . '","' . $teamresult->getTeamId() . '","' . $teamresult->getName() . '","' . $teamresult->getMatchPoints() . '"),';
|
||||||
$rank++;
|
$rank++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user