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;
|
DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
|
||||||
if (event.getTargetId().equals(source.getControllerId())) {
|
if (event.getTargetId().equals(source.getControllerId())) {
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
|
Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
|
||||||
if (permanent != null && filter.match(permanent, game)) {
|
if (filter.match(permanent, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ class AuntiesSnitchTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
|
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
|
||||||
Permanent p = game.getPermanent(event.getSourceId());
|
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
|
@Override
|
||||||
|
|
|
@ -89,7 +89,7 @@ class BombSquadTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getData().equals(CounterType.FUSE.getName())) {
|
if (event.getData().equals(CounterType.FUSE.getName())) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
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)) {
|
if (4 <= permanent.getCounters(game).getCount(CounterType.FUSE)) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(permanent, game));
|
effect.setTargetPointer(new FixedTarget(permanent, game));
|
||||||
|
|
|
@ -68,7 +68,7 @@ class BubblingMuckTriggeredAbility extends DelayedTriggeredManaAbility {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent land = game.getPermanentOrLKIBattlefield(event.getTargetId());
|
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()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(land.getControllerId()));
|
effect.setTargetPointer(new FixedTarget(land.getControllerId()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ class CamelEffect extends PreventionEffectImpl {
|
||||||
&& sourcePermanent.isAttacking()
|
&& sourcePermanent.isAttacking()
|
||||||
&& (event.getTargetId().equals(source.getSourceId()) || sourcePermanent.getBandedCards().contains(event.getTargetId()))) {
|
&& (event.getTargetId().equals(source.getSourceId()) || sourcePermanent.getBandedCards().contains(event.getTargetId()))) {
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
|
Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
|
||||||
if (permanent != null && filter.match(permanent, game)) {
|
if (filter.match(permanent, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ class CeaseFireEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getPlayerId().equals(getTargetPointer().getFirst(game, source))) {
|
if (event.getPlayerId().equals(getTargetPointer().getFirst(game, source))) {
|
||||||
Spell spell = game.getStack().getSpell(event.getSourceId());
|
Spell spell = game.getStack().getSpell(event.getSourceId());
|
||||||
if (spell != null && filter.match(spell, game)) {
|
if (filter.match(spell, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ class ChaosMoonOddTriggeredAbility extends DelayedTriggeredManaAbility {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent land = game.getPermanentOrLKIBattlefield(event.getTargetId());
|
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()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(land.getControllerId()));
|
effect.setTargetPointer(new FixedTarget(land.getControllerId()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,6 +239,6 @@ class CityInABottleCantPlayEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
Card card = game.getCard(event.getSourceId());
|
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
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent land = game.getPermanentOrLKIBattlefield(event.getTargetId());
|
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
|
@Override
|
||||||
|
|
|
@ -73,7 +73,7 @@ class CultOfTheWaxingMoonAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
return permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game);
|
return filter.match(permanent, getSourceId(), getControllerId(), game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -74,7 +74,7 @@ class DeepWoodEffect extends PreventionEffectImpl {
|
||||||
DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
|
DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
|
||||||
if (event.getTargetId().equals(source.getControllerId())) {
|
if (event.getTargetId().equals(source.getControllerId())) {
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
|
Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
|
||||||
if (permanent != null && filter.match(permanent, game)) {
|
if (filter.match(permanent, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ class EchoBaseCommandoEffect extends CostModificationEffectImpl {
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify.getAbilityType() == AbilityType.ACTIVATED || (abilityToModify.getAbilityType() == AbilityType.MANA && (abilityToModify instanceof ActivatedAbility))) {
|
if (abilityToModify.getAbilityType() == AbilityType.ACTIVATED || (abilityToModify.getAbilityType() == AbilityType.MANA && (abilityToModify instanceof ActivatedAbility))) {
|
||||||
Permanent permanent = game.getPermanent(abilityToModify.getSourceId());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ class EmbalmersToolsEffect extends CostModificationEffectImpl {
|
||||||
|| (abilityToModify.getAbilityType() == AbilityType.MANA && (abilityToModify instanceof ActivatedAbility))) {
|
|| (abilityToModify.getAbilityType() == AbilityType.MANA && (abilityToModify instanceof ActivatedAbility))) {
|
||||||
// Activated abilities of creatures
|
// Activated abilities of creatures
|
||||||
Card card = game.getCard(abilityToModify.getSourceId());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ class NimbleTrapfinderWatcher extends Watcher {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent == null || !filter.match(permanent, game)) {
|
if (!filter.match(permanent, game)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
playerMap
|
playerMap
|
||||||
|
|
|
@ -982,7 +982,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
// check against current state
|
// check against current state
|
||||||
Zone test = game.getState().getZone(parameterSourceId);
|
Zone test = game.getState().getZone(parameterSourceId);
|
||||||
return test != null && zone.match(test);
|
return zone.match(test);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -295,7 +295,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
||||||
&& !(sourceObject instanceof PermanentToken) // it's no token
|
&& !(sourceObject instanceof PermanentToken) // it's no token
|
||||||
&& sourceObject.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(source.getSourceId())) { // It's in the next zone
|
&& sourceObject.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(source.getSourceId())) { // It's in the next zone
|
||||||
Zone after = game.getState().getZone(source.getSourceId());
|
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
|
return false; // Moving to graveyard was replaced so no trigger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class AttacksCreatureYouControlTriggeredAbility extends TriggeredAbilityI
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent sourcePermanent = game.getPermanent(event.getSourceId());
|
Permanent sourcePermanent = game.getPermanent(event.getSourceId());
|
||||||
if (sourcePermanent != null && filter.match(sourcePermanent, sourceId, controllerId, game)) {
|
if (filter.match(sourcePermanent, sourceId, controllerId, game)) {
|
||||||
if (setTargetPointer) {
|
if (setTargetPointer) {
|
||||||
this.getEffects().setTargetPointer(new FixedTarget(event.getSourceId(), game));
|
this.getEffects().setTargetPointer(new FixedTarget(event.getSourceId(), game));
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
int attackerCount = 0;
|
int attackerCount = 0;
|
||||||
for (UUID attackerId : game.getCombat().getAttackers()) {
|
for (UUID attackerId : game.getCombat().getAttackers()) {
|
||||||
Permanent attacker = game.getPermanent(attackerId);
|
Permanent attacker = game.getPermanent(attackerId);
|
||||||
if (attacker != null && filter.match(attacker, game)) {
|
if (filter.match(attacker, game)) {
|
||||||
attackerCount++;
|
attackerCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class BecomesBlockedAllTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
||||||
if (setTargetPointer) {
|
if (setTargetPointer) {
|
||||||
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
|
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class BecomesTappedTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
||||||
if (setTargetPointer) {
|
if (setTargetPointer) {
|
||||||
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
|
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class BlocksOrBecomesBlockedByOneOrMoreTriggeredAbility extends Triggered
|
||||||
}
|
}
|
||||||
for (UUID uuid : group.getBlockers()){
|
for (UUID uuid : group.getBlockers()){
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(uuid);
|
Permanent permanent = game.getPermanentOrLKIBattlefield(uuid);
|
||||||
if (permanent != null && filter.match(permanent, game)){
|
if (filter.match(permanent, game)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class BlocksOrBecomesBlockedByOneOrMoreTriggeredAbility extends Triggered
|
||||||
}
|
}
|
||||||
for (UUID uuid : group.getAttackers()){
|
for (UUID uuid : group.getAttackers()){
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(uuid);
|
Permanent permanent = game.getPermanentOrLKIBattlefield(uuid);
|
||||||
if (permanent != null && filter.match(permanent, game)){
|
if (filter.match(permanent, game)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class BlocksOrBecomesBlockedSourceTriggeredAbility extends TriggeredAbili
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getSourceId().equals(this.getSourceId())) {
|
if (event.getSourceId().equals(this.getSourceId())) {
|
||||||
Permanent blocked = game.getPermanent(event.getTargetId());
|
Permanent blocked = game.getPermanent(event.getTargetId());
|
||||||
if (blocked != null && filter.match(blocked, game)) {
|
if (filter.match(blocked, game)) {
|
||||||
if (setTargetPointer) {
|
if (setTargetPointer) {
|
||||||
this.getEffects().setTargetPointer(new FixedTarget(blocked, game));
|
this.getEffects().setTargetPointer(new FixedTarget(blocked, game));
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class BlocksOrBecomesBlockedSourceTriggeredAbility extends TriggeredAbili
|
||||||
}
|
}
|
||||||
if (event.getTargetId().equals(this.getSourceId())) {
|
if (event.getTargetId().equals(this.getSourceId())) {
|
||||||
Permanent blocker = game.getPermanent(event.getSourceId());
|
Permanent blocker = game.getPermanent(event.getSourceId());
|
||||||
if (blocker != null && filter.match(blocker, game)) {
|
if (filter.match(blocker, game)) {
|
||||||
if (setTargetPointer) {
|
if (setTargetPointer) {
|
||||||
this.getEffects().setTargetPointer(new FixedTarget(blocker, game));
|
this.getEffects().setTargetPointer(new FixedTarget(blocker, game));
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class BlocksOrBecomesBlockedTriggeredAbility extends TriggeredAbilityImpl
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getSourceId().equals(this.getSourceId())) {
|
if (event.getSourceId().equals(this.getSourceId())) {
|
||||||
Permanent blocked = game.getPermanent(event.getTargetId());
|
Permanent blocked = game.getPermanent(event.getTargetId());
|
||||||
if (blocked != null && filter.match(blocked, game)) {
|
if (filter.match(blocked, game)) {
|
||||||
if (setTargetPointer) {
|
if (setTargetPointer) {
|
||||||
this.getEffects().setTargetPointer(new FixedTarget(blocked, game));
|
this.getEffects().setTargetPointer(new FixedTarget(blocked, game));
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class BlocksOrBecomesBlockedTriggeredAbility extends TriggeredAbilityImpl
|
||||||
}
|
}
|
||||||
if (event.getTargetId().equals(this.getSourceId())) {
|
if (event.getTargetId().equals(this.getSourceId())) {
|
||||||
Permanent blocker = game.getPermanent(event.getSourceId());
|
Permanent blocker = game.getPermanent(event.getSourceId());
|
||||||
if (blocker != null && filter.match(blocker, game)) {
|
if (filter.match(blocker, game)) {
|
||||||
if (setTargetPointer) {
|
if (setTargetPointer) {
|
||||||
this.getEffects().setTargetPointer(new FixedTarget(blocker, game));
|
this.getEffects().setTargetPointer(new FixedTarget(blocker, game));
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
||||||
if (permanent == null || !filterPermanent.match(permanent, getSourceId(), getControllerId(), game)) {
|
if (!filterPermanent.match(permanent, getSourceId(), getControllerId(), game)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class DealsDamageToACreatureTriggeredAbility extends TriggeredAbilityImpl
|
||||||
&& (!combatOnly || ((DamagedEvent) event).isCombatDamage())) {
|
&& (!combatOnly || ((DamagedEvent) event).isCombatDamage())) {
|
||||||
if (filter != null) {
|
if (filter != null) {
|
||||||
Permanent creature = game.getPermanentOrLKIBattlefield(event.getTargetId());
|
Permanent creature = game.getPermanentOrLKIBattlefield(event.getTargetId());
|
||||||
if (creature == null || !filter.match(creature, getSourceId(), getControllerId(), game)) {
|
if (!filter.match(creature, getSourceId(), getControllerId(), game)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class DealsDamageToAPlayerAllTriggeredAbility extends TriggeredAbilityImp
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Permanent permanent = game.getPermanent(event.getSourceId());
|
Permanent permanent = game.getPermanent(event.getSourceId());
|
||||||
if (permanent == null || !filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
if (!filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.getEffects().setValue("damage", event.getAmount());
|
this.getEffects().setValue("damage", event.getAmount());
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class EntersBattlefieldAllTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
UUID targetId = event.getTargetId();
|
UUID targetId = event.getTargetId();
|
||||||
Permanent permanent = game.getPermanent(targetId);
|
Permanent permanent = game.getPermanent(targetId);
|
||||||
if (permanent == null || !filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
if (!filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.getEffects().setValue("permanentEnteringBattlefield", permanent);
|
this.getEffects().setValue("permanentEnteringBattlefield", permanent);
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class EntersBattlefieldOrAttacksAllTriggeredAbility extends TriggeredAbil
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD
|
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) {
|
if (setTargetPointer != SetTargetPointer.NONE) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
switch (setTargetPointer) {
|
switch (setTargetPointer) {
|
||||||
|
@ -98,7 +98,7 @@ public class EntersBattlefieldOrAttacksAllTriggeredAbility extends TriggeredAbil
|
||||||
|
|
||||||
Permanent attacker = game.getPermanent(event.getSourceId());
|
Permanent attacker = game.getPermanent(event.getSourceId());
|
||||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED
|
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) {
|
if (setTargetPointer != SetTargetPointer.NONE) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
switch (setTargetPointer) {
|
switch (setTargetPointer) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class LeavesBattlefieldAllTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
|
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
|
||||||
UUID targetId = event.getTargetId();
|
UUID targetId = event.getTargetId();
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(targetId);
|
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) {
|
if (setTargetPointer != SetTargetPointer.NONE) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
switch (setTargetPointer) {
|
switch (setTargetPointer) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class SacrificeAllTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Permanent sacrificedPermanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
|
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
|
@Override
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class SpellCastAllTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
getEffects().setValue("spellCast", spell);
|
getEffects().setValue("spellCast", spell);
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class SpellCastControllerTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getPlayerId().equals(this.getControllerId())) {
|
if (event.getPlayerId().equals(this.getControllerId())) {
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
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) {
|
if (rememberSource) {
|
||||||
this.getEffects().setValue("spellCast", spell);
|
this.getEffects().setValue("spellCast", spell);
|
||||||
if (rememberSourceAsCard) {
|
if (rememberSourceAsCard) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
getEffects().setValue("spellCast", spell);
|
getEffects().setValue("spellCast", spell);
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class TapForManaAllTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
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;
|
ManaEvent mEvent = (ManaEvent) event;
|
||||||
for(Effect effect:getEffects()) {
|
for(Effect effect:getEffects()) {
|
||||||
effect.setValue("mana", mEvent.getMana());
|
effect.setValue("mana", mEvent.getMana());
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class TapForManaAllTriggeredManaAbility extends TriggeredManaAbility {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
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;
|
ManaEvent mEvent = (ManaEvent) event;
|
||||||
for(Effect effect:getEffects()) {
|
for(Effect effect:getEffects()) {
|
||||||
effect.setValue("mana", mEvent.getMana());
|
effect.setValue("mana", mEvent.getMana());
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class TurnedFaceUpAllTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
||||||
if (setTargetPointer) {
|
if (setTargetPointer) {
|
||||||
for (Effect effect : getEffects()) {
|
for (Effect effect : getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
|
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class ZoneChangeAllTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
} else {
|
} else {
|
||||||
perm = game.getPermanent(event.getTargetId()); // LevelX2: maybe this part is not neccessary
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,10 @@ public class AttachedToMatchesFilterCondition implements Condition {
|
||||||
if (attachedTo == null) {
|
if (attachedTo == null) {
|
||||||
attachedTo = (Permanent) game.getLastKnownInformation(permanent.getAttachedTo(), Zone.BATTLEFIELD);
|
attachedTo = (Permanent) game.getLastKnownInformation(permanent.getAttachedTo(), Zone.BATTLEFIELD);
|
||||||
}
|
}
|
||||||
if (attachedTo != null) {
|
if (filter.match(attachedTo, attachedTo.getId(), attachedTo.getControllerId(), game)) {
|
||||||
if (filter.match(attachedTo, attachedTo.getId(), attachedTo.getControllerId(), game)) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,8 @@ public class EnchantedCreatureColorCondition implements Condition {
|
||||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||||
if (enchantment != null) {
|
if (enchantment != null) {
|
||||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||||
if (creature != null) {
|
if(filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)){
|
||||||
if(filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)){
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -26,11 +26,10 @@ public class EnchantedCreatureSubtypeCondition implements Condition {
|
||||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||||
if (enchantment != null) {
|
if (enchantment != null) {
|
||||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||||
if (creature != null) {
|
if (filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)) {
|
||||||
if (filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,10 @@ public class SourceMatchesFilterCondition implements Condition {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
|
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
|
||||||
if (permanent != null) {
|
if (FILTER.match(permanent, permanent.getId(), permanent.getControllerId(), game)) {
|
||||||
if (FILTER.match(permanent, permanent.getId(), permanent.getControllerId(), game)) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class SourceTargetsPermanentCondition implements Condition {
|
||||||
Iterator<Target> targets = sourceSpell.getStackAbility().getTargets().iterator();
|
Iterator<Target> targets = sourceSpell.getStackAbility().getTargets().iterator();
|
||||||
while (targets.hasNext()) {
|
while (targets.hasNext()) {
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(targets.next().getFirstTarget());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class AttackingCreatureCount implements DynamicValue {
|
||||||
for (UUID permId : combatGroup.getAttackers()) {
|
for (UUID permId : combatGroup.getAttackers()) {
|
||||||
if (filter != null) {
|
if (filter != null) {
|
||||||
Permanent attacker = game.getPermanent(permId);
|
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++;
|
count++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class CantBeCounteredControlledEffect extends ContinuousRuleModifyingEffe
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
MageObject sourceObject = game.getObject(event.getSourceId());
|
MageObject sourceObject = game.getObject(event.getSourceId());
|
||||||
if (sourceObject != null && filterSource.match(sourceObject, game)) {
|
if (filterSource.match(sourceObject, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class CantBeTargetedAllEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
} else {
|
} else {
|
||||||
sourceObject = stackObject;
|
sourceObject = stackObject;
|
||||||
}
|
}
|
||||||
if (sourceObject != null && filterSource.match(sourceObject, game)) {
|
if (filterSource.match(sourceObject, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class CantBeTargetedSourceEffect extends ContinuousRuleModifyingEffectImp
|
||||||
} else {
|
} else {
|
||||||
sourceObject = stackObject;
|
sourceObject = stackObject;
|
||||||
}
|
}
|
||||||
if (sourceObject != null && filterSource.match(sourceObject, game)) {
|
if (filterSource.match(sourceObject, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class CantBeTargetedTargetEffect extends ContinuousRuleModifyingEffectImp
|
||||||
} else {
|
} else {
|
||||||
sourceObject = stackObject;
|
sourceObject = stackObject;
|
||||||
}
|
}
|
||||||
if (sourceObject != null && filterSource.match(sourceObject, game)) {
|
if (filterSource.match(sourceObject, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class GainActivatedAbilitiesOfTopCardEffect extends ContinuousEffectImpl
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
Card card = player.getLibrary().getFromTop(game);
|
Card card = player.getLibrary().getFromTop(game);
|
||||||
if (card != null && filter.match(card, game)) {
|
if (filter.match(card, game)) {
|
||||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
for (Ability ability : card.getAbilities(game)) {
|
for (Ability ability : card.getAbilities(game)) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class PermanentsEnterBattlefieldTappedEffect extends ReplacementEffectImp
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
|
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
|
@Override
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class PreventAllDamageByAllPermanentsEffect extends PreventionEffectImpl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Permanent permanent = game.getPermanent(damageEvent.getSourceId());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class RevealCardsFromLibraryUntilEffect extends OneShotEffect {
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
cards.add(card);
|
cards.add(card);
|
||||||
}
|
}
|
||||||
} while (library.hasCards() && card != null && !filter.match(card, game));
|
} while (library.hasCards() && !filter.match(card, game));
|
||||||
// reveal cards
|
// reveal cards
|
||||||
if (!cards.isEmpty()) {
|
if (!cards.isEmpty()) {
|
||||||
controller.revealCards(sourceObject.getIdName(), cards, game);
|
controller.revealCards(sourceObject.getIdName(), cards, game);
|
||||||
|
|
|
@ -48,8 +48,7 @@ public class CanAttackAsThoughItDidntHaveDefenderAllEffect extends AsThoughEffec
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||||
Permanent permanent = game.getPermanent(objectId);
|
Permanent permanent = game.getPermanent(objectId);
|
||||||
return permanent != null
|
return filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
|
||||||
&& filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getText() {
|
private String getText() {
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
|
||||||
filter.add(SubType.AURA.getPredicate());
|
filter.add(SubType.AURA.getPredicate());
|
||||||
for (UUID attachmentId : new HashSet<>(permanent.getAttachments())) {
|
for (UUID attachmentId : new HashSet<>(permanent.getAttachments())) {
|
||||||
Permanent attachment = game.getPermanent(attachmentId);
|
Permanent attachment = game.getPermanent(attachmentId);
|
||||||
if (attachment != null && filter.match(attachment, game)) {
|
if (filter.match(attachment, game)) {
|
||||||
attachment.destroy(source, game, false);
|
attachment.destroy(source, game, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class GainAbilityControlledSpellsEffect extends ContinuousEffectImpl {
|
||||||
&& !stackObject.isCopy()
|
&& !stackObject.isCopy()
|
||||||
&& stackObject.isControlledBy(source.getControllerId())) {
|
&& stackObject.isControlledBy(source.getControllerId())) {
|
||||||
Card card = game.getCard(stackObject.getSourceId());
|
Card card = game.getCard(stackObject.getSourceId());
|
||||||
if (card != null && filter.match(card, game)) {
|
if (filter.match(card, game)) {
|
||||||
game.getState().addOtherAbility(card, ability);
|
game.getState().addOtherAbility(card, ability);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class SpellsCostIncreasingAllEffect extends CostModificationEffectImpl {
|
||||||
// get playable and other staff without put on stack
|
// get playable and other staff without put on stack
|
||||||
// used at least for flashback ability because Flashback ability doesn't use stack
|
// used at least for flashback ability because Flashback ability doesn't use stack
|
||||||
Card sourceCard = game.getCard(abilityToModify.getSourceId());
|
Card sourceCard = game.getCard(abilityToModify.getSourceId());
|
||||||
return sourceCard != null && this.filter.match(sourceCard, game);
|
return this.filter.match(sourceCard, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class SpellsCostModificationThatTargetSourceEffect extends CostModificati
|
||||||
}
|
}
|
||||||
|
|
||||||
Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game);
|
Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game);
|
||||||
if (spellCard == null || !this.spellFilter.match(spellCard, game)) {
|
if (!this.spellFilter.match(spellCard, game)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ class SpellCastManaCondition extends ManaCondition implements Condition {
|
||||||
} else if (object instanceof Commander) {
|
} else if (object instanceof Commander) {
|
||||||
spell = new Spell(((Commander) object).getSourceObject(), (SpellAbility) source, source.getControllerId(), game.getState().getZone(source.getSourceId()), game);
|
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;
|
return false;
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class FilterPermanent extends FilterObject<Permanent> implements FilterIn
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class TargetsPermanentPredicate implements ObjectSourcePlayerPredicate<Ob
|
||||||
}
|
}
|
||||||
for (UUID targetId : target.getTargets()) {
|
for (UUID targetId : target.getTargets()) {
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(targetId);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class AttachedToPredicate implements Predicate<Permanent> {
|
||||||
public boolean apply(Permanent input, Game game) {
|
public boolean apply(Permanent input, Game game) {
|
||||||
UUID attachedTo = input.getAttachedTo();
|
UUID attachedTo = input.getAttachedTo();
|
||||||
Permanent permanent = game.getPermanent(attachedTo);
|
Permanent permanent = game.getPermanent(attachedTo);
|
||||||
return permanent != null && filter.match(permanent, game);
|
return filter.match(permanent, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -60,7 +60,7 @@ class VenserTheSojournerSpellCastTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getPlayerId().equals(this.getControllerId())) {
|
if (event.getPlayerId().equals(this.getControllerId())) {
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ class EdgeOfMalacolEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
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();
|
UUID oldController = source.getControllerId();
|
||||||
source.setControllerId(game.getActivePlayerId());
|
source.setControllerId(game.getActivePlayerId());
|
||||||
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(2));
|
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(2));
|
||||||
|
|
|
@ -138,7 +138,7 @@ class FeedingGroundsEffect extends CostModificationEffectImpl {
|
||||||
} else {
|
} else {
|
||||||
// used at least for flashback ability because Flashback ability doesn't use stack
|
// used at least for flashback ability because Flashback ability doesn't use stack
|
||||||
Card sourceCard = game.getCard(abilityToModify.getSourceId());
|
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;
|
return false;
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class TargetPermanent extends TargetObject {
|
||||||
|
|
||||||
public boolean canTarget(UUID controllerId, UUID id, UUID sourceId, Game game, boolean flag) {
|
public boolean canTarget(UUID controllerId, UUID id, UUID sourceId, Game game, boolean flag) {
|
||||||
Permanent permanent = game.getPermanent(id);
|
Permanent permanent = game.getPermanent(id);
|
||||||
return permanent != null && filter.match(permanent, sourceId, controllerId, game);
|
return filter.match(permanent, sourceId, controllerId, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class TargetPlayer extends TargetImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean canTarget(UUID id, Game game) {
|
public boolean canTarget(UUID id, Game game) {
|
||||||
Player player = game.getPlayer(id);
|
Player player = game.getPlayer(id);
|
||||||
return player != null && filter.match(player, game);
|
return filter.match(player, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class TargetSpell extends TargetObject {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Spell spell = game.getStack().getSpell(id);
|
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
|
@Override
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class TargetStackObject extends TargetObject {
|
||||||
@Override
|
@Override
|
||||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||||
StackObject stackObject = game.getStack().getStackObject(id);
|
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
|
@Override
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class TargetAnyTarget extends TargetImpl {
|
||||||
return filter.match(permanent, game);
|
return filter.match(permanent, game);
|
||||||
}
|
}
|
||||||
Player player = game.getPlayer(id);
|
Player player = game.getPlayer(id);
|
||||||
return player != null && filter.match(player, game);
|
return filter.match(player, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,7 +88,7 @@ public class TargetAnyTarget extends TargetImpl {
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
return filter.match(permanent, game);
|
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)) {
|
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (player != null && filter.match(player, game)) {
|
if (filter.match(player, game)) {
|
||||||
count++;
|
count++;
|
||||||
if (count >= this.minNumberOfTargets) {
|
if (count >= this.minNumberOfTargets) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -193,7 +193,7 @@ public class TargetAnyTarget extends TargetImpl {
|
||||||
|
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (player != null && filter.match(player, game)) {
|
if (filter.match(player, game)) {
|
||||||
possibleTargets.add(playerId);
|
possibleTargets.add(playerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class TargetCardInHand extends TargetCard {
|
||||||
Card card = game.getCard(id);
|
Card card = game.getCard(id);
|
||||||
return game.getState().getZone(id) == Zone.HAND
|
return game.getState().getZone(id) == Zone.HAND
|
||||||
&& game.getState().getPlayersInRange(getTargetController() == null ? playerId : getTargetController(), game).contains(game.getOwnerId(id))
|
&& game.getState().getPlayersInRange(getTargetController() == null ? playerId : getTargetController(), game).contains(game.getOwnerId(id))
|
||||||
&& card != null && filter.match(card, game);
|
&& filter.match(card, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class TargetCardInLibrary extends TargetCard {
|
||||||
@Override
|
@Override
|
||||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||||
Card card = game.getPlayer(source.getControllerId()).getLibrary().getCard(id, 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
|
@Override
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
|
||||||
return filter.match(permanent, game);
|
return filter.match(permanent, game);
|
||||||
}
|
}
|
||||||
Player player = game.getPlayer(id);
|
Player player = game.getPlayer(id);
|
||||||
return player != null && filter.match(player, game);
|
return filter.match(player, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,7 +88,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
return filter.match(permanent, game);
|
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;
|
int count = 0;
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (player != null && filter.match(player, game)) {
|
if (filter.match(player, game)) {
|
||||||
count++;
|
count++;
|
||||||
if (count >= this.minNumberOfTargets) {
|
if (count >= this.minNumberOfTargets) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class TargetDiscard extends TargetCard {
|
||||||
@Override
|
@Override
|
||||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||||
Card card = game.getPlayer(playerId).getHand().get(id, 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
|
@Override
|
||||||
|
|
|
@ -51,7 +51,7 @@ public abstract class TargetPermanentAmount extends TargetAmount {
|
||||||
@Override
|
@Override
|
||||||
public boolean canTarget(UUID objectId, Game game) {
|
public boolean canTarget(UUID objectId, Game game) {
|
||||||
Permanent permanent = game.getPermanent(objectId);
|
Permanent permanent = game.getPermanent(objectId);
|
||||||
return permanent != null && filter.match(permanent, game);
|
return filter.match(permanent, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
||||||
return filter.match(permanent, game);
|
return filter.match(permanent, game);
|
||||||
}
|
}
|
||||||
Player player = game.getPlayer(id);
|
Player player = game.getPlayer(id);
|
||||||
return player != null && filter.match(player, game);
|
return filter.match(player, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -102,7 +102,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
return filter.match(permanent, game);
|
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<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (player != null && filter.match(player, game)) {
|
if (filter.match(player, game)) {
|
||||||
possibleTargets.add(playerId);
|
possibleTargets.add(playerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount {
|
||||||
return filter.match(permanent, game);
|
return filter.match(permanent, game);
|
||||||
}
|
}
|
||||||
Player player = game.getPlayer(objectId);
|
Player player = game.getPlayer(objectId);
|
||||||
return player != null && filter.match(player, game);
|
return filter.match(player, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,7 +83,7 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount {
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
return filter.match(permanent, game);
|
return filter.match(permanent, game);
|
||||||
}
|
}
|
||||||
return player != null && filter.match(player, game);
|
return filter.match(player, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl {
|
||||||
return filter.match(permanent, game);
|
return filter.match(permanent, game);
|
||||||
}
|
}
|
||||||
Card card = game.getExile().getCard(id, game);
|
Card card = game.getExile().getCard(id, game);
|
||||||
return card != null && filter.match(card, game);
|
return filter.match(card, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -134,7 +134,7 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Card card = game.getExile().getCard(id, game);
|
Card card = game.getExile().getCard(id, game);
|
||||||
return card != null && filter.match(card, game);
|
return filter.match(card, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class TargetSpellOrPermanent extends TargetImpl {
|
||||||
return filter.match(permanent, game);
|
return filter.match(permanent, game);
|
||||||
}
|
}
|
||||||
Spell spell = game.getStack().getSpell(id);
|
Spell spell = game.getStack().getSpell(id);
|
||||||
return spell != null && filter.match(spell, game);
|
return filter.match(spell, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue