"ERROR," -> "Wrong code usage:" in IllegalArgumentException

This commit is contained in:
Steven Knipe 2023-10-01 22:41:24 -07:00
parent 731b391306
commit 47fc192a36
8 changed files with 9 additions and 9 deletions

View file

@ -512,14 +512,14 @@ public class ContinuousEffects implements Serializable {
// usage check: effect must apply for specific ability only, not to full object (example: PLAY_FROM_NOT_OWN_HAND_ZONE)
if (type.needAffectedAbility() && affectedAbility == null) {
throw new IllegalArgumentException("ERROR, you can't call asThough check to whole object, call it with affected ability instead: " + type);
throw new IllegalArgumentException("Wrong code usage: you can't call asThough check to whole object, call it with affected ability instead: " + type);
}
// usage check: effect must apply to full object, not specific ability (example: ATTACK_AS_HASTE)
// P.S. In theory a same AsThough effect can be applied to object or to ability, so if you really, really
// need it then disable that check or add extra param to AsThoughEffectType like needAffectedAbilityOrFullObject
if (!type.needAffectedAbility() && affectedAbility != null) {
throw new IllegalArgumentException("ERROR, you can't call AsThough check to affected ability, call it with empty affected ability instead: " + type);
throw new IllegalArgumentException("Wrong code usage: you can't call AsThough check to affected ability, call it with empty affected ability instead: " + type);
}
List<AsThoughEffect> asThoughEffectsList = getApplicableAsThoughEffects(type, game);

View file

@ -52,7 +52,7 @@ public class PlayFromNotOwnHandZoneAllEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
throw new IllegalArgumentException("ERROR, can't call applies method on empty affectedAbility");
throw new IllegalArgumentException("Wrong code usage: can't call applies method on empty affectedAbility");
}
@Override
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) {

View file

@ -87,7 +87,7 @@ public class PlayFromNotOwnHandZoneTargetEffect extends AsThoughEffectImpl {
// PLAY_FROM_NOT_OWN_HAND_ZONE must applies to affectedAbility only
// If you see it then parent conditional effect must override both applies methods to support different
// AsThough effect types in one conditional effect
throw new IllegalArgumentException("ERROR, can't call applies method on empty affectedAbility");
throw new IllegalArgumentException("Wrong code usage: can't call applies method on empty affectedAbility");
}
// invalid targets

View file

@ -88,7 +88,7 @@ public class PlayTheTopCardEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
throw new IllegalArgumentException("ERROR, can't call applies method on empty affectedAbility");
throw new IllegalArgumentException("Wrong code usage: can't call applies method on empty affectedAbility");
}
@Override
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) {

View file

@ -49,7 +49,7 @@ public class PlayLandsFromGraveyardControllerEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
throw new IllegalArgumentException("ERROR, can't call applies method on empty affectedAbility");
throw new IllegalArgumentException("Wrong code usage: can't call applies method on empty affectedAbility");
}
@Override
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) {

View file

@ -50,7 +50,7 @@ public class PermanentCard extends PermanentImpl {
}
}
if (!goodForBattlefield) {
throw new IllegalArgumentException("ERROR, can't create permanent card from split or mdf: " + card.getName());
throw new IllegalArgumentException("Wrong code usage: can't create permanent card from split or mdf: " + card.getName());
}
this.card = card;