diff --git a/core/src/main/java/tc/oc/pgm/score/MercyRule.java b/core/src/main/java/tc/oc/pgm/score/MercyRule.java index e07157c9ae..10a377d887 100644 --- a/core/src/main/java/tc/oc/pgm/score/MercyRule.java +++ b/core/src/main/java/tc/oc/pgm/score/MercyRule.java @@ -10,14 +10,17 @@ public class MercyRule { private final ScoreMatchModule scoreMatchModule; private final int scoreLimit; private final int mercyLimit; + private final int mercyLimitMin; private Map.Entry leader; private Map.Entry trailer; - public MercyRule(ScoreMatchModule scoreMatchModule, int scoreLimit, int mercyLimit) { + public MercyRule( + ScoreMatchModule scoreMatchModule, int scoreLimit, int mercyLimit, int mercyLimitMin) { this.scoreMatchModule = scoreMatchModule; this.scoreLimit = scoreLimit; this.mercyLimit = mercyLimit; + this.mercyLimitMin = mercyLimitMin; calculateLeaders(); } @@ -49,11 +52,13 @@ private boolean isTrailer(Competitor competitor) { public int getScoreLimit() { int scoreBaseline = (int) getTrailerScore(); + int mercyBaseline = Math.max(scoreBaseline + mercyLimit, mercyLimitMin); + if (scoreLimit < 0) { - return scoreBaseline + mercyLimit; + return mercyBaseline; } - return Math.min(scoreBaseline + mercyLimit, scoreLimit); + return Math.min(mercyBaseline, scoreLimit); } public void handleEvent(CompetitorScoreChangeEvent event) { diff --git a/core/src/main/java/tc/oc/pgm/score/ScoreConfig.java b/core/src/main/java/tc/oc/pgm/score/ScoreConfig.java index 9a5a591fe7..0f312e8ff2 100644 --- a/core/src/main/java/tc/oc/pgm/score/ScoreConfig.java +++ b/core/src/main/java/tc/oc/pgm/score/ScoreConfig.java @@ -5,4 +5,5 @@ public class ScoreConfig { public int deathScore; public int killScore; public int mercyLimit; + public int mercyLimitMin; } diff --git a/core/src/main/java/tc/oc/pgm/score/ScoreMatchModule.java b/core/src/main/java/tc/oc/pgm/score/ScoreMatchModule.java index 90237d51ee..eb64e56741 100644 --- a/core/src/main/java/tc/oc/pgm/score/ScoreMatchModule.java +++ b/core/src/main/java/tc/oc/pgm/score/ScoreMatchModule.java @@ -62,7 +62,8 @@ public ScoreMatchModule(Match match, ScoreConfig config, Set scoreBoxe this.match.getCompetitors().forEach(competitor -> this.scores.put(competitor, 0.0)); if (this.config.mercyLimit > 0) { - this.mercyRule = new MercyRule(this, config.scoreLimit, config.mercyLimit); + this.mercyRule = + new MercyRule(this, config.scoreLimit, config.mercyLimit, config.mercyLimitMin); } } diff --git a/core/src/main/java/tc/oc/pgm/score/ScoreModule.java b/core/src/main/java/tc/oc/pgm/score/ScoreModule.java index 651487a2a7..4a86a0c145 100644 --- a/core/src/main/java/tc/oc/pgm/score/ScoreModule.java +++ b/core/src/main/java/tc/oc/pgm/score/ScoreModule.java @@ -102,6 +102,10 @@ public ScoreModule parse(MapFactory factory, Logger logger, Document doc) config.scoreLimit = XMLUtils.parseNumber(scoreEl.getChild("limit"), Integer.class, -1); config.mercyLimit = XMLUtils.parseNumber(scoreEl.getChild("mercy"), Integer.class, -1); + Element mercyElement = XMLUtils.getUniqueChild(scoreEl, "mercy"); + config.mercyLimitMin = + XMLUtils.parseNumber(Node.fromAttr(mercyElement, "min"), Integer.class, -1); + // For backwards compatibility, default kill/death points to 1 if proto is old and // tag // is not present