[MOM] fixed Artistic Refusal (wrong modes), added additional checks for modes

This commit is contained in:
Oleg Agafonov 2023-04-05 12:13:36 +04:00
parent dddb7363b2
commit 64434fbcbc
3 changed files with 18 additions and 2 deletions

View file

@ -937,6 +937,21 @@ public abstract class AbilityImpl implements Ability {
@Override
public void addMode(Mode mode) {
getModes().addMode(mode);
// runtime check: modes must have good settings
int currentMin = getModes().getMinModes();
int currentMax = getModes().getMaxModes(null, null);
boolean isFine = true;
if (currentMin < 0 || currentMax < 0) {
isFine = false;
}
if (currentMin > 0 && currentMin > currentMax) {
isFine = false;
}
if (!isFine) {
throw new IllegalArgumentException(String.format("Wrong code usage: you must setup correct min and max modes (%d, %d) for %s",
currentMin, currentMax, this));
}
}
@Override