mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
[MOM] fixed Artistic Refusal (wrong modes), added additional checks for modes
This commit is contained in:
parent
dddb7363b2
commit
64434fbcbc
3 changed files with 18 additions and 2 deletions
|
@ -24,7 +24,7 @@ public final class ArtisticRefusal extends CardImpl {
|
||||||
|
|
||||||
// Choose one or both --
|
// Choose one or both --
|
||||||
this.getSpellAbility().getModes().setMinModes(1);
|
this.getSpellAbility().getModes().setMinModes(1);
|
||||||
this.getSpellAbility().getModes().setMinModes(2);
|
this.getSpellAbility().getModes().setMaxModes(2);
|
||||||
|
|
||||||
// * Counter target spell.
|
// * Counter target spell.
|
||||||
this.getSpellAbility().addEffect(new CounterTargetEffect());
|
this.getSpellAbility().addEffect(new CounterTargetEffect());
|
||||||
|
|
|
@ -937,6 +937,21 @@ public abstract class AbilityImpl implements Ability {
|
||||||
@Override
|
@Override
|
||||||
public void addMode(Mode mode) {
|
public void addMode(Mode mode) {
|
||||||
getModes().addMode(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
|
@Override
|
||||||
|
|
|
@ -490,7 +490,8 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
} else if (this.getMinModes() == this.getMaxModes(null, null)) {
|
} else if (this.getMinModes() == this.getMaxModes(null, null)) {
|
||||||
sb.append(CardUtil.numberToText(this.getMinModes()));
|
sb.append(CardUtil.numberToText(this.getMinModes()));
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("no text available for this selection of min and max modes");
|
throw new UnsupportedOperationException(String.format("no text available for this selection of min and max modes (%d and %d)",
|
||||||
|
this.getMinModes(), this.getMaxModes(null, null)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sb.append(chooseText);
|
sb.append(chooseText);
|
||||||
|
|
Loading…
Reference in a new issue