mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
remove explicit null checks, match(..) checks on null itself by instanceof calls
This commit is contained in:
parent
b4d806211c
commit
96d026e4af
77 changed files with 97 additions and 104 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,11 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,12 +30,10 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue