fix cup point system
This commit is contained in:
parent
ebb5ae1e6d
commit
8b2a97bee6
@ -37,7 +37,7 @@ use ManiaControl\Maps\Map;
|
|||||||
class MatchManagerCore implements CallbackListener, CommandListener, TimerListener, CommunicationListener, Plugin {
|
class MatchManagerCore implements CallbackListener, CommandListener, TimerListener, CommunicationListener, Plugin {
|
||||||
|
|
||||||
const PLUGIN_ID = 152;
|
const PLUGIN_ID = 152;
|
||||||
const PLUGIN_VERSION = 2.4;
|
const PLUGIN_VERSION = 2.5;
|
||||||
const PLUGIN_NAME = 'MatchManager Core';
|
const PLUGIN_NAME = 'MatchManager Core';
|
||||||
const PLUGIN_AUTHOR = 'Beu';
|
const PLUGIN_AUTHOR = 'Beu';
|
||||||
|
|
||||||
@ -337,7 +337,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
private $settings_pointlimit = 100;
|
private $settings_pointlimit = 100;
|
||||||
|
|
||||||
private $nbwinners = 0;
|
private $nbwinners = 0;
|
||||||
private $nbstillalive = 0;
|
|
||||||
private $scriptSettings = array();
|
private $scriptSettings = array();
|
||||||
|
|
||||||
private $currentscore = array();
|
private $currentscore = array();
|
||||||
@ -649,6 +648,8 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
$this->postmatch = true;
|
$this->postmatch = true;
|
||||||
$this->matchid = "";
|
$this->matchid = "";
|
||||||
|
|
||||||
|
$this->nbwinners = 0;
|
||||||
|
|
||||||
$this->settings_nbroundsbymap = 5;
|
$this->settings_nbroundsbymap = 5;
|
||||||
$this->settings_nbwinner = 2;
|
$this->settings_nbwinner = 2;
|
||||||
$this->settings_nbmapsbymatch = 0;
|
$this->settings_nbmapsbymatch = 0;
|
||||||
@ -924,9 +925,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
|
|
||||||
$this->resetMatchVariables();
|
$this->resetMatchVariables();
|
||||||
|
|
||||||
// KO Specifics variables
|
|
||||||
$this->nbstillalive = 0;
|
|
||||||
|
|
||||||
// Teams Specifics variables
|
// Teams Specifics variables
|
||||||
$this->currentteamsscore = [];
|
$this->currentteamsscore = [];
|
||||||
|
|
||||||
@ -1385,12 +1383,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
usort($results, function ($a, $b) { return -($a->getMatchPoints() + $a->getRoundPoints() <=> $b->getMatchPoints() + $b->getRoundPoints()); });
|
usort($results, function ($a, $b) { return -($a->getMatchPoints() + $a->getRoundPoints() <=> $b->getMatchPoints() + $b->getRoundPoints()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
// CUP Specific variables
|
|
||||||
$this->nbwinners = 0;
|
|
||||||
|
|
||||||
// Knockout Specific variables
|
|
||||||
$this->nbstillalive = 0;
|
|
||||||
|
|
||||||
$pointsrepartition = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_S_POINTSREPARTITION);
|
$pointsrepartition = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_S_POINTSREPARTITION);
|
||||||
$pointsrepartition = explode(',', $pointsrepartition);
|
$pointsrepartition = explode(',', $pointsrepartition);
|
||||||
|
|
||||||
@ -1408,14 +1400,27 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
if ($this->currentgmbase == "Champion") {
|
if ($this->currentgmbase == "Champion") {
|
||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, $points , $result->getMapPoints(), $time, "")));
|
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, $points , $result->getMapPoints(), $time, "")));
|
||||||
} elseif ($this->currentgmbase == "Cup") {
|
} elseif ($this->currentgmbase == "Cup") {
|
||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, ($points + $roundpoints), $roundpoints, $time, "-1")));
|
// 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
|
if ($roundpoints > 0) $atleastonefinished = true; // Round is skipped if no one finishes only in cup mode
|
||||||
} elseif ($this->currentgmbase == "Rounds" ) {
|
} elseif ($this->currentgmbase == "Rounds" ) {
|
||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, ($points + $roundpoints), $roundpoints, $time, "-1")));
|
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, $matchpoints, $roundpoints, $time, "-1")));
|
||||||
} elseif ($this->currentgmbase == "Teams") {
|
} elseif ($this->currentgmbase == "Teams") {
|
||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, ($points + $roundpoints), $roundpoints, $time, $player->teamId)));
|
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, ($points + $roundpoints), $roundpoints, $time, $player->teamId)));
|
||||||
} elseif ($this->currentgmbase == "Knockout") {
|
} elseif ($this->currentgmbase == "Knockout") {
|
||||||
$this->currentscore = array_merge($this->currentscore, array(array($rank, $player->login, $points, "-1", $time, "-1")));
|
$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()))) {
|
} elseif (in_array($this->currentgmbase, ["Laps", "TimeAttack", "RoyalTimeAttack"]) && !(($time == 0 || $time == -1) && ($player->isSpectator || $player->isFakePlayer()))) {
|
||||||
$besttime = $result->getBestRaceTime();
|
$besttime = $result->getBestRaceTime();
|
||||||
|
@ -42,7 +42,7 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
|||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const PLUGIN_ID = 153;
|
const PLUGIN_ID = 153;
|
||||||
const PLUGIN_VERSION = 1.3;
|
const PLUGIN_VERSION = 1.4;
|
||||||
const PLUGIN_NAME = 'MatchManager Widget';
|
const PLUGIN_NAME = 'MatchManager Widget';
|
||||||
const PLUGIN_AUTHOR = 'Beu';
|
const PLUGIN_AUTHOR = 'Beu';
|
||||||
|
|
||||||
@ -454,11 +454,7 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
|||||||
$points = $score[2];
|
$points = $score[2];
|
||||||
if (isset($pointlimit)) {
|
if (isset($pointlimit)) {
|
||||||
if ($score[2] > $pointlimit) {
|
if ($score[2] > $pointlimit) {
|
||||||
if ($score[3] == 0 || $score[2] - $score[3] == $pointlimit) {
|
|
||||||
$points = '$0f0Winner';
|
$points = '$0f0Winner';
|
||||||
} else {
|
|
||||||
$points = '$f00Finalist';
|
|
||||||
}
|
|
||||||
} elseif ($score[2] == $pointlimit) {
|
} elseif ($score[2] == $pointlimit) {
|
||||||
$points = '$f00Finalist';
|
$points = '$f00Finalist';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user