remove explicit null checks, match(..) checks on null itself by instanceof calls

This commit is contained in:
Ingmar Goudt 2021-04-28 20:53:42 +02:00
parent b4d806211c
commit 96d026e4af
77 changed files with 97 additions and 104 deletions

View file

@ -74,7 +74,7 @@ class AlAbarasCarpetEffect extends PreventionEffectImpl {
DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
if (event.getTargetId().equals(source.getControllerId())) {
Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
if (permanent != null && filter.match(permanent, game)) {
if (filter.match(permanent, game)) {
return true;
}
}

View file

@ -83,7 +83,7 @@ class AuntiesSnitchTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
Permanent p = game.getPermanent(event.getSourceId());
return damageEvent.isCombatDamage() && p != null && filter.match(p, getSourceId(), getControllerId(), game);
return damageEvent.isCombatDamage() && filter.match(p, getSourceId(), getControllerId(), game);
}
@Override

View file

@ -89,7 +89,7 @@ class BombSquadTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getData().equals(CounterType.FUSE.getName())) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && filter.match(permanent, game)) {
if (filter.match(permanent, game)) {
if (4 <= permanent.getCounters(game).getCount(CounterType.FUSE)) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(permanent, game));

View file

@ -68,7 +68,7 @@ class BubblingMuckTriggeredAbility extends DelayedTriggeredManaAbility {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent land = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (land != null && filter.match(land, getSourceId(), getControllerId(), game)) {
if (filter.match(land, getSourceId(), getControllerId(), game)) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(land.getControllerId()));
}

View file

@ -80,7 +80,7 @@ class CamelEffect extends PreventionEffectImpl {
&& sourcePermanent.isAttacking()
&& (event.getTargetId().equals(source.getSourceId()) || sourcePermanent.getBandedCards().contains(event.getTargetId()))) {
Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
if (permanent != null && filter.match(permanent, game)) {
if (filter.match(permanent, game)) {
return true;
}
}

View file

@ -80,7 +80,7 @@ class CeaseFireEffect extends ContinuousRuleModifyingEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getPlayerId().equals(getTargetPointer().getFirst(game, source))) {
Spell spell = game.getStack().getSpell(event.getSourceId());
if (spell != null && filter.match(spell, game)) {
if (filter.match(spell, game)) {
return true;
}
}

View file

@ -119,7 +119,7 @@ class ChaosMoonOddTriggeredAbility extends DelayedTriggeredManaAbility {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent land = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (land != null && filter.match(land, getSourceId(), getControllerId(), game)) {
if (filter.match(land, getSourceId(), getControllerId(), game)) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(land.getControllerId()));
}

View file

@ -239,6 +239,6 @@ class CityInABottleCantPlayEffect extends ContinuousRuleModifyingEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Card card = game.getCard(event.getSourceId());
return card != null && filter.match(card, source.getSourceId(), source.getControllerId(), game);
return filter.match(card, source.getSourceId(), source.getControllerId(), game);
}
}

View file

@ -72,7 +72,7 @@ class CryptGhastTriggeredAbility extends TriggeredManaAbility {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent land = game.getPermanentOrLKIBattlefield(event.getTargetId());
return land != null && filter.match(land, this.getSourceId(), this.getControllerId(), game);
return filter.match(land, this.getSourceId(), this.getControllerId(), game);
}
@Override

View file

@ -73,7 +73,7 @@ class CultOfTheWaxingMoonAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
return permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game);
return filter.match(permanent, getSourceId(), getControllerId(), game);
}
@Override

View file

