Refactor event max lobbies - is no longer a range

It's no longer a range because it:
1. Makes no sense for it to be a range
2. Makes for simpler scripts since returning a JS array is a hassle with Graal
This commit is contained in:
P0nk
2021-05-21 20:50:04 +02:00
parent 095008a20f
commit d9d63a1b44
60 changed files with 189 additions and 198 deletions

View File

@@ -12,14 +12,14 @@ var maxMapId;
var eventTime; // Max time allotted for the event, in minutes.
var lobbyRange = [0, 0]; // Range of concurrent lobbies (min range is 0, max range is 7).
const maxLobbies = 7; // Max amount of concurrent active lobbies.
function init() {
// After loading, ChannelServer
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -30,10 +30,10 @@ var maxMapId = 108010101;
var eventTime = 20; //20 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function init() {

View File

@@ -30,10 +30,10 @@ var maxMapId = 108010201;
var eventTime = 20; //20 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function init() {

View File

@@ -32,10 +32,10 @@ var eventMaps = [923010000];
var eventTime = 5; //5 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function init() {

View File

@@ -30,10 +30,10 @@ var maxMapId = 108010501;
var eventTime = 20; //20 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function init() {

View File

@@ -30,10 +30,10 @@ var maxMapId = 108010401;
var eventTime = 20; //20 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function init() {

View File

@@ -30,10 +30,10 @@ var maxMapId = 108010301;
var eventTime = 20; //20 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function init() {

View File

@@ -30,10 +30,10 @@ var maxMapId = 912020000;
var eventTime = 2; //2 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function init() {

View File

@@ -30,10 +30,10 @@ var maxMapId = 912010200;
var eventTime = 4; //4 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function init() {

View File

@@ -30,10 +30,10 @@ var maxMapId = 912010200;
var eventTime = 4; //4 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function init() {

View File

@@ -37,14 +37,14 @@ var maxMapId = 670010800;
var eventTime = 75; // 75 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -30,10 +30,10 @@ var maxMapId = 921110000;
var eventTime = 3; //3 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function init() {

View File

@@ -30,10 +30,10 @@ var maxMapId = 914030000;
var eventTime = 3; //3 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function init() {

View File

@@ -41,14 +41,14 @@ var bossMobId = 8830003;
var eventTime = 60; // 60 minutes
var releaseClawTime = 1;
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -41,14 +41,14 @@ var bossMobId = 8830010;
var eventTime = 60; // 60 minutes
var releaseClawTime = 1;
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -30,10 +30,10 @@ var maxMapId = 910520000;
var eventTime = 10; //10 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function init() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 970042711;
var eventTime = 5; //5 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 610030800;
var eventTime = 2; // 2 minutes for first stg
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var eventMaps = [190000000, 190000001, 190000002];
var eventTime = 45; // 45 minutes
var couponsNeeded = 400; // total of coupons to complete the event
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var eventMaps = [191000000, 191000001];
var eventTime = 45; // 45 minutes
var couponsNeeded = 350; // total of coupons to complete the event
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var eventMaps = [192000000, 192000001];
var eventTime = 45; // 45 minutes
var couponsNeeded = 350; // total of coupons to complete the event
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var eventMaps = [195000000, 195010000, 195020000, 195030000];
var eventTime = 45; // 45 minutes
var couponsNeeded = 450; // total of coupons to complete the event
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var eventMaps = [196000000, 196010000];
var eventTime = 45; // 45 minutes
var couponsNeeded = 500; // total of coupons to complete the event
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var eventMaps = [197000000, 197010000];
var eventTime = 45; // 45 minutes
var couponsNeeded = 300; // total of coupons to complete the event
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -35,14 +35,14 @@ var maxMapId = 925010300;
var eventTime = 6; // 6 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 922020100;
var eventTime = 20; // 20 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 930000800;
var eventTime = 30; // 30 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -35,14 +35,14 @@ var maxMapId = 921100300;
var eventTime = 10; // 10 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var waitTime = 3; // 3 minutes
var eventTime = 90; // 90 minutes
var bonusTime = 0.5; // 30 seconds
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 910010400;
var eventTime = 10; // 10 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var maxMapId = 889100001;
var eventTime = 15; // 15 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var maxMapId = 889100011;
var eventTime = 20; // 20 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var maxMapId = 889100021;
var eventTime = 25; // 25 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 240060200;
var eventTime = 120; // 120 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 240050310;
var eventTime = 25; // 25 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 103000805;
var eventTime = 30; // 30 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 541010100;
var eventTime = 10; // 10 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 809050016;
var eventTime = 15; // 15 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 922011100;
var eventTime = 45; // 45 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 926110600;
var eventTime = 45; // 45 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 926100600;
var eventTime = 45; // 45 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -33,7 +33,7 @@ var maxMapId = 914020000;
var eventTime = 10; // 10 minutes
var lobbyRange = [0, 7];
const maxLobbies = 7;
function init() {}

View File

@@ -36,14 +36,14 @@ var maxMapId = 920011300;
var eventTime = 45; // 45 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 220080001;
var eventTime = 45; // 45 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 270050300;
var eventTime = 140; // 140 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var maxMapId = 925100500;
var eventTime = 4; // 4 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -15,14 +15,14 @@ var maxMapId = 922240100;
var eventTime = 3; // 3 minutes
var lobbyRange = [0, 19];
const maxLobbies = 20;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 551030200;
var eventTime = 60; // 60 minutes for boss stg
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 801040101;
var eventTime = 60; // 60 minutes for boss stg
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var tdBossId = 7220005;
var eventTime = 10; // 10 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var tdBossId = 8220010;
var eventTime = 10; // 10 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var tdBossId = 8220011;
var eventTime = 15; // 15 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var tdBossId = 8220012;
var eventTime = 15; // 15 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -38,14 +38,14 @@ var tdBossId = 8220015;
var eventTime = 20; // 20 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -37,14 +37,14 @@ var maxMapId = 674030300;
var eventTime = 45; // 45 minutes
var bonusTime = 10; // 10 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -44,12 +44,12 @@ var forceHideMsgTime = 10; // unfortunately, EIM weddings don't send wedding ta
var eventBoss = true; // spawns a Cake boss at the hunting ground
var isCathedral = true;
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventExclusives(eim) {

View File

@@ -44,12 +44,12 @@ var forceHideMsgTime = 10; // unfortunately, EIM weddings don't send wedding ta
var eventBoss = true; // spawns a Cake boss at the hunting ground
var isCathedral = false;
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventExclusives(eim) {

View File

@@ -36,14 +36,14 @@ var maxMapId = 280030000;
var eventTime = 120; // 120 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -36,14 +36,14 @@ var maxMapId = 280011006;
var eventTime = 30; // 30 minutes
var lobbyRange = [0, 0];
const maxLobbies = 1;
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
function getMaxLobbies() {
return maxLobbies;
}
function setEventRequirements() {

View File

@@ -163,16 +163,11 @@ public class EventManager {
return YamlConfig.config.server.EVENT_LOBBY_DELAY;
}
private List<Integer> getLobbyRange() {
private int getMaxLobbies() {
try {
List<Object> objects = (List<Object>) iv.invokeFunction("setLobbyRange", (Object) null);
return convertToIntegerList(objects);
return (int) iv.invokeFunction("getMaxLobbies");
} catch (ScriptException | NoSuchMethodException ex) { // they didn't define a lobby range
List<Integer> defaultRange = new ArrayList<>();
defaultRange.add(0);
defaultRange.add(maxLobbys);
return defaultRange;
return maxLobbys;
}
}
@@ -332,23 +327,19 @@ public class EventManager {
public String getName() {
return name;
}
private int availableLobbyInstance() {
List<Integer> lr = getLobbyRange();
int lb = 0, hb = 0;
if(lr.size() >= 2) {
lb = Math.max(lr.get(0), 0);
hb = Math.min(lr.get(1), maxLobbys - 1);
int maxLobbies = getMaxLobbies();
if (maxLobbies > 0) {
for (int i = 0; i < maxLobbies; i++) {
if (startLobbyInstance(i)) {
return i;
}
}
for(int i = lb; i <= hb; i++) {
if(startLobbyInstance(i)) {
return i;
}
}
return -1;
}
return -1;
}
private String getInternalScriptExceptionMessage(Throwable a) {