diff --git a/src/main/java/dev/pgm/community/requests/RequestConfig.java b/src/main/java/dev/pgm/community/requests/RequestConfig.java index 01a3359..0bc9038 100644 --- a/src/main/java/dev/pgm/community/requests/RequestConfig.java +++ b/src/main/java/dev/pgm/community/requests/RequestConfig.java @@ -23,6 +23,7 @@ public class RequestConfig extends FeatureConfigImpl { private static final String MAX_TOKENS = SPONSORS + ".max-tokens"; private static final String REFUND = SPONSORS + ".refund"; private static final String MAP_COOLDOWN_MULTIPLY = SPONSORS + ".map-cooldown"; + private static final String SCALE_FACTOR = SPONSORS + ".scale-factor"; private static final String LOWER_LIMIT_OFFSET = SPONSORS + ".lower-limit-offset"; private static final String UPPER_LIMIT_OFFSET = SPONSORS + ".upper-limit-offset"; private static final String SUPER_VOTE = KEY + ".super-votes"; @@ -47,6 +48,8 @@ public class RequestConfig extends FeatureConfigImpl { private int mapCooldownMultiply; // # to multiply match length by to determine cooldown + private double scaleFactor; // Scaling factor for adjusting the upper bound of map size selection + private int lowerLimitOffset; // Offset to apply on match end to lower map size bound private int upperLimitOffset; // Offset to apply on match end to upper map size bound @@ -125,6 +128,10 @@ public boolean isSuperVoteBroadcast() { return superVoteBroadcast; } + public double getScaleFactor() { + return scaleFactor; + } + @Override public void reload(Configuration config) { super.reload(config); @@ -137,6 +144,7 @@ public void reload(Configuration config) { this.maxQueue = config.getInt(SPONSORS_LIMIT); this.refund = config.getBoolean(REFUND); this.mapCooldownMultiply = config.getInt(MAP_COOLDOWN_MULTIPLY); + this.scaleFactor = config.getDouble(SCALE_FACTOR); this.lowerLimitOffset = config.getInt(LOWER_LIMIT_OFFSET); this.upperLimitOffset = config.getInt(UPPER_LIMIT_OFFSET); this.superVoteEnabled = config.getBoolean(SUPER_VOTE_ENABLED); diff --git a/src/main/java/dev/pgm/community/requests/feature/RequestFeatureBase.java b/src/main/java/dev/pgm/community/requests/feature/RequestFeatureBase.java index 9cae2d2..0a723be 100644 --- a/src/main/java/dev/pgm/community/requests/feature/RequestFeatureBase.java +++ b/src/main/java/dev/pgm/community/requests/feature/RequestFeatureBase.java @@ -614,7 +614,9 @@ public int queueIndex(SponsorRequest request) { @Override public MapSizeBounds getCurrentMapSizeBounds() { return PGMUtils.getMapSizeBounds( - getRequestConfig().getLowerLimitOffset(), getRequestConfig().getUpperLimitOffset()); + getRequestConfig().getLowerLimitOffset(), + getRequestConfig().getUpperLimitOffset(), + getRequestConfig().getScaleFactor()); } private boolean isACooldownVariant(MapInfo map) { @@ -832,7 +834,10 @@ private boolean isPartyActive() { private boolean isMapSizeAllowed(MapInfo map) { return PGMUtils.isMapSizeAllowed( - map, getRequestConfig().getLowerLimitOffset(), getRequestConfig().getUpperLimitOffset()); + map, + getRequestConfig().getLowerLimitOffset(), + getRequestConfig().getUpperLimitOffset(), + getRequestConfig().getScaleFactor()); } private void sendWrongSizeMapError(SponsorRequest request) { diff --git a/src/main/java/dev/pgm/community/utils/PGMUtils.java b/src/main/java/dev/pgm/community/utils/PGMUtils.java index 705fb95..2469fa0 100644 --- a/src/main/java/dev/pgm/community/utils/PGMUtils.java +++ b/src/main/java/dev/pgm/community/utils/PGMUtils.java @@ -84,9 +84,10 @@ public int getUpperBound() { } } - public static boolean isMapSizeAllowed(MapInfo map, int lowerBoundOffset, int upperBoundOffset) { + public static boolean isMapSizeAllowed( + MapInfo map, int lowerBoundOffset, int upperBoundOffset, double scaleFactor) { if (isPGMEnabled()) { - MapSizeBounds bounds = getMapSizeBounds(lowerBoundOffset, upperBoundOffset); + MapSizeBounds bounds = getMapSizeBounds(lowerBoundOffset, upperBoundOffset, scaleFactor); int max = getMapMaxSize(map); @@ -100,7 +101,8 @@ public static int getMapMaxSize(MapInfo map) { return map.getMaxPlayers().stream().reduce(0, Integer::sum); } - public static MapSizeBounds getMapSizeBounds(int lowerBoundOffset, int upperBoundOffset) { + public static MapSizeBounds getMapSizeBounds( + int lowerBoundOffset, int upperBoundOffset, double scalingFactor) { if (!isPGMEnabled()) return new MapSizeBounds(0, 150); Match match = getMatch(); @@ -110,7 +112,7 @@ public static MapSizeBounds getMapSizeBounds(int lowerBoundOffset, int upperBoun int total = participants + (observers / 4); int lowerBound = participants; - int upperBound = Math.max(5, total + (int) (total * 0.35)); + int upperBound = Math.max(5, total + (int) (total * scalingFactor)); if (isFinished) { lowerBound = Math.max(0, lowerBound - lowerBoundOffset); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3fd1de4..4ca5f9a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -228,6 +228,7 @@ requests: weekly-tokens: 1 # Amount of tokens given on a weekly basis (community.token.weekly perm) max-tokens: 7 # Maximum amount of tokens an account can collect refund: true # Tokens are refunded when map vote is successful + scale-factor: 0.45 # Scaling factor for adjusting the upper bound of map size selection # Sponsor bound offset used to modify avaiable maps at the end of each match lower-limit-offset: 4 # Subtracted from the current minimum