@ -74,7 +74,7 @@ class DeepWoodEffect extends PreventionEffectImpl {
DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
if (event.getTargetId().equals(source.getControllerId())) {
Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
if (permanent != null && filter.match(permanent, game)) {
if (filter.match(permanent, game)) {
return true;
}
}

View file

@ -86,7 +86,7 @@ class EchoBaseCommandoEffect extends CostModificationEffectImpl {
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify.getAbilityType() == AbilityType.ACTIVATED || (abilityToModify.getAbilityType() == AbilityType.MANA && (abilityToModify instanceof ActivatedAbility))) {
Permanent permanent = game.getPermanent(abilityToModify.getSourceId());
if (permanent != null && filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
if (filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
return true;
}
}

View file

@ -91,7 +91,7 @@ class EmbalmersToolsEffect extends CostModificationEffectImpl {
|| (abilityToModify.getAbilityType() == AbilityType.MANA && (abilityToModify instanceof ActivatedAbility))) {
// Activated abilities of creatures
Card card = game.getCard(abilityToModify.getSourceId());
if (card != null && filter.match(card, source.getSourceId(), source.getControllerId(), game) && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
if (filter.match(card, source.getSourceId(), source.getControllerId(), game) && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
return true;
}
}

View file

@ -119,7 +119,7 @@ class NimbleTrapfinderWatcher extends Watcher {
return;
}
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null || !filter.match(permanent, game)) {
if (!filter.match(permanent, game)) {
return;
}
playerMap

View file

@ -982,7 +982,7 @@ public abstract class AbilityImpl implements Ability {
}
// check against current state
Zone test = game.getState().getZone(parameterSourceId);
return test != null && zone.match(test);
return zone.match(test);
}
@Override

View file

@ -295,7 +295,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
&& !(sourceObject instanceof PermanentToken) // it's no token
&& sourceObject.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(source.getSourceId())) { // It's in the next zone
Zone after = game.getState().getZone(source.getSourceId());
if (after == null || !Zone.GRAVEYARD.match(after)) { // Zone is not the graveyard
if (!Zone.GRAVEYARD.match(after)) { // Zone is not the graveyard
return false; // Moving to graveyard was replaced so no trigger
}
}

View file

@ -60,7 +60,7 @@ public class AttacksCreatureYouControlTriggeredAbility extends TriggeredAbilityI
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent sourcePermanent = game.getPermanent(event.getSourceId());
if (sourcePermanent != null && filter.match(sourcePermanent, sourceId, controllerId, game)) {
if (filter.match(sourcePermanent, sourceId, controllerId, game)) {
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(event.getSourceId(), game));
}

View file

@ -56,7 +56,7 @@ public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
int attackerCount = 0;
for (UUID attackerId : game.getCombat().getAttackers()) {
Permanent attacker = game.getPermanent(attackerId);
if (attacker != null && filter.match(attacker, game)) {
if (filter.match(attacker, game)) {
attackerCount++;
}
}

View file

@ -43,7 +43,7 @@ public class BecomesBlockedAllTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
}

View file

@ -55,7 +55,7 @@ public class BecomesTappedTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
}

View file

@ -57,7 +57,7 @@ public class BlocksOrBecomesBlockedByOneOrMoreTriggeredAbility extends Triggered
}
for (UUID uuid : group.getBlockers()){
Permanent permanent = game.getPermanentOrLKIBattlefield(uuid);
if (permanent != null && filter.match(permanent, game)){
if (filter.match(permanent, game)){
return true;
}
}
@ -67,7 +67,7 @@ public class BlocksOrBecomesBlockedByOneOrMoreTriggeredAbility extends Triggered
}
for (UUID uuid : group.getAttackers()){
Permanent permanent = game.getPermanentOrLKIBattlefield(uuid);
if (permanent != null && filter.match(permanent, game)){
if (filter.match(permanent, game)){
return true;
}
}

View file

@ -57,7 +57,7 @@ public class BlocksOrBecomesBlockedSourceTriggeredAbility extends TriggeredAbili
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.getSourceId())) {
Permanent blocked = game.getPermanent(event.getTargetId());
if (blocked != null && filter.match(blocked, game)) {
if (filter.match(blocked, game)) {
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(blocked, game));
}
@ -66,7 +66,7 @@ public class BlocksOrBecomesBlockedSourceTriggeredAbility extends TriggeredAbili
}
if (event.getTargetId().equals(this.getSourceId())) {
Permanent blocker = game.getPermanent(event.getSourceId());
if (blocker != null && filter.match(blocker, game)) {
if (filter.match(blocker, game)) {
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(blocker, game));
}

View file

@ -57,7 +57,7 @@ public class BlocksOrBecomesBlockedTriggeredAbility extends TriggeredAbilityImpl
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.getSourceId())) {
Permanent blocked = game.getPermanent(event.getTargetId());
if (blocked != null && filter.match(blocked, game)) {
if (filter.match(blocked, game)) {
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(blocked, game));
}
@ -66,7 +66,7 @@ public class BlocksOrBecomesBlockedTriggeredAbility extends TriggeredAbilityImpl
}
if (event.getTargetId().equals(this.getSourceId())) {
Permanent blocker = game.getPermanent(event.getSourceId());
if (blocker != null && filter.match(blocker, game)) {
if (filter.match(blocker, game)) {
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(blocker, game));
}

View file

@ -69,7 +69,7 @@ public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityI
return false;
}
permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (permanent == null || !filterPermanent.match(permanent, getSourceId(), getControllerId(), game)) {
if (!filterPermanent.match(permanent, getSourceId(), getControllerId(), game)) {
return false;
}
for (Effect effect : this.getEffects()) {

View file

@ -55,7 +55,7 @@ public class DealsDamageToACreatureTriggeredAbility extends TriggeredAbilityImpl
&& (!combatOnly || ((DamagedEvent) event).isCombatDamage())) {
if (filter != null) {
Permanent creature = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (creature == null || !filter.match(creature, getSourceId(), getControllerId(), game)) {
if (!filter.match(creature, getSourceId(), getControllerId(), game)) {
return false;
}
}

View file

@ -74,7 +74,7 @@ public class DealsDamageToAPlayerAllTriggeredAbility extends TriggeredAbilityImp
return false;
}
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent == null || !filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (!filter.match(permanent, getSourceId(), getControllerId(), game)) {
return false;
}
this.getEffects().setValue("damage", event.getAmount());

View file

@ -84,7 +84,7 @@ public class EntersBattlefieldAllTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
UUID targetId = event.getTargetId();
Permanent permanent = game.getPermanent(targetId);
if (permanent == null || !filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (!filter.match(permanent, getSourceId(), getControllerId(), game)) {
return false;
}
this.getEffects().setValue("permanentEnteringBattlefield", permanent);

View file

@ -79,7 +79,7 @@ public class EntersBattlefieldOrAttacksAllTriggeredAbility extends TriggeredAbil
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD
&& permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
&& filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (setTargetPointer != SetTargetPointer.NONE) {
for (Effect effect : this.getEffects()) {
switch (setTargetPointer) {
@ -98,7 +98,7 @@ public class EntersBattlefieldOrAttacksAllTriggeredAbility extends TriggeredAbil
Permanent attacker = game.getPermanent(event.getSourceId());
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED
&& attacker != null && filter.match(attacker, getSourceId(), getControllerId(), game)) {
&& filter.match(attacker, getSourceId(), getControllerId(), game)) {
if (setTargetPointer != SetTargetPointer.NONE) {
for (Effect effect : this.getEffects()) {
switch (setTargetPointer) {

View file

@ -62,7 +62,7 @@ public class LeavesBattlefieldAllTriggeredAbility extends TriggeredAbilityImpl {
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
UUID targetId = event.getTargetId();
Permanent permanent = game.getPermanentOrLKIBattlefield(targetId);
if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (setTargetPointer != SetTargetPointer.NONE) {
for (Effect effect : this.getEffects()) {
switch (setTargetPointer) {

View file

@ -58,7 +58,7 @@ public class SacrificeAllTriggeredAbility extends TriggeredAbilityImpl {
break;
}
Permanent sacrificedPermanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
return sacrificed && sacrificedPermanent != null && filter.match(sacrificedPermanent, getSourceId(), getControllerId(), game);
return sacrificed && filter.match(sacrificedPermanent, getSourceId(), getControllerId(), game);
}
@Override

View file

@ -59,7 +59,7 @@ public class SpellCastAllTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell == null || !filter.match(spell, getSourceId(), getControllerId(), game)) {
if (!filter.match(spell, getSourceId(), getControllerId(), game)) {
return false;
}
getEffects().setValue("spellCast", spell);

View file

@ -68,7 +68,7 @@ public class SpellCastControllerTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(this.getControllerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) {
if (filter.match(spell, getSourceId(), getControllerId(), game)) {
if (rememberSource) {
this.getEffects().setValue("spellCast", spell);
if (rememberSourceAsCard) {

View file

@ -61,7 +61,7 @@ public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl {
return false;
}
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell == null || !filter.match(spell, getSourceId(), getControllerId(), game)) {
if (!filter.match(spell, getSourceId(), getControllerId(), game)) {
return false;
}
getEffects().setValue("spellCast", spell);

View file

@ -45,7 +45,7 @@ public class TapForManaAllTriggeredAbility extends TriggeredAbilityImpl {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
ManaEvent mEvent = (ManaEvent) event;
for(Effect effect:getEffects()) {
effect.setValue("mana", mEvent.getMana());

View file

@ -43,7 +43,7 @@ public class TapForManaAllTriggeredManaAbility extends TriggeredManaAbility {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
ManaEvent mEvent = (ManaEvent) event;
for(Effect effect:getEffects()) {
effect.setValue("mana", mEvent.getMana());

View file

@ -67,7 +67,7 @@ public class TurnedFaceUpAllTriggeredAbility extends TriggeredAbilityImpl {
}
}
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (setTargetPointer) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId()));

View file

@ -60,7 +60,7 @@ public class ZoneChangeAllTriggeredAbility extends TriggeredAbilityImpl {
} else {
perm = game.getPermanent(event.getTargetId()); // LevelX2: maybe this part is not neccessary
}
if (perm != null && filter.match(perm, sourceId, controllerId, game)) {
if (filter.match(perm, sourceId, controllerId, game)) {
return true;
}
}

View file

@ -29,12 +29,10 @@ public class AttachedToMatchesFilterCondition implements Condition {
if (attachedTo == null) {
attachedTo = (Permanent) game.getLastKnownInformation(permanent.getAttachedTo(), Zone.BATTLEFIELD);
}
if (attachedTo != null) {
if (filter.match(attachedTo, attachedTo.getId(), attachedTo.getControllerId(), game)) {
return true;
}
if (filter.match(attachedTo, attachedTo.getId(), attachedTo.getControllerId(), game)) {
return true;
}
}
return false;
}

View file

@ -30,10 +30,8 @@ public class EnchantedCreatureColorCondition implements Condition {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
if(filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)){
return true;
}
if(filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)){
return true;
}
}
return false;

View file

@ -26,11 +26,10 @@ public class EnchantedCreatureSubtypeCondition implements Condition {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
if (filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)) {
return true;
}
if (filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)) {
return true;
}
}
return false;
}

View file

@ -29,11 +29,10 @@ public class SourceMatchesFilterCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
if (permanent != null) {
if (FILTER.match(permanent, permanent.getId(), permanent.getControllerId(), game)) {
return true;
}
if (FILTER.match(permanent, permanent.getId(), permanent.getControllerId(), game)) {
return true;
}
return false;
}

View file

@ -30,7 +30,7 @@ public class SourceTargetsPermanentCondition implements Condition {
Iterator<Target> targets = sourceSpell.getStackAbility().getTargets().iterator();
while (targets.hasNext()) {
Permanent permanent = game.getPermanentOrLKIBattlefield(targets.next().getFirstTarget());
if (permanent != null && filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
if (filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
return true;
}
}

View file

@ -48,7 +48,7 @@ public class AttackingCreatureCount implements DynamicValue {
for (UUID permId : combatGroup.getAttackers()) {
if (filter != null) {
Permanent attacker = game.getPermanent(permId);
if (attacker != null && filter.match(attacker, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game)) {
if (filter.match(attacker, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game)) {
count++;
}
} else {

View file

@ -67,7 +67,7 @@ public class CantBeCounteredControlledEffect extends ContinuousRuleModifyingEffe
return true;
} else {
MageObject sourceObject = game.getObject(event.getSourceId());
if (sourceObject != null && filterSource.match(sourceObject, game)) {
if (filterSource.match(sourceObject, game)) {
return true;
}
}

View file

@ -76,7 +76,7 @@ public class CantBeTargetedAllEffect extends ContinuousRuleModifyingEffectImpl {
} else {
sourceObject = stackObject;
}
if (sourceObject != null && filterSource.match(sourceObject, game)) {
if (filterSource.match(sourceObject, game)) {
return true;
}
}

View file

@ -57,7 +57,7 @@ public class CantBeTargetedSourceEffect extends ContinuousRuleModifyingEffectImp
} else {
sourceObject = stackObject;
}
if (sourceObject != null && filterSource.match(sourceObject, game)) {
if (filterSource.match(sourceObject, game)) {
return true;
}
}

View file

@ -69,7 +69,7 @@ public class CantBeTargetedTargetEffect extends ContinuousRuleModifyingEffectImp
} else {
sourceObject = stackObject;
}
if (sourceObject != null && filterSource.match(sourceObject, game)) {
if (filterSource.match(sourceObject, game)) {
return true;
}
}

View file

@ -38,7 +38,7 @@ public class GainActivatedAbilitiesOfTopCardEffect extends ContinuousEffectImpl
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Card card = player.getLibrary().getFromTop(game);
if (card != null && filter.match(card, game)) {
if (filter.match(card, game)) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
for (Ability ability : card.getAbilities(game)) {

View file

@ -55,7 +55,7 @@ public class PermanentsEnterBattlefieldTappedEffect extends ReplacementEffectImp
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
return permanent != null && filter.match(permanent, source.getSourceId(), event.getPlayerId(), game);
return filter.match(permanent, source.getSourceId(), event.getPlayerId(), game);
}
@Override

View file

@ -55,7 +55,7 @@ public class PreventAllDamageByAllPermanentsEffect extends PreventionEffectImpl
return true;
}
Permanent permanent = game.getPermanent(damageEvent.getSourceId());
if (permanent != null && filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
if (filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
return true;
}
}

View file

@ -72,7 +72,7 @@ public class RevealCardsFromLibraryUntilEffect extends OneShotEffect {
if (card != null) {
cards.add(card);
}
} while (library.hasCards() && card != null && !filter.match(card, game));
} while (library.hasCards() && !filter.match(card, game));
// reveal cards
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);

View file

@ -48,8 +48,7 @@ public class CanAttackAsThoughItDidntHaveDefenderAllEffect extends AsThoughEffec
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
Permanent permanent = game.getPermanent(objectId);
return permanent != null
&& filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
return filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
}
private String getText() {

View file

@ -129,7 +129,7 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
filter.add(SubType.AURA.getPredicate());
for (UUID attachmentId : new HashSet<>(permanent.getAttachments())) {
Permanent attachment = game.getPermanent(attachmentId);
if (attachment != null && filter.match(attachment, game)) {
if (filter.match(attachment, game)) {
attachment.destroy(source, game, false);
}
}

View file

@ -78,7 +78,7 @@ public class GainAbilityControlledSpellsEffect extends ContinuousEffectImpl {
&& !stackObject.isCopy()
&& stackObject.isControlledBy(source.getControllerId())) {
Card card = game.getCard(stackObject.getSourceId());
if (card != null && filter.match(card, game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
return true;
}

View file

@ -124,7 +124,7 @@ public class SpellsCostIncreasingAllEffect extends CostModificationEffectImpl {
// get playable and other staff without put on stack
// used at least for flashback ability because Flashback ability doesn't use stack
Card sourceCard = game.getCard(abilityToModify.getSourceId());
return sourceCard != null && this.filter.match(sourceCard, game);
return this.filter.match(sourceCard, game);
}
}
return false;

View file

@ -113,7 +113,7 @@ public class SpellsCostModificationThatTargetSourceEffect extends CostModificati
}
Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game);
if (spellCard == null || !this.spellFilter.match(spellCard, game)) {
if (!this.spellFilter.match(spellCard, game)) {
return false;
}

View file

@ -73,7 +73,7 @@ class SpellCastManaCondition extends ManaCondition implements Condition {
} else if (object instanceof Commander) {
spell = new Spell(((Commander) object).getSourceObject(), (SpellAbility) source, source.getControllerId(), game.getState().getZone(source.getSourceId()), game);
}
return spell != null && filter.match(spell, source.getSourceId(), source.getControllerId(), game);
return filter.match(spell, source.getSourceId(), source.getControllerId(), game);
}
}
return false;

View file

@ -52,7 +52,7 @@ public class FilterPermanent extends FilterObject<Permanent> implements FilterIn
@Override
public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) {
if (!permanent.isPhasedIn() || !this.match(permanent, game)) {
if (!this.match(permanent, game) || !permanent.isPhasedIn()) {
return false;
}

View file

@ -35,7 +35,7 @@ public class TargetsPermanentPredicate implements ObjectSourcePlayerPredicate<Ob
}
for (UUID targetId : target.getTargets()) {
Permanent permanent = game.getPermanentOrLKIBattlefield(targetId);
if (permanent != null && targetFilter.match(permanent, input.getSourceId(), input.getPlayerId(), game)) {
if (targetFilter.match(permanent, input.getSourceId(), input.getPlayerId(), game)) {
return true;
}
}

View file

@ -23,7 +23,7 @@ public class AttachedToPredicate implements Predicate<Permanent> {
public boolean apply(Permanent input, Game game) {
UUID attachedTo = input.getAttachedTo();
Permanent permanent = game.getPermanent(attachedTo);
return permanent != null && filter.match(permanent, game);
return filter.match(permanent, game);
}
@Override

View file

@ -60,7 +60,7 @@ class VenserTheSojournerSpellCastTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(this.getControllerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
return spell != null && StaticFilters.FILTER_SPELL_A.match(spell, game);
return StaticFilters.FILTER_SPELL_A.match(spell, game);
}
return false;
}

View file

@ -99,7 +99,7 @@ class EdgeOfMalacolEffect extends ContinuousRuleModifyingEffectImpl {
return false;
}
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && filter.match(permanent, game) && Objects.equals(permanent.getControllerId(), game.getActivePlayerId())) {
if (filter.match(permanent, game) && Objects.equals(permanent.getControllerId(), game.getActivePlayerId())) {
UUID oldController = source.getControllerId();
source.setControllerId(game.getActivePlayerId());
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(2));

View file

@ -138,7 +138,7 @@ class FeedingGroundsEffect extends CostModificationEffectImpl {
} else {
// used at least for flashback ability because Flashback ability doesn't use stack
Card sourceCard = game.getCard(abilityToModify.getSourceId());
return sourceCard != null && filter.match(sourceCard, game) && selectedByRuntimeData(sourceCard, source, game);
return filter.match(sourceCard, game) && selectedByRuntimeData(sourceCard, source, game);
}
}
return false;

View file

@ -79,7 +79,7 @@ public class TargetPermanent extends TargetObject {
public boolean canTarget(UUID controllerId, UUID id, UUID sourceId, Game game, boolean flag) {
Permanent permanent = game.getPermanent(id);
return permanent != null && filter.match(permanent, sourceId, controllerId, game);
return filter.match(permanent, sourceId, controllerId, game);
}
@Override

View file

@ -141,7 +141,7 @@ public class TargetPlayer extends TargetImpl {
@Override
public boolean canTarget(UUID id, Game game) {
Player player = game.getPlayer(id);
return player != null && filter.match(player, game);
return filter.match(player, game);
}
@Override

View file

@ -61,7 +61,7 @@ public class TargetSpell extends TargetObject {
return false;
}
Spell spell = game.getStack().getSpell(id);
return spell != null && filter.match(spell, source.getSourceId(), source.getControllerId(), game);
return filter.match(spell, source.getSourceId(), source.getControllerId(), game);
}
@Override

View file

@ -51,7 +51,7 @@ public class TargetStackObject extends TargetObject {
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
StackObject stackObject = game.getStack().getStackObject(id);
return stackObject != null && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game);
return filter.match(stackObject, source.getSourceId(), source.getControllerId(), game);
}
@Override

View file

@ -62,7 +62,7 @@ public class TargetAnyTarget extends TargetImpl {
return filter.match(permanent, game);
}
Player player = game.getPlayer(id);
return player != null && filter.match(player, game);
return filter.match(player, game);
}
@Override
@ -88,7 +88,7 @@ public class TargetAnyTarget extends TargetImpl {
if (permanent != null) {
return filter.match(permanent, game);
}
return player != null && filter.match(player, game);
return filter.match(player, game);
}
/**
@ -143,7 +143,7 @@ public class TargetAnyTarget extends TargetImpl {
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
Player player = game.getPlayer(playerId);
if (player != null && filter.match(player, game)) {
if (filter.match(player, game)) {
count++;
if (count >= this.minNumberOfTargets) {
return true;
@ -193,7 +193,7 @@ public class TargetAnyTarget extends TargetImpl {
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
Player player = game.getPlayer(playerId);
if (player != null && filter.match(player, game)) {
if (filter.match(player, game)) {
possibleTargets.add(playerId);
}
}

View file

@ -48,7 +48,7 @@ public class TargetCardInHand extends TargetCard {
Card card = game.getCard(id);
return game.getState().getZone(id) == Zone.HAND
&& game.getState().getPlayersInRange(getTargetController() == null ? playerId : getTargetController(), game).contains(game.getOwnerId(id))
&& card != null && filter.match(card, game);
&& filter.match(card, game);
}
@Override

View file

@ -90,7 +90,7 @@ public class TargetCardInLibrary extends TargetCard {
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
Card card = game.getPlayer(source.getControllerId()).getLibrary().getCard(id, game);
return card != null && filter.match(card, source.getSourceId(), source.getControllerId(), game);
return filter.match(card, source.getSourceId(), source.getControllerId(), game);
}
@Override

View file

@ -62,7 +62,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
return filter.match(permanent, game);
}
Player player = game.getPlayer(id);
return player != null && filter.match(player, game);
return filter.match(player, game);
}
@Override
@ -88,7 +88,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
if (permanent != null) {
return filter.match(permanent, game);
}
return player != null && filter.match(player, game);
return filter.match(player, game);
}
/**
@ -139,7 +139,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
int count = 0;
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
Player player = game.getPlayer(playerId);
if (player != null && filter.match(player, game)) {
if (filter.match(player, game)) {
count++;
if (count >= this.minNumberOfTargets) {
return true;

View file

@ -47,7 +47,7 @@ public class TargetDiscard extends TargetCard {
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
Card card = game.getPlayer(playerId).getHand().get(id, game);
return card != null && filter.match(card, source.getControllerId(), game);
return filter.match(card, source.getControllerId(), game);
}
@Override

View file

@ -51,7 +51,7 @@ public abstract class TargetPermanentAmount extends TargetAmount {
@Override
public boolean canTarget(UUID objectId, Game game) {
Permanent permanent = game.getPermanent(objectId);
return permanent != null && filter.match(permanent, game);
return filter.match(permanent, game);
}
@Override

View file

@ -64,7 +64,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
return filter.match(permanent, game);
}
Player player = game.getPlayer(id);
return player != null && filter.match(player, game);
return filter.match(player, game);
}
@Override
@ -102,7 +102,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
if (permanent != null) {
return filter.match(permanent, game);
}
return player != null && filter.match(player, game);
return filter.match(player, game);
}
/**
@ -196,7 +196,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
Set<UUID> possibleTargets = new HashSet<>();
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
Player player = game.getPlayer(playerId);
if (player != null && filter.match(player, game)) {
if (filter.match(player, game)) {
possibleTargets.add(playerId);
}
}

View file

@ -54,7 +54,7 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount {
return filter.match(permanent, game);
}
Player player = game.getPlayer(objectId);
return player != null && filter.match(player, game);
return filter.match(player, game);
}
@Override
@ -83,7 +83,7 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount {
if (permanent != null) {
return filter.match(permanent, game);
}
return player != null && filter.match(player, game);
return filter.match(player, game);
}
@Override

View file

@ -118,7 +118,7 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl {
return filter.match(permanent, game);
}
Card card = game.getExile().getCard(id, game);
return card != null && filter.match(card, game);
return filter.match(card, game);
}
@Override
@ -134,7 +134,7 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl {
}
}
Card card = game.getExile().getCard(id, game);
return card != null && filter.match(card, game);
return filter.match(card, game);
}
@Override

View file

@ -80,7 +80,7 @@ public class TargetSpellOrPermanent extends TargetImpl {
return filter.match(permanent, game);
}
Spell spell = game.getStack().getSpell(id);
return spell != null && filter.match(spell, game);
return filter.match(spell, game);
}
@Override