use seed setting to improve step readability and easier integrations
This commit is contained in:
1 file changed
+23
-6
@@ -33,7 +33,7 @@ class MatchManagerPickAndBan implements ManialinkPageAnswerListener, CallbackLis
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 223;
|
||||
const PLUGIN_VERSION = 0.5;
|
||||
const PLUGIN_VERSION = 0.6;
|
||||
const PLUGIN_NAME = 'MatchManager Pick & Ban';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@@ -41,6 +41,7 @@ class MatchManagerPickAndBan implements ManialinkPageAnswerListener, CallbackLis
|
||||
|
||||
// Settings
|
||||
const SETTING_ENABLE = 'Enable pick & ban';
|
||||
const SETTING_SEEDED_PLAYERS = 'Seeded players login';
|
||||
const SETTING_STEPCONFIG = 'Step config';
|
||||
const SETTING_STEPDURATION = 'Step duration';
|
||||
const SETTING_DURATIONAFTERTHELASTSTEP = 'Duration after the last step';
|
||||
@@ -127,7 +128,8 @@ class MatchManagerPickAndBan implements ManialinkPageAnswerListener, CallbackLis
|
||||
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ENABLE, true, '', 0);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_STEPCONFIG, '', '', 100);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SEEDED_PLAYERS, '', 'Comma separated logins in their seed order', 100);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_STEPCONFIG, '', 'In comp-tool format: b:0,p:1,p:r', 100);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_STEPDURATION, 60, '',100);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DURATIONAFTERTHELASTSTEP, 30, '', 150);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_STARTMATCHAUTOMATICALLY, true, '', 150);
|
||||
@@ -448,26 +450,41 @@ class MatchManagerPickAndBan implements ManialinkPageAnswerListener, CallbackLis
|
||||
$this->log(count($this->state->maps) . ' maps loaded for Pick & Ban');
|
||||
|
||||
// build steps
|
||||
$seededPlayersRaw = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SEEDED_PLAYERS);
|
||||
$seededPlayers = $seededPlayersRaw === '' ? [] : array_map('trim', explode(',', $seededPlayersRaw));
|
||||
|
||||
$steps = [];
|
||||
foreach (explode(',', $stepConfig) as $index => $stepRaw) {
|
||||
$stepArray = explode(':', $stepRaw);
|
||||
if (count($stepArray) !== 2) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() . 'Invalid step ' . $index . ' config: ' . $stepRaw);
|
||||
$this->state = new MatchManagerPickAndBan_State;
|
||||
return false;
|
||||
}
|
||||
|
||||
$step = new MatchManagerPickAndBan_Step;
|
||||
|
||||
if ($stepArray[0] === 'p') {
|
||||
$stepType = trim($stepArray[0]);
|
||||
if ($stepType === 'p') {
|
||||
$step->type = MatchManagerPickAndBan_Step::STEP_PICK;
|
||||
} else if ($stepArray[0] === 'b') {
|
||||
} else if ($stepType === 'b') {
|
||||
$step->type = MatchManagerPickAndBan_Step::STEP_BAN;
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() . 'Invalid step ' . $index . ' config: ' . $stepRaw);
|
||||
$this->state = new MatchManagerPickAndBan_State;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($stepArray[1] === 'r') {
|
||||
$playerKey = trim($stepArray[1]);
|
||||
if ($playerKey === 'r') {
|
||||
$step->login = "";
|
||||
} else {
|
||||
$step->login = $stepArray[1];
|
||||
if (!ctype_digit($playerKey) || !array_key_exists((int)$playerKey, $seededPlayers) || $seededPlayers[(int)$playerKey] === '') {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() . 'Invalid player key "' . $playerKey . '" in step ' . $index . ' config: ' . $stepRaw);
|
||||
$this->state = new MatchManagerPickAndBan_State;
|
||||
return false;
|
||||
}
|
||||
$step->login = $seededPlayers[(int)$playerKey];
|
||||
}
|
||||
$steps[] = $step;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user