diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java b/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java index d391282a49b..d6bc7ce28dc 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java @@ -190,13 +190,13 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene setCursor(new Cursor(Cursor.WAIT_CURSOR)); if (limited) { for (Card card: cards) { - if (filter.match(card)) + if (filter.match(card, null)) filteredCards.add(card); } } else { for (Card card: CardsStorage.getAllCards()) { - if (filter.match(card)) + if (filter.match(card, null)) filteredCards.add(card); } } diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/table/CardTableSelector.java b/Mage.Client/src/main/java/mage/client/deckeditor/table/CardTableSelector.java index ee48b4848b1..adf1135d3a3 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/table/CardTableSelector.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/table/CardTableSelector.java @@ -28,27 +28,9 @@ package mage.client.deckeditor.table; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.UUID; - -import javax.swing.DefaultComboBoxModel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - import mage.Constants.CardType; import mage.cards.Card; import mage.cards.ExpansionSet; -import mage.cards.MageCard; import mage.client.cards.BigCard; import mage.client.cards.CardEventSource; import mage.client.cards.CardsStorage; @@ -60,6 +42,16 @@ import mage.filter.FilterCard; import mage.sets.Sets; import mage.view.CardsView; +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.*; +import java.util.List; + /** * * @author BetaSteward_at_googlemail.com, nantuko @@ -156,13 +148,13 @@ public class CardTableSelector extends javax.swing.JPanel implements ComponentLi setCursor(new Cursor(Cursor.WAIT_CURSOR)); if (!cards.isEmpty()) { for (Card card: cards) { - if (filter.match(card)) + if (filter.match(card, null)) filteredCards.add(card); } } else { for (Card card: CardsStorage.getAllCards()) { - if (filter.match(card)) + if (filter.match(card, null)) filteredCards.add(card); } } diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java index 8c5849c0f78..dcc2feab0b5 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java @@ -899,7 +899,7 @@ public class ComputerPlayer6 extends ComputerPlayer implements int defenderForcesForBlock = 0; FilterCreatureForCombat filter = new FilterCreatureForCombat(); - for (Permanent possibleAttacker : game.getBattlefield().getAllActivePermanents(filter, defender.getId())) { + for (Permanent possibleAttacker : game.getBattlefield().getAllActivePermanents(filter, defender.getId(), game)) { //TODO: it can be improved with next turn emulation if (!possibleAttacker.getAbilities().contains(DefenderAbility.getInstance())) { counterAttackList.add(possibleAttacker); @@ -923,7 +923,7 @@ public class ComputerPlayer6 extends ComputerPlayer implements int possibleAttackersDamage = 0; int ourForces = 0; - for (Permanent possibleAttacker : game.getBattlefield().getAllActivePermanents(filter, playerId)) { + for (Permanent possibleAttacker : game.getBattlefield().getAllActivePermanents(filter, playerId, game)) { //TODO: it can be improved with next turn emulation if (!possibleAttacker.getAbilities().contains(DefenderAbility.getInstance())) { possibleAttackersList.add(possibleAttacker); @@ -1006,7 +1006,7 @@ public class ComputerPlayer6 extends ComputerPlayer implements int totalFirstStrikeBlockPower = 0; if (!attacker.getAbilities().contains(FirstStrikeAbility.getInstance()) && !attacker.getAbilities().contains(DoubleStrikeAbility.getInstance())) { - for (Permanent blockerWithFSorDB : game.getBattlefield().getAllActivePermanents(filter, playerId)) { + for (Permanent blockerWithFSorDB : game.getBattlefield().getAllActivePermanents(filter, playerId, game)) { if (blockerWithFSorDB.getAbilities().contains(DoubleStrikeAbility.getInstance())) { totalFirstStrikeBlockPower += 2 * blockerWithFSorDB.getPower().getValue(); } else diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index 1060b43dc4b..a7649b00f32 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -1411,7 +1411,7 @@ public class ComputerPlayer> extends PlayerImpl i protected List getOpponentBlockers(UUID opponentId, Game game) { FilterCreatureForCombat blockFilter = new FilterCreatureForCombat(); - List blockers = game.getBattlefield().getAllActivePermanents(blockFilter, opponentId); + List blockers = game.getBattlefield().getAllActivePermanents(blockFilter, opponentId, game); return blockers; } @@ -1515,7 +1515,7 @@ public class ComputerPlayer> extends PlayerImpl i protected List threats(UUID playerId, UUID sourceId, FilterPermanent filter, Game game, List targets) { List threats = playerId == null ? - game.getBattlefield().getAllActivePermanents(filter) : + game.getBattlefield().getAllActivePermanents(filter, game) : game.getBattlefield().getActivePermanents(filter, playerId, sourceId, game); Iterator it = threats.iterator(); diff --git a/Mage.Sets/src/mage/sets/apocalypse/BogGnarr.java b/Mage.Sets/src/mage/sets/apocalypse/BogGnarr.java index c2f6eb59f36..f970e4a3141 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/BogGnarr.java +++ b/Mage.Sets/src/mage/sets/apocalypse/BogGnarr.java @@ -92,7 +92,7 @@ class BogGnarrTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter)) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) { permanent.destroy(source.getId(), game, false); } return true; diff --git a/Mage.Sets/src/mage/sets/avacynrestored/AngelOfGlorysRise.java b/Mage.Sets/src/mage/sets/avacynrestored/AngelOfGlorysRise.java index 8dcdc0c5311..2f20a6c5d7e 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/AngelOfGlorysRise.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/AngelOfGlorysRise.java @@ -107,7 +107,7 @@ class AngelOfGlorysRiseEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - for (Permanent zombie : game.getBattlefield().getAllActivePermanents(filterZombie)) { + for (Permanent zombie : game.getBattlefield().getAllActivePermanents(filterZombie, game)) { zombie.moveToExile(source.getId(), zombie.getName(), source.getSourceId(), game); } for (Card human : player.getGraveyard().getCards(filterHuman, game)) { diff --git a/Mage.Sets/src/mage/sets/avacynrestored/BarterInBlood.java b/Mage.Sets/src/mage/sets/avacynrestored/BarterInBlood.java index fffd05fe0cf..1a534cf7c02 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/BarterInBlood.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/BarterInBlood.java @@ -27,7 +27,6 @@ */ package mage.sets.avacynrestored; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Outcome; import mage.Constants.Rarity; @@ -41,6 +40,8 @@ import mage.players.Player; import mage.target.Target; import mage.target.common.TargetControlledPermanent; +import java.util.UUID; + /** * * @author North @@ -91,7 +92,7 @@ class BarterInBloodEffect extends OneShotEffect { for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); if (player != null) { - int amount = Math.min(2, game.getBattlefield().countAll(filter, player.getId())); + int amount = Math.min(2, game.getBattlefield().countAll(filter, player.getId(), game)); Target target = new TargetControlledPermanent(amount, amount, filter, false); target.setRequired(true); if (amount > 0 && target.canChoose(player.getId(), game) diff --git a/Mage.Sets/src/mage/sets/avacynrestored/BonfireOfTheDamned.java b/Mage.Sets/src/mage/sets/avacynrestored/BonfireOfTheDamned.java index 2b6309e0262..b6203c85cf2 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/BonfireOfTheDamned.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/BonfireOfTheDamned.java @@ -94,7 +94,7 @@ class BonfireOfTheDamnedEffect extends OneShotEffect { int damage = source.getManaCostsToPay().getX(); if (damage > 0) { player.damage(damage, source.getId(), game, false, true); - for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId())) { + for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) { perm.damage(damage, source.getId(), game, true, false); } return true; diff --git a/Mage.Sets/src/mage/sets/avacynrestored/DescendantsPath.java b/Mage.Sets/src/mage/sets/avacynrestored/DescendantsPath.java index 039e75bf0cb..d260e477d73 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/DescendantsPath.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/DescendantsPath.java @@ -98,7 +98,7 @@ class DescendantsPathEffect extends OneShotEffect { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); filter.getSubtype().addAll(card.getSubtype()); filter.setScopeSubtype(Filter.ComparisonScope.Any); - int count = game.getBattlefield().getAllActivePermanents(filter, player.getId()).size(); + int count = game.getBattlefield().getAllActivePermanents(filter, player.getId(), game).size(); if (count > 0) { game.informPlayers("DescendantsPath: Found a creature that shares a creature type with the revealed card."); if (player.chooseUse(Constants.Outcome.Benefit, "Cast the card?", game)) { diff --git a/Mage.Sets/src/mage/sets/avacynrestored/DevastationTide.java b/Mage.Sets/src/mage/sets/avacynrestored/DevastationTide.java index fcf3595d4ae..85c14e2e1c7 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/DevastationTide.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/DevastationTide.java @@ -83,7 +83,7 @@ class DevastationTideEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterNonlandPermanent())) { + for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterNonlandPermanent(), game)) { creature.moveToZone(Constants.Zone.HAND, source.getSourceId(), game, true); } return true; diff --git a/Mage.Sets/src/mage/sets/avacynrestored/EssenceHarvest.java b/Mage.Sets/src/mage/sets/avacynrestored/EssenceHarvest.java index e8d9a22e302..a248c04b6de 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/EssenceHarvest.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/EssenceHarvest.java @@ -89,7 +89,7 @@ class EssenceHarvestEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(source.getFirstTarget()); if (player != null && targetPlayer != null) { - List creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId()); + List creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game); int amount = 0; for (Permanent creature : creatures) { int power = creature.getPower().getValue(); diff --git a/Mage.Sets/src/mage/sets/avacynrestored/KillingWave.java b/Mage.Sets/src/mage/sets/avacynrestored/KillingWave.java index fc6eebdf938..57e1ed7b4df 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/KillingWave.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/KillingWave.java @@ -27,10 +27,6 @@ */ package mage.sets.avacynrestored; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Outcome; import mage.Constants.Rarity; @@ -43,6 +39,11 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + /** * * @author North @@ -100,7 +101,7 @@ class KillingWaveEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent(); for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); - List creatures = game.getBattlefield().getAllActivePermanents(filter, playerId); + List creatures = game.getBattlefield().getAllActivePermanents(filter, playerId, game); int lifePaid = 0; int playerLife = player.getLife(); diff --git a/Mage.Sets/src/mage/sets/avacynrestored/LoneRevenant.java b/Mage.Sets/src/mage/sets/avacynrestored/LoneRevenant.java index 174708287f4..98395a0ee7a 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/LoneRevenant.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/LoneRevenant.java @@ -104,7 +104,7 @@ class LoneRevenantTriggeredAbility extends TriggeredAbilityImpl { filter.getCardType().add(cardType); for (UUID playerId : controller.getInRange()) { - int amount = Math.min(count, game.getBattlefield().countAll(filter, playerId)); + int amount = Math.min(count, game.getBattlefield().countAll(filter, playerId, game)); TargetControlledPermanent target = new TargetControlledPermanent(amount, amount, filter, false); target.setRequired(true); Player player = game.getPlayer(playerId); diff --git a/Mage.Sets/src/mage/sets/avacynrestored/SecondGuess.java b/Mage.Sets/src/mage/sets/avacynrestored/SecondGuess.java new file mode 100644 index 00000000000..afb191a4778 --- /dev/null +++ b/Mage.Sets/src/mage/sets/avacynrestored/SecondGuess.java @@ -0,0 +1,134 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.avacynrestored; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.effects.common.CounterTargetEffect; +import mage.cards.CardImpl; +import mage.filter.FilterSpell; +import mage.game.Game; +import mage.game.stack.Spell; +import mage.game.stack.StackObject; +import mage.target.TargetSpell; +import mage.watchers.common.CastSpellLastTurnWatcher; + +import java.util.UUID; + +/** + * + * @author noxx + */ +public class SecondGuess extends CardImpl { + + public SecondGuess(UUID ownerId) { + super(ownerId, 74, "Second Guess", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{1}{U}"); + this.expansionSetCode = "AVR"; + + this.color.setBlue(true); + + // Counter target spell that's the second spell cast this turn. + this.getSpellAbility().addEffect(new CounterTargetEffect()); + this.getSpellAbility().addTarget(new TargetSpell(new FilterSecondSpell())); + } + + public SecondGuess(final SecondGuess card) { + super(card); + } + + @Override + public SecondGuess copy() { + return new SecondGuess(this); + } +} + +class FilterSecondSpell extends FilterSpell { + + public FilterSecondSpell() { + super("spell that's the second spell cast this turn"); + } + + public FilterSecondSpell(final FilterSecondSpell filter) { + super(filter); + } + + @Override + public boolean match(StackObject spell, Game game) { + if (!super.match(spell, game)) + return notFilter; + + if (spell instanceof Spell) { + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher"); + + int index = watcher.getSpellOrder((Spell)spell); + + if (index == 2) { + return !notFilter; + } + } + + return notFilter; + } + + @Override + public boolean match(StackObject spell, UUID playerId, Game game) { + if (!super.match(spell, playerId, game)) + return notFilter; + + if (spell instanceof Spell) { + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher"); + + int index = watcher.getSpellOrder((Spell)spell); + + if (index == 2) { + return notFilter; + } + } + + return !notFilter; + } + + @Override + public FilterSecondSpell copy() { + return new FilterSecondSpell(this); + } + + public void setFromZone(Constants.Zone fromZone) { + this.fromZone = fromZone; + } + + public void setNotFromZone(boolean notFromZone) { + this.notFromZone = notFromZone; + } + +} + + + + diff --git a/Mage.Sets/src/mage/sets/avacynrestored/TyrantOfDiscord.java b/Mage.Sets/src/mage/sets/avacynrestored/TyrantOfDiscord.java index 56284a843fe..f16e820f23d 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/TyrantOfDiscord.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/TyrantOfDiscord.java @@ -96,7 +96,7 @@ class TyrantOfDiscordEffect extends OneShotEffect { if (opponent != null) { boolean stop = false; while (!stop) { - int count = game.getBattlefield().countAll(new FilterPermanent(), opponent.getId()); + int count = game.getBattlefield().countAll(new FilterPermanent(), opponent.getId(), game); if (count > 0) { int random = (int)(Math.random()*count); int index = 0; diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/FinalJudgment.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/FinalJudgment.java index 2473d74c053..6daeba065b9 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/FinalJudgment.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/FinalJudgment.java @@ -27,8 +27,6 @@ */ package mage.sets.betrayersofkamigawa; -import java.util.UUID; - import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; @@ -40,6 +38,8 @@ import mage.filter.FilterPermanent; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** * * @author Loki @@ -85,7 +85,7 @@ class FinalJudgmentEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter)) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) { permanent.moveToExile(null, null,source.getId(), game); } return true; diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/CallToGlory.java b/Mage.Sets/src/mage/sets/championsofkamigawa/CallToGlory.java index bdd924c3706..4a6a12ff5f6 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/CallToGlory.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/CallToGlory.java @@ -91,7 +91,7 @@ class CalltoGloryFirstEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId())) { + for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game)) { creature.untap(game); } return true; diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/PainwrackerOni.java b/Mage.Sets/src/mage/sets/championsofkamigawa/PainwrackerOni.java index 7b26a995fb8..dc4352e9a4b 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/PainwrackerOni.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/PainwrackerOni.java @@ -110,7 +110,7 @@ class PainwrackerOniTriggeredAbility1 extends TriggeredAbilityImpl { @Override public boolean apply(Game game, Ability source) { - for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId())) { + for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) { creature.moveToZone(Constants.Zone.HAND, source.getSourceId(), game, true); } return true; diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/TakenoSamuraiGeneral.java b/Mage.Sets/src/mage/sets/championsofkamigawa/TakenoSamuraiGeneral.java index ebd940c9e94..ea4e855845f 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/TakenoSamuraiGeneral.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/TakenoSamuraiGeneral.java @@ -28,8 +28,6 @@ package mage.sets.championsofkamigawa; -import java.util.UUID; - import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; @@ -44,6 +42,8 @@ import mage.filter.common.FilterControlledCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** * @author Loki */ @@ -99,7 +99,7 @@ class TakenoSamuraiGeneralEffect extends ContinuousEffectImpl= 1; + return game.getBattlefield().countAll(filter, this.controllerId, game) >= 1; } @Override @@ -144,7 +145,7 @@ class BloodhallOozeTriggeredAbility2 extends TriggeredAbilityImpl= 1; + return game.getBattlefield().countAll(filter, this.controllerId, game) >= 1; } @Override diff --git a/Mage.Sets/src/mage/sets/conflux/CourtHomunculus.java b/Mage.Sets/src/mage/sets/conflux/CourtHomunculus.java index e52ff63ef31..897f189c976 100644 --- a/Mage.Sets/src/mage/sets/conflux/CourtHomunculus.java +++ b/Mage.Sets/src/mage/sets/conflux/CourtHomunculus.java @@ -27,8 +27,6 @@ */ package mage.sets.conflux; -import java.util.List; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Duration; import mage.Constants.Rarity; @@ -44,6 +42,9 @@ import mage.filter.common.FilterArtifactPermanent; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.List; +import java.util.UUID; + /** * * @author North @@ -79,7 +80,7 @@ class ControlsAnotherArtifactCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - List controlledArtifacts = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), source.getControllerId()); + List controlledArtifacts = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), source.getControllerId(), game); for (Permanent permanent : controlledArtifacts) { if (!permanent.getId().equals(game.getObject(source.getSourceId()).getId())) { return true; diff --git a/Mage.Sets/src/mage/sets/conflux/DarkTemper.java b/Mage.Sets/src/mage/sets/conflux/DarkTemper.java index c4832bc3981..628aca46f80 100644 --- a/Mage.Sets/src/mage/sets/conflux/DarkTemper.java +++ b/Mage.Sets/src/mage/sets/conflux/DarkTemper.java @@ -27,7 +27,6 @@ */ package mage.sets.conflux; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Outcome; import mage.Constants.Rarity; @@ -39,6 +38,8 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** * * @author North @@ -93,7 +94,7 @@ class DarkTemperEffect extends OneShotEffect { filter.getColor().setBlack(true); filter.setUseColor(true); - if (game.getBattlefield().countAll(filter, source.getControllerId()) == 0) { + if (game.getBattlefield().countAll(filter, source.getControllerId(), game) == 0) { permanent.damage(2, source.getSourceId(), game, true, false); } else { permanent.destroy(source.getId(), game, false); diff --git a/Mage.Sets/src/mage/sets/conflux/GleamOfResistance.java b/Mage.Sets/src/mage/sets/conflux/GleamOfResistance.java index 3385f767b10..eec23fa8881 100644 --- a/Mage.Sets/src/mage/sets/conflux/GleamOfResistance.java +++ b/Mage.Sets/src/mage/sets/conflux/GleamOfResistance.java @@ -27,8 +27,6 @@ */ package mage.sets.conflux; -import java.util.UUID; - import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; @@ -42,6 +40,8 @@ import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** * * @author Loki @@ -82,7 +82,7 @@ class GleamOfResistanceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent perm: game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId())) { + for (Permanent perm: game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) { if (perm.isTapped()) { perm.untap(game); } diff --git a/Mage.Sets/src/mage/sets/conflux/ViewFromAbove.java b/Mage.Sets/src/mage/sets/conflux/ViewFromAbove.java index 7643560e6b1..aa736581b43 100644 --- a/Mage.Sets/src/mage/sets/conflux/ViewFromAbove.java +++ b/Mage.Sets/src/mage/sets/conflux/ViewFromAbove.java @@ -27,7 +27,6 @@ */ package mage.sets.conflux; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Duration; import mage.Constants.Rarity; @@ -42,6 +41,8 @@ import mage.filter.FilterPermanent; import mage.game.Game; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** * * @author North @@ -92,7 +93,7 @@ class ViewFromAboveEffect extends PostResolveEffect { filter.getColor().setWhite(true); filter.setUseColor(true); - if (game.getBattlefield().countAll(filter, source.getControllerId()) > 0) { + if (game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0) { card.moveToZone(Zone.HAND, source.getId(), game, false); } else { card.moveToZone(Zone.GRAVEYARD, source.getId(), game, false); diff --git a/Mage.Sets/src/mage/sets/darkascension/AlphaBrawl.java b/Mage.Sets/src/mage/sets/darkascension/AlphaBrawl.java index 1591e75fd1d..3844ee84bf5 100644 --- a/Mage.Sets/src/mage/sets/darkascension/AlphaBrawl.java +++ b/Mage.Sets/src/mage/sets/darkascension/AlphaBrawl.java @@ -27,13 +27,10 @@ */ package mage.sets.darkascension; -import java.util.UUID; import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.abilities.Ability; -import mage.abilities.dynamicvalue.DynamicValue; -import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; @@ -42,6 +39,8 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** * * @author BetaSteward @@ -96,10 +95,10 @@ class AlphaBrawlEffect extends OneShotEffect { Player player = game.getPlayer(creature.getControllerId()); if (player != null) { int power = creature.getPower().getValue(); - for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId())) { + for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) { perm.damage(power, creature.getId(), game, true, false); } - for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId())) { + for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) { creature.damage(perm.getPower().getValue(), perm.getId(), game, true, false); } return true; diff --git a/Mage.Sets/src/mage/sets/darkascension/BeguilerOfWills.java b/Mage.Sets/src/mage/sets/darkascension/BeguilerOfWills.java index 8521dc482c6..224ac3f2d91 100644 --- a/Mage.Sets/src/mage/sets/darkascension/BeguilerOfWills.java +++ b/Mage.Sets/src/mage/sets/darkascension/BeguilerOfWills.java @@ -27,7 +27,6 @@ */ package mage.sets.darkascension; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Duration; import mage.Constants.Rarity; @@ -43,6 +42,8 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; +import java.util.UUID; + /** * * @author North @@ -95,7 +96,7 @@ class BeguilerOfWillsTarget extends TargetPermanent { @Override public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { Permanent permanent = game.getPermanent(id); - int count = game.getBattlefield().countAll(this.filter, source.getControllerId()); + int count = game.getBattlefield().countAll(this.filter, source.getControllerId(), game); if (permanent != null && permanent.getPower().getValue() <= count) { return super.canTarget(controllerId, id, source, game); diff --git a/Mage.Sets/src/mage/sets/darkascension/DiregrafCaptain.java b/Mage.Sets/src/mage/sets/darkascension/DiregrafCaptain.java index 095214cc079..d6bba5a4784 100644 --- a/Mage.Sets/src/mage/sets/darkascension/DiregrafCaptain.java +++ b/Mage.Sets/src/mage/sets/darkascension/DiregrafCaptain.java @@ -27,22 +27,17 @@ */ package mage.sets.darkascension; -import java.util.UUID; - import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.MageInt; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.common.ZoneChangeTriggeredAbility; import mage.abilities.effects.common.LoseLifeTargetEffect; import mage.abilities.effects.common.continious.BoostControlledEffect; import mage.abilities.keyword.DeathtouchAbility; import mage.cards.CardImpl; import mage.filter.Filter; -import mage.filter.common.FilterControlledCreaturePermanent; -import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.events.GameEvent; @@ -50,6 +45,8 @@ import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; import mage.target.common.TargetOpponent; +import java.util.UUID; + /** * * @author Loki @@ -115,7 +112,7 @@ class DiregrafCaptainTriggeredAbility extends TriggeredAbilityImpl if (sourceId.equals(source.getSourceId())) { Card card = game.getCard(source.getSourceId()); if (card != null && game.getState().getZone(source.getSourceId()) == Constants.Zone.GRAVEYARD) { - if (game.getBattlefield().countAll(filter, source.getControllerId()) > 0) + if (game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0) return true; } } diff --git a/Mage.Sets/src/mage/sets/darkascension/Immerwolf.java b/Mage.Sets/src/mage/sets/darkascension/Immerwolf.java index 98fcf6c3810..f44d988ecb9 100644 --- a/Mage.Sets/src/mage/sets/darkascension/Immerwolf.java +++ b/Mage.Sets/src/mage/sets/darkascension/Immerwolf.java @@ -27,7 +27,6 @@ */ package mage.sets.darkascension; -import java.util.UUID; import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; @@ -44,6 +43,8 @@ import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; +import java.util.UUID; + /** * * @author BetaSteward @@ -129,7 +130,7 @@ class ImmerwolfEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == GameEvent.EventType.TRANSFORM) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && permanent.getControllerId().equals(source.getControllerId()) && filterWerewolf.match(permanent) && filterNonhuman.match(permanent)) { + if (permanent != null && permanent.getControllerId().equals(source.getControllerId()) && filterWerewolf.match(permanent, game) && filterNonhuman.match(permanent, game)) { return true; } } diff --git a/Mage.Sets/src/mage/sets/darkascension/PyreheartWolf.java b/Mage.Sets/src/mage/sets/darkascension/PyreheartWolf.java index fc9066f0c54..6a56ff2ae9f 100644 --- a/Mage.Sets/src/mage/sets/darkascension/PyreheartWolf.java +++ b/Mage.Sets/src/mage/sets/darkascension/PyreheartWolf.java @@ -94,7 +94,7 @@ class PyreheartWolfEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { FilterCreaturePermanent filter = new FilterCreaturePermanent(); - for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) { + for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { CantBeBlockedByOneEffect effect = new CantBeBlockedByOneEffect(2, Duration.EndOfTurn); SimpleStaticAbility ability = new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect); perm.addAbility(ability, game); diff --git a/Mage.Sets/src/mage/sets/darkascension/SuddenDisappearance.java b/Mage.Sets/src/mage/sets/darkascension/SuddenDisappearance.java index 5a8e14635f8..aa2f5601001 100644 --- a/Mage.Sets/src/mage/sets/darkascension/SuddenDisappearance.java +++ b/Mage.Sets/src/mage/sets/darkascension/SuddenDisappearance.java @@ -27,8 +27,6 @@ */ package mage.sets.darkascension; -import java.util.List; -import java.util.UUID; import mage.Constants; import mage.Constants.CardType; import mage.Constants.Outcome; @@ -43,6 +41,9 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.TargetPlayer; +import java.util.List; +import java.util.UUID; + /** * * @author BetaSteward @@ -85,9 +86,9 @@ class SuddenDisappearanceEffect extends OneShotEffect @Override public boolean apply(Game game, Ability source) { - List perms = game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget()); + List perms = game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game); if (perms.size() > 0) { - for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget())) { + for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game)) { permanent.moveToExile(source.getSourceId(), "Sudden Disappearance", source.getSourceId(), game); } AtEndOfTurnDelayedTriggeredAbility delayedAbility = new AtEndOfTurnDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Constants.Zone.BATTLEFIELD)); diff --git a/Mage.Sets/src/mage/sets/darksteel/Soulscour.java b/Mage.Sets/src/mage/sets/darksteel/Soulscour.java index b3802efe3d6..7b09cb8da97 100644 --- a/Mage.Sets/src/mage/sets/darksteel/Soulscour.java +++ b/Mage.Sets/src/mage/sets/darksteel/Soulscour.java @@ -87,7 +87,7 @@ class SoulscourEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter)) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) { permanent.destroy(source.getId(), game, false); } return true; diff --git a/Mage.Sets/src/mage/sets/innistrad/BalefireDragon.java b/Mage.Sets/src/mage/sets/innistrad/BalefireDragon.java index 3983730bd4f..3400e96124d 100644 --- a/Mage.Sets/src/mage/sets/innistrad/BalefireDragon.java +++ b/Mage.Sets/src/mage/sets/innistrad/BalefireDragon.java @@ -90,7 +90,7 @@ class BalefireDragonEffect extends OneShotEffect { if (player != null) { int amount = (Integer)getValue("damage"); if (amount > 0) { - for (Permanent creature: game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId())) { + for (Permanent creature: game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game)) { creature.damage(amount, source.getSourceId(), game, true, false); } } diff --git a/Mage.Sets/src/mage/sets/innistrad/BlasphemousAct.java b/Mage.Sets/src/mage/sets/innistrad/BlasphemousAct.java index a6ec73a9e18..de205cbc578 100644 --- a/Mage.Sets/src/mage/sets/innistrad/BlasphemousAct.java +++ b/Mage.Sets/src/mage/sets/innistrad/BlasphemousAct.java @@ -60,7 +60,7 @@ public class BlasphemousAct extends CardImpl { @Override public void adjustCosts(Ability ability, Game game) { - int creatureCount = game.getState().getBattlefield().getAllActivePermanents(new FilterCreaturePermanent()).size(); + int creatureCount = game.getState().getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), game).size(); int cost = 8 - creatureCount; String adjustedCost = "{R}"; if (cost > 0) { diff --git a/Mage.Sets/src/mage/sets/innistrad/BloodlineKeeper.java b/Mage.Sets/src/mage/sets/innistrad/BloodlineKeeper.java index 3af3c58be1b..f4b6b9e01d1 100644 --- a/Mage.Sets/src/mage/sets/innistrad/BloodlineKeeper.java +++ b/Mage.Sets/src/mage/sets/innistrad/BloodlineKeeper.java @@ -116,7 +116,7 @@ class ControlFiveVampiresCost extends CostImpl { @Override public boolean canPay(UUID sourceId, UUID controllerId, Game game) { - return game.getBattlefield().contains(filter, controllerId, 5); + return game.getBattlefield().contains(filter, controllerId, 5, game); } @Override diff --git a/Mage.Sets/src/mage/sets/innistrad/CurseOfDeathsHold.java b/Mage.Sets/src/mage/sets/innistrad/CurseOfDeathsHold.java index 29be1a434f5..4f675f325f8 100644 --- a/Mage.Sets/src/mage/sets/innistrad/CurseOfDeathsHold.java +++ b/Mage.Sets/src/mage/sets/innistrad/CurseOfDeathsHold.java @@ -27,14 +27,7 @@ */ package mage.sets.innistrad; -import java.util.UUID; -import mage.Constants.CardType; -import mage.Constants.Duration; -import mage.Constants.Layer; -import mage.Constants.Outcome; -import mage.Constants.Rarity; -import mage.Constants.SubLayer; -import mage.Constants.Zone; +import mage.Constants.*; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ContinuousEffectImpl; @@ -47,6 +40,8 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPlayer; +import java.util.UUID; + /** * * @author BetaSteward @@ -98,7 +93,7 @@ class CurseOfDeathsHoldEffect extends ContinuousEffectImpl { @Override public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { - if (!super.match(permanent)) + if (!super.match(permanent, game)) return notFilter; Permanent twin = game.getPermanent(sourceId); diff --git a/Mage.Sets/src/mage/sets/innistrad/FullMoonsRise.java b/Mage.Sets/src/mage/sets/innistrad/FullMoonsRise.java index defea56e531..e80e953bee3 100644 --- a/Mage.Sets/src/mage/sets/innistrad/FullMoonsRise.java +++ b/Mage.Sets/src/mage/sets/innistrad/FullMoonsRise.java @@ -110,7 +110,7 @@ class FullMoonsRiseEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { ReplacementEffect effect = new RegenerateTargetEffect(); effect.setTargetPointer(new FixedTarget(permanent.getId())); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/sets/innistrad/LilianaOfTheVeil.java b/Mage.Sets/src/mage/sets/innistrad/LilianaOfTheVeil.java index e5ab72f5998..b5ae050c9f0 100644 --- a/Mage.Sets/src/mage/sets/innistrad/LilianaOfTheVeil.java +++ b/Mage.Sets/src/mage/sets/innistrad/LilianaOfTheVeil.java @@ -27,9 +27,6 @@ */ package mage.sets.innistrad; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Outcome; import mage.Constants.Rarity; @@ -50,6 +47,10 @@ import mage.players.Player; import mage.target.TargetPermanent; import mage.target.TargetPlayer; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author North @@ -108,7 +109,7 @@ class LilianaOfTheVeilEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(source.getFirstTarget()); if (player != null && targetPlayer != null) { - int count = game.getBattlefield().countAll(new FilterPermanent(), targetPlayer.getId()); + int count = game.getBattlefield().countAll(new FilterPermanent(), targetPlayer.getId(), game); TargetPermanent target = new TargetPermanent(0, count, new FilterPermanent("permanents to put in the first pile"), false); List pile1 = new ArrayList(); if (player.choose(Outcome.Neutral, target, source.getSourceId(), game)) { diff --git a/Mage.Sets/src/mage/sets/innistrad/MemorysJourney.java b/Mage.Sets/src/mage/sets/innistrad/MemorysJourney.java index 5f23ad7ffe6..db9fe2cbab6 100644 --- a/Mage.Sets/src/mage/sets/innistrad/MemorysJourney.java +++ b/Mage.Sets/src/mage/sets/innistrad/MemorysJourney.java @@ -133,7 +133,7 @@ class MemorysJourneyTarget extends TargetCard { if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { UUID firstTarget = source.getFirstTarget(); if (firstTarget != null && game.getPlayer(firstTarget).getGraveyard().contains(id)) { - return filter.match(card); + return filter.match(card, game); } } return false; diff --git a/Mage.Sets/src/mage/sets/innistrad/NightRevelers.java b/Mage.Sets/src/mage/sets/innistrad/NightRevelers.java index 5b0b38f0871..0087477fdfa 100644 --- a/Mage.Sets/src/mage/sets/innistrad/NightRevelers.java +++ b/Mage.Sets/src/mage/sets/innistrad/NightRevelers.java @@ -27,8 +27,6 @@ */ package mage.sets.innistrad; -import java.util.Set; -import java.util.UUID; import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; @@ -43,6 +41,9 @@ import mage.cards.CardImpl; import mage.filter.FilterPermanent; import mage.game.Game; +import java.util.Set; +import java.util.UUID; + /** * * @author North @@ -86,7 +87,7 @@ class NightRevelersCondition implements Condition { Set opponents = game.getOpponents(source.getControllerId()); for (UUID opponentId : opponents) { - conditionApplies |= game.getBattlefield().countAll(filter, opponentId) > 0; + conditionApplies |= game.getBattlefield().countAll(filter, opponentId, game) > 0; } return conditionApplies; } diff --git a/Mage.Sets/src/mage/sets/innistrad/SmiteTheMonstrous.java b/Mage.Sets/src/mage/sets/innistrad/SmiteTheMonstrous.java index c0060b5576a..629dad14f87 100644 --- a/Mage.Sets/src/mage/sets/innistrad/SmiteTheMonstrous.java +++ b/Mage.Sets/src/mage/sets/innistrad/SmiteTheMonstrous.java @@ -32,6 +32,7 @@ import mage.Constants.Rarity; import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; import mage.filter.FilterPermanent; +import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; @@ -74,8 +75,8 @@ class FilterTheMonstrous extends FilterPermanent { } @Override - public boolean match(Permanent permanent) { - if (!super.match(permanent)) + public boolean match(Permanent permanent, Game game) { + if (!super.match(permanent, game)) return notFilter; if (!permanent.getCardType().contains(CardType.CREATURE)) diff --git a/Mage.Sets/src/mage/sets/innistrad/UnbreathingHorde.java b/Mage.Sets/src/mage/sets/innistrad/UnbreathingHorde.java index c9df6c2114b..63eb9c5176d 100644 --- a/Mage.Sets/src/mage/sets/innistrad/UnbreathingHorde.java +++ b/Mage.Sets/src/mage/sets/innistrad/UnbreathingHorde.java @@ -104,7 +104,7 @@ class UnbreathingHordeEffect1 extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null && player != null) { - int amount = game.getBattlefield().countAll(filter1, source.getControllerId()) - 1; + int amount = game.getBattlefield().countAll(filter1, source.getControllerId(), game) - 1; amount += player.getGraveyard().count(filter2, game); if (amount > 0) { permanent.addCounters(CounterType.P1P1.createInstance(amount), game); diff --git a/Mage.Sets/src/mage/sets/innistrad/UrgentExorcism.java b/Mage.Sets/src/mage/sets/innistrad/UrgentExorcism.java index 41e332deb4f..42c94d8a458 100644 --- a/Mage.Sets/src/mage/sets/innistrad/UrgentExorcism.java +++ b/Mage.Sets/src/mage/sets/innistrad/UrgentExorcism.java @@ -27,15 +27,17 @@ */ package mage.sets.innistrad; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; import mage.filter.FilterPermanent; +import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; +import java.util.UUID; + /** * * @author nantuko @@ -74,8 +76,8 @@ class FilterSpiritOrEnchantment extends FilterPermanent { Player targetPlayer = game.getPlayer(source.getFirstTarget()); if (targetPlayer != null) { for (Card card: targetPlayer.getGraveyard().getCards(game)) { - if (!filter.match(card)) { + if (!filter.match(card, game)) { card.moveToExile(null, "", source.getId(), game); FilterCard filterCard = new FilterCard("cards named " + card.getName()); diff --git a/Mage.Sets/src/mage/sets/magic2010/MasterOfTheWildHunt.java b/Mage.Sets/src/mage/sets/magic2010/MasterOfTheWildHunt.java index 5e5fb5547d9..cb2630b6059 100644 --- a/Mage.Sets/src/mage/sets/magic2010/MasterOfTheWildHunt.java +++ b/Mage.Sets/src/mage/sets/magic2010/MasterOfTheWildHunt.java @@ -28,9 +28,6 @@ package mage.sets.magic2010; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Outcome; import mage.Constants.Rarity; @@ -52,6 +49,10 @@ import mage.game.permanent.token.WolfToken; import mage.players.Player; import mage.target.common.TargetCreaturePermanent; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -114,8 +115,8 @@ class MasterOfTheWildHuntEffect extends OneShotEffect public boolean apply(Game game, Ability source) { List wolves = new ArrayList(); Permanent target = game.getPermanent(source.getFirstTarget()); - if (target != null && game.getBattlefield().countAll(filter, source.getControllerId()) > 0) { - for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) { + if (target != null && game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0) { + for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { permanent.tap(game); target.damage(permanent.getToughness().getValue(), permanent.getId(), game, true, false); wolves.add(permanent.getId()); diff --git a/Mage.Sets/src/mage/sets/magic2010/PlanarCleansing.java b/Mage.Sets/src/mage/sets/magic2010/PlanarCleansing.java index 80b3b2eb315..6a0fd925170 100644 --- a/Mage.Sets/src/mage/sets/magic2010/PlanarCleansing.java +++ b/Mage.Sets/src/mage/sets/magic2010/PlanarCleansing.java @@ -85,7 +85,7 @@ class PlanarCleansingEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter)) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) { permanent.destroy(source.getId(), game, false); } return true; diff --git a/Mage.Sets/src/mage/sets/magic2010/SerpentOfTheEndlessSea.java b/Mage.Sets/src/mage/sets/magic2010/SerpentOfTheEndlessSea.java index 3fde0e90d33..05d2096a68f 100644 --- a/Mage.Sets/src/mage/sets/magic2010/SerpentOfTheEndlessSea.java +++ b/Mage.Sets/src/mage/sets/magic2010/SerpentOfTheEndlessSea.java @@ -114,7 +114,7 @@ class SerpentOfTheEndlessSeaEffect extends ReplacementEffectImpl { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { - for (Permanent creature: game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId())) { + for (Permanent creature: game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game)) { creature.tap(game); game.addEffect(new SleepEffect2(creature.getId()), source); } diff --git a/Mage.Sets/src/mage/sets/magic2010/TempestOfLight.java b/Mage.Sets/src/mage/sets/magic2010/TempestOfLight.java index f2b2c527405..42971badb00 100644 --- a/Mage.Sets/src/mage/sets/magic2010/TempestOfLight.java +++ b/Mage.Sets/src/mage/sets/magic2010/TempestOfLight.java @@ -83,7 +83,7 @@ class TempestOfLightEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter)) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) { permanent.destroy(source.getId(), game, false); } return true; diff --git a/Mage.Sets/src/mage/sets/magic2011/HarborSerpent.java b/Mage.Sets/src/mage/sets/magic2011/HarborSerpent.java index 9264d4b31fa..a72cf06d212 100644 --- a/Mage.Sets/src/mage/sets/magic2011/HarborSerpent.java +++ b/Mage.Sets/src/mage/sets/magic2011/HarborSerpent.java @@ -97,7 +97,7 @@ class HarborSerpentEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - if (game.getBattlefield().countAll(filter) < 5) { + if (game.getBattlefield().countAll(filter, game) < 5) { return true; } return false; diff --git a/Mage.Sets/src/mage/sets/magic2011/MassPolymorph.java b/Mage.Sets/src/mage/sets/magic2011/MassPolymorph.java index aa4e3f5b04d..776a32678f7 100644 --- a/Mage.Sets/src/mage/sets/magic2011/MassPolymorph.java +++ b/Mage.Sets/src/mage/sets/magic2011/MassPolymorph.java @@ -28,8 +28,6 @@ package mage.sets.magic2011; -import java.util.List; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Outcome; import mage.Constants.Rarity; @@ -45,6 +43,9 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; +import java.util.List; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -82,7 +83,7 @@ class MassPolymorphEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int count; - List creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId()); + List creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game); count = creatures.size(); for (Permanent creature: creatures) { creature.moveToExile(null, null, source.getId(), game); diff --git a/Mage.Sets/src/mage/sets/magic2011/OverwhelmingStampede.java b/Mage.Sets/src/mage/sets/magic2011/OverwhelmingStampede.java index 667436df138..2881c02b576 100644 --- a/Mage.Sets/src/mage/sets/magic2011/OverwhelmingStampede.java +++ b/Mage.Sets/src/mage/sets/magic2011/OverwhelmingStampede.java @@ -28,13 +28,7 @@ package mage.sets.magic2011; -import java.util.UUID; -import mage.Constants.CardType; -import mage.Constants.Duration; -import mage.Constants.Layer; -import mage.Constants.Outcome; -import mage.Constants.Rarity; -import mage.Constants.SubLayer; +import mage.Constants.*; import mage.abilities.Ability; import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.keyword.TrampleAbility; @@ -43,6 +37,8 @@ import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -85,11 +81,11 @@ class OverwhelmingStampedeEffect extends ContinuousEffectImpl maxPower) maxPower = perm.getPower().getValue(); } - for (Permanent perm: game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId())) { + for (Permanent perm: game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) { switch (layer) { case PTChangingEffects_7: if (sublayer == SubLayer.ModifyPT_7c) { diff --git a/Mage.Sets/src/mage/sets/magic2012/AdaptiveAutomaton.java b/Mage.Sets/src/mage/sets/magic2012/AdaptiveAutomaton.java index e30e2bf22ac..f2b529d1606 100644 --- a/Mage.Sets/src/mage/sets/magic2012/AdaptiveAutomaton.java +++ b/Mage.Sets/src/mage/sets/magic2012/AdaptiveAutomaton.java @@ -165,7 +165,7 @@ class AdaptiveAutomatonBoostControlledEffect extends ContinuousEffectImpl { if (player == null) { return false; } - List creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId()); + List creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game); for (Permanent creature : creatures) { final String creatureName = creature.getName(); if (!namesFiltered.contains(creatureName)) { diff --git a/Mage.Sets/src/mage/sets/magic2012/Scrambleverse.java b/Mage.Sets/src/mage/sets/magic2012/Scrambleverse.java index 5986076cdc0..b9211970f41 100644 --- a/Mage.Sets/src/mage/sets/magic2012/Scrambleverse.java +++ b/Mage.Sets/src/mage/sets/magic2012/Scrambleverse.java @@ -27,11 +27,6 @@ */ package mage.sets.magic2012; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.UUID; - import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; @@ -40,16 +35,16 @@ import mage.abilities.Mode; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.continious.GainControlTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterNonlandPermanent; import mage.game.Game; import mage.game.permanent.Permanent; -import mage.players.Player; import mage.players.PlayerList; -import mage.players.Players; import mage.target.targetpointer.FixedTarget; +import java.util.Random; +import java.util.UUID; + /** * * @author nantuko @@ -94,7 +89,7 @@ class ScrambleverseEffect extends OneShotEffect { int count = players.size(); if (count > 1) { FilterNonlandPermanent nonLand = new FilterNonlandPermanent(); - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(nonLand)) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(nonLand, game)) { ContinuousEffect effect = new ScrambleverseControlEffect(players.get(random.nextInt(count))); effect.setTargetPointer(new FixedTarget(permanent.getId())); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/sets/magic2012/TimelyReinforcements.java b/Mage.Sets/src/mage/sets/magic2012/TimelyReinforcements.java index 3218fab9c8b..188f3792cec 100644 --- a/Mage.Sets/src/mage/sets/magic2012/TimelyReinforcements.java +++ b/Mage.Sets/src/mage/sets/magic2012/TimelyReinforcements.java @@ -27,13 +27,10 @@ */ package mage.sets.magic2012; -import java.util.UUID; - import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.abilities.Ability; -import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CreateTokenEffect; @@ -44,6 +41,8 @@ import mage.game.Game; import mage.game.permanent.token.SoldierToken; import mage.players.Player; +import java.util.UUID; + /** * @author nantuko */ @@ -86,14 +85,14 @@ class TimelyReinforcementsEffect extends OneShotEffect controller.getLife()) { lessLife = true; } - if (game.getBattlefield().countAll(filter, uuid) > count) { + if (game.getBattlefield().countAll(filter, uuid, game) > count) { lessCreatures = true; } } diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/ConcussiveBolt.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/ConcussiveBolt.java index 047720d34dc..897db3d9a2d 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/ConcussiveBolt.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/ConcussiveBolt.java @@ -27,14 +27,7 @@ */ package mage.sets.mirrodinbesieged; -import java.util.List; -import java.util.UUID; -import mage.Constants.CardType; -import mage.Constants.Duration; -import mage.Constants.Layer; -import mage.Constants.Outcome; -import mage.Constants.Rarity; -import mage.Constants.SubLayer; +import mage.Constants.*; import mage.abilities.Ability; import mage.abilities.common.CantBlockAbility; import mage.abilities.condition.common.MetalcraftCondition; @@ -48,6 +41,9 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPlayer; +import java.util.List; +import java.util.UUID; + /** * * @author North @@ -96,7 +92,7 @@ class ConcussiveBoltEffect extends ContinuousEffectImpl { int affectedTargets = 0; Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { - List permanents = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId()); + List permanents = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game); for (Permanent permanent : permanents) { permanent.addAbility(CantBlockAbility.getInstance(), game); affectedTargets++; diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/ThopterAssembly.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/ThopterAssembly.java index 4d792990551..750d1617663 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/ThopterAssembly.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/ThopterAssembly.java @@ -94,7 +94,7 @@ class ThopterAssemblyTriggeredAbility extends TriggeredAbilityImpl { if (permanent != null) { ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color"); if (color != null) { - for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) { + for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { if (perm.getColor().contains(color)) { perm.addPower(1); perm.addToughness(1); diff --git a/Mage.Sets/src/mage/sets/newphyrexia/UnwindingClock.java b/Mage.Sets/src/mage/sets/newphyrexia/UnwindingClock.java index 481f6a66880..27fa7c0e8d8 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/UnwindingClock.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/UnwindingClock.java @@ -95,7 +95,7 @@ class UnwindingClockEffect extends ContinuousEffectImpl { if (!applied && layer.equals(Layer.RulesEffects)) { if (!game.getActivePlayerId().equals(source.getControllerId()) && game.getStep().getType() == PhaseStep.UNTAP) { game.getState().setValue(source.getSourceId() + "applied", true); - for (Permanent artifact: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) { + for (Permanent artifact: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { boolean untap = true; for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(artifact, game)) { untap &= effect.canBeUntapped(artifact, game); diff --git a/Mage.Sets/src/mage/sets/newphyrexia/WarReport.java b/Mage.Sets/src/mage/sets/newphyrexia/WarReport.java index 0b25b7ce4df..009e7a8d4c1 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/WarReport.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/WarReport.java @@ -27,7 +27,6 @@ */ package mage.sets.newphyrexia; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Outcome; import mage.Constants.Rarity; @@ -39,6 +38,8 @@ import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.players.Player; +import java.util.UUID; + /** * * @author North @@ -84,8 +85,8 @@ class WarReportEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - int lifeToGain = game.getBattlefield().countAll(new FilterCreaturePermanent()); - lifeToGain += game.getBattlefield().countAll(new FilterArtifactPermanent()); + int lifeToGain = game.getBattlefield().countAll(new FilterCreaturePermanent(), game); + lifeToGain += game.getBattlefield().countAll(new FilterArtifactPermanent(), game); player.gainLife(lifeToGain, game); } return true; diff --git a/Mage.Sets/src/mage/sets/newphyrexia/Xenograft.java b/Mage.Sets/src/mage/sets/newphyrexia/Xenograft.java index 9f5135ef3ef..83632434c20 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/Xenograft.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/Xenograft.java @@ -126,7 +126,7 @@ class XenograftAddSubtypeEffect extends ContinuousEffectImpl permanents = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId()); + List permanents = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game); for (Permanent permanent : permanents) { if (permanent != null && !permanent.getSubtype().contains(subtype)) { permanent.getSubtype().add(subtype); diff --git a/Mage.Sets/src/mage/sets/planechase/AkromasVengeance.java b/Mage.Sets/src/mage/sets/planechase/AkromasVengeance.java index e98fe0df15c..9abfc8065fa 100644 --- a/Mage.Sets/src/mage/sets/planechase/AkromasVengeance.java +++ b/Mage.Sets/src/mage/sets/planechase/AkromasVengeance.java @@ -88,7 +88,7 @@ class AkromasVengeanceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter)) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) { permanent.destroy(source.getId(), game, false); } return true; diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/BroodBirthing.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/BroodBirthing.java index 6b294fa255a..7ece7867d76 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/BroodBirthing.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/BroodBirthing.java @@ -88,7 +88,7 @@ class BroodBirthingEffect extends OneShotEffect { filter.setScopeSubtype(ComparisonScope.All); EldraziSpawnToken token = new EldraziSpawnToken(); - int count = game.getBattlefield().countAll(filter, source.getControllerId()) > 0 ? 3 : 1; + int count = game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0 ? 3 : 1; token.putOntoBattlefield(count, game, source.getSourceId(), source.getControllerId()); return true; } diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/DawnglareInvoker.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/DawnglareInvoker.java index e27f559c584..46195125a46 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/DawnglareInvoker.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/DawnglareInvoker.java @@ -95,7 +95,7 @@ class DawnglareInvokerEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { - List allCreatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId()); + List allCreatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game); for (Permanent creature : allCreatures) { creature.tap(game); } diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/HellionEruption.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/HellionEruption.java index aa759cb9a6f..ddd887a7b3a 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/HellionEruption.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/HellionEruption.java @@ -27,8 +27,6 @@ */ package mage.sets.riseoftheeldrazi; -import java.util.List; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Outcome; import mage.Constants.Rarity; @@ -41,6 +39,9 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.permanent.token.Token; +import java.util.List; +import java.util.UUID; + /** * * @author North @@ -85,7 +86,7 @@ class HellionEruptionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List permanents = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId()); + List permanents = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game); for (Permanent permanent : permanents) { permanent.sacrifice(source.getSourceId(), game); } diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/KhalniHydra.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/KhalniHydra.java index fd4064f41de..09db70103ec 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/KhalniHydra.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/KhalniHydra.java @@ -77,7 +77,7 @@ public class KhalniHydra extends CardImpl { @Override public void adjustCosts(Ability ability, Game game) { super.adjustCosts(ability, game); - int reductionAmount = game.getBattlefield().getAllActivePermanents(filter).size(); + int reductionAmount = game.getBattlefield().getAllActivePermanents(filter, game).size(); Iterator iter = ability.getManaCostsToPay().iterator(); while ( reductionAmount > 0 && iter.hasNext() ) { diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/NotOfThisWorld.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/NotOfThisWorld.java index 47856bfc422..1b17c6ba5ff 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/NotOfThisWorld.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/NotOfThisWorld.java @@ -27,23 +27,22 @@ */ package mage.sets.riseoftheeldrazi; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - import mage.Constants.CardType; import mage.Constants.Rarity; import mage.Constants.Zone; import mage.abilities.Ability; import mage.abilities.effects.common.CounterTargetEffect; import mage.cards.CardImpl; -import mage.filter.Filter; import mage.filter.FilterSpell; import mage.game.Game; import mage.game.stack.Spell; import mage.game.stack.StackObject; import mage.target.TargetObject; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author Rafbill @@ -144,7 +143,7 @@ class TargetSpellTargetingControlledPermanent extends public boolean canTarget(UUID id, Ability source, Game game) { Spell spell = game.getStack().getSpell(id); if (spell != null) { - return filter.match(spell); + return filter.match(spell, game); } return false; } @@ -161,7 +160,7 @@ class TargetSpellTargetingControlledPermanent extends if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange() .contains(stackObject.getControllerId()) - && filter.match((Spell) stackObject) + && filter.match((Spell) stackObject, game) && ((Spell) stackObject).getSpellAbility().getTargets() .isChosen() && game.getPermanent(((Spell) stackObject) @@ -191,7 +190,7 @@ class TargetSpellTargetingControlledPermanent extends if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange() .contains(stackObject.getControllerId()) - && filter.match((Spell) stackObject) + && filter.match((Spell) stackObject, game) && ((Spell) stackObject).getSpellAbility().getTargets() .isChosen() && game.getPermanent(((Spell) stackObject) diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/SarkhanTheMad.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/SarkhanTheMad.java index a110f8e477f..83be4fa05c6 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/SarkhanTheMad.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/SarkhanTheMad.java @@ -180,7 +180,7 @@ class SarkhanTheMadDragonDamageEffect extends OneShotEffect dragons = game.getBattlefield().getAllActivePermanents(filter); + List dragons = game.getBattlefield().getAllActivePermanents(filter, game); Player player = game.getPlayer(source.getTargets().getFirstTarget()); if ( player != null && dragons != null && !dragons.isEmpty() ) { for ( Permanent dragon : dragons ) { diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/UnifiedWill.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/UnifiedWill.java index 2ca83a83a4e..99c51aa41f4 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/UnifiedWill.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/UnifiedWill.java @@ -28,7 +28,6 @@ package mage.sets.riseoftheeldrazi; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.abilities.Ability; @@ -39,6 +38,8 @@ import mage.game.Game; import mage.game.stack.StackObject; import mage.target.TargetSpell; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -79,7 +80,7 @@ class UnifiedWillEffect extends CounterTargetEffect { public boolean apply(Game game, Ability source) { StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget()); if (stackObject != null) { - if (game.getBattlefield().countAll(filter, source.getControllerId()) > game.getBattlefield().countAll(filter, stackObject.getControllerId())) { + if (game.getBattlefield().countAll(filter, source.getControllerId(), game) > game.getBattlefield().countAll(filter, stackObject.getControllerId(), game)) { return game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game); } return true; diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/VeneratedTeacher.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/VeneratedTeacher.java index 97d81cb38b9..9be32ec83e4 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/VeneratedTeacher.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/VeneratedTeacher.java @@ -88,7 +88,7 @@ class VeneratedTeacherEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List permanents = game.getBattlefield().getAllActivePermanents(filter, source.getControllerId()); + List permanents = game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game); if (!permanents.isEmpty()) { for (Permanent permanent : permanents) { for (Ability ability : permanent.getAbilities()) { diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java index dfff0675344..e4d8316498c 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java @@ -27,7 +27,6 @@ */ package mage.sets.scarsofmirrodin; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Outcome; import mage.Constants.Rarity; @@ -46,6 +45,8 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetOpponent; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -96,7 +97,7 @@ class CerebralEruptionEffect1 extends OneShotEffect { game.getState().setValue(source.getId().toString(), card); int damage = card.getManaCost().convertedManaCost(); player.damage(damage, source.getId(), game, false, true); - for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId())) { + for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) { perm.damage(damage, source.getId(), game, true, false); } return true; diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/ContagionEngine.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/ContagionEngine.java index a65ce3156c6..96e6713db76 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/ContagionEngine.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/ContagionEngine.java @@ -91,7 +91,7 @@ class ContagionEngineEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player target = game.getPlayer(source.getFirstTarget()); if (target != null) { - for (Permanent p : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), target.getId())) { + for (Permanent p : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), target.getId(), game)) { p.addCounters(CounterType.M1M1.createInstance(), game); } return true; diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/ElspethTirel.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/ElspethTirel.java index 09d4d5b9915..74af93e1edd 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/ElspethTirel.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/ElspethTirel.java @@ -28,12 +28,9 @@ package mage.sets.scarsofmirrodin; -import java.util.UUID; - import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; -import mage.MageInt; import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; import mage.abilities.common.EntersBattlefieldAbility; @@ -49,6 +46,8 @@ import mage.game.permanent.PermanentToken; import mage.game.permanent.token.SoldierToken; import mage.players.Player; +import java.util.UUID; + /** * * @author Loki @@ -90,7 +89,7 @@ class ElspethTirelFirstEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - int amount = game.getBattlefield().countAll(new FilterCreaturePermanent(), source.getControllerId()); + int amount = game.getBattlefield().countAll(new FilterCreaturePermanent(), source.getControllerId(), game); Player player = game.getPlayer(source.getControllerId()); if (player != null) { player.gainLife(amount, game); diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/PrecursorGolem.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/PrecursorGolem.java index 8d5d6e0272a..1eb3f740e1a 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/PrecursorGolem.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/PrecursorGolem.java @@ -174,7 +174,7 @@ class PrecursorGolemCopySpellEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { UUID defendingPlayer = game.getCombat().getDefendingPlayer(source.getSourceId()); if (defendingPlayer != null) { - return game.getBattlefield().countAll(filter, defendingPlayer) > 0; + return game.getBattlefield().countAll(filter, defendingPlayer, game) > 0; } return false; } diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/StrataScythe.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/StrataScythe.java index b9b5fd22751..a75148d063f 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/StrataScythe.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/StrataScythe.java @@ -134,7 +134,7 @@ class SameNameAsExiledCountValue implements DynamicValue { if (permanent != null && permanent.getImprinted().size() > 0) { FilterPermanent filterPermanent = new FilterPermanent(); filterPermanent.getName().add(game.getCard(permanent.getImprinted().get(0)).getName()); - value = game.getBattlefield().countAll(filterPermanent); + value = game.getBattlefield().countAll(filterPermanent, game); } return value; } diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/TurnAside.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/TurnAside.java index 831f2f88fb1..8c241a81403 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/TurnAside.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/TurnAside.java @@ -43,7 +43,6 @@ import mage.game.stack.StackObject; import mage.target.TargetObject; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import java.util.UUID; @@ -124,7 +123,7 @@ public class TurnAside extends CardImpl { public boolean canChoose(UUID sourceControllerId, Game game) { int count = 0; for (StackObject stackObject : game.getStack()) { - if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match((Spell) stackObject)) { + if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match((Spell) stackObject, game)) { if (targetsMyPermanent(stackObject.getId(), sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) @@ -139,7 +138,7 @@ public class TurnAside extends CardImpl { public Set possibleTargets(UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet(); for (StackObject stackObject : game.getStack()) { - if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match((Spell) stackObject)) { + if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match((Spell) stackObject, game)) { if (targetsMyPermanent(stackObject.getId(), sourceControllerId, game)) { possibleTargets.add(stackObject.getId()); diff --git a/Mage.Sets/src/mage/sets/shadowmoor/LeechriddenSwamp.java b/Mage.Sets/src/mage/sets/shadowmoor/LeechriddenSwamp.java index 44bca836d4c..52689cb93d2 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/LeechriddenSwamp.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/LeechriddenSwamp.java @@ -102,7 +102,7 @@ class ControlTwoOrMoreBlackPermanentsCost extends CostImpl permanents = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), source.getControllerId()); + List permanents = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), source.getControllerId(), game); for (Permanent permanent : permanents) { if (permanent != null) { switch (layer) { diff --git a/Mage.Sets/src/mage/sets/tempest/Tranquility.java b/Mage.Sets/src/mage/sets/tempest/Tranquility.java index a137b4cc953..1d510781358 100644 --- a/Mage.Sets/src/mage/sets/tempest/Tranquility.java +++ b/Mage.Sets/src/mage/sets/tempest/Tranquility.java @@ -83,7 +83,7 @@ class TranquilityEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter)) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) { permanent.destroy(source.getId(), game, false); } return true; diff --git a/Mage.Sets/src/mage/sets/worldwake/TectonicEdge.java b/Mage.Sets/src/mage/sets/worldwake/TectonicEdge.java index 96d711cb551..860d78b8a67 100644 --- a/Mage.Sets/src/mage/sets/worldwake/TectonicEdge.java +++ b/Mage.Sets/src/mage/sets/worldwake/TectonicEdge.java @@ -28,7 +28,6 @@ package mage.sets.worldwake; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.Constants.Zone; @@ -47,6 +46,8 @@ import mage.filter.common.FilterLandPermanent; import mage.game.Game; import mage.target.common.TargetNonBasicLandPermanent; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -98,7 +99,7 @@ class TectonicEdgeCost extends CostImpl { @Override public boolean canPay(UUID sourceId, UUID controllerId, Game game) { for (UUID opponentId: game.getOpponents(controllerId)) { - if (game.getBattlefield().countAll(filter, opponentId) > 3) { + if (game.getBattlefield().countAll(filter, opponentId, game) > 3) { return true; } } diff --git a/Mage.Sets/src/mage/sets/zendikar/ArmamentMaster.java b/Mage.Sets/src/mage/sets/zendikar/ArmamentMaster.java index 513301a737c..75699b679c2 100644 --- a/Mage.Sets/src/mage/sets/zendikar/ArmamentMaster.java +++ b/Mage.Sets/src/mage/sets/zendikar/ArmamentMaster.java @@ -27,15 +27,7 @@ */ package mage.sets.zendikar; -import java.util.List; -import java.util.UUID; -import mage.Constants.CardType; -import mage.Constants.Duration; -import mage.Constants.Layer; -import mage.Constants.Outcome; -import mage.Constants.Rarity; -import mage.Constants.SubLayer; -import mage.Constants.Zone; +import mage.Constants.*; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; @@ -45,6 +37,9 @@ import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.List; +import java.util.UUID; + /** * * @author North @@ -106,7 +101,7 @@ class ArmamentMasterEffect extends ContinuousEffectImpl { public void init(Ability source, Game game) { super.init(source, game); if (this.affectedObjectsSet) { - List permanents = game.getBattlefield().getAllActivePermanents(filter, source.getControllerId()); + List permanents = game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game); for (Permanent perm : permanents) { if (!perm.getId().equals(source.getSourceId())) { objects.add(perm.getId()); @@ -118,7 +113,7 @@ class ArmamentMasterEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { int count = countEquipment(game, source); - List permanents = game.getBattlefield().getAllActivePermanents(filter, source.getControllerId()); + List permanents = game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game); for (Permanent perm : permanents) { if (!this.affectedObjectsSet || objects.contains(perm.getId())) { if (!perm.getId().equals(source.getSourceId())) { diff --git a/Mage.Sets/src/mage/sets/zendikar/EmeriaTheSkyRuin.java b/Mage.Sets/src/mage/sets/zendikar/EmeriaTheSkyRuin.java index d9350f312e1..f36516f4742 100644 --- a/Mage.Sets/src/mage/sets/zendikar/EmeriaTheSkyRuin.java +++ b/Mage.Sets/src/mage/sets/zendikar/EmeriaTheSkyRuin.java @@ -27,7 +27,6 @@ */ package mage.sets.zendikar; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.Constants.Zone; @@ -43,6 +42,8 @@ import mage.game.Game; import mage.game.events.GameEvent; import mage.target.common.TargetCardInYourGraveyard; +import java.util.UUID; + /** * * @author North @@ -105,7 +106,7 @@ class EmeriaTheSkyRuinTriggeredAbility extends TriggeredAbilityImpl= 7; + return game.getBattlefield().countAll(filter, this.controllerId, game) >= 7; } @Override diff --git a/Mage.Sets/src/mage/sets/zendikar/FeastOfBlood.java b/Mage.Sets/src/mage/sets/zendikar/FeastOfBlood.java index 6c46a97a097..01e16ca5e6f 100644 --- a/Mage.Sets/src/mage/sets/zendikar/FeastOfBlood.java +++ b/Mage.Sets/src/mage/sets/zendikar/FeastOfBlood.java @@ -89,7 +89,7 @@ class FeastOfBloodCost extends CostImpl { @Override public boolean canPay(UUID sourceId, UUID controllerId, Game game) { - return game.getBattlefield().contains(filter, controllerId, 2); + return game.getBattlefield().contains(filter, controllerId, 2, game); } @Override diff --git a/Mage.Sets/src/mage/sets/zendikar/MalakirBloodwitch.java b/Mage.Sets/src/mage/sets/zendikar/MalakirBloodwitch.java index 352b214618e..f21ca4c9b7a 100644 --- a/Mage.Sets/src/mage/sets/zendikar/MalakirBloodwitch.java +++ b/Mage.Sets/src/mage/sets/zendikar/MalakirBloodwitch.java @@ -107,7 +107,7 @@ class MalakirBloodwitchEffect extends OneShotEffect { FilterControlledPermanent filter = new FilterControlledPermanent("Vampire"); filter.getSubtype().add("Vampire"); - int amount = game.getBattlefield().countAll(filter, source.getControllerId()); + int amount = game.getBattlefield().countAll(filter, source.getControllerId(), game); Set opponents = game.getOpponents(source.getControllerId()); int total = 0; diff --git a/Mage.Sets/src/mage/sets/zendikar/MarshCasualties.java b/Mage.Sets/src/mage/sets/zendikar/MarshCasualties.java index 93a9c50d4f8..8f49254ecbc 100644 --- a/Mage.Sets/src/mage/sets/zendikar/MarshCasualties.java +++ b/Mage.Sets/src/mage/sets/zendikar/MarshCasualties.java @@ -27,14 +27,7 @@ */ package mage.sets.zendikar; -import java.util.List; -import java.util.UUID; -import mage.Constants.CardType; -import mage.Constants.Duration; -import mage.Constants.Layer; -import mage.Constants.Outcome; -import mage.Constants.Rarity; -import mage.Constants.SubLayer; +import mage.Constants.*; import mage.abilities.Ability; import mage.abilities.condition.common.KickedCondition; import mage.abilities.costs.mana.KickerManaCost; @@ -46,6 +39,9 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.TargetPlayer; +import java.util.List; +import java.util.UUID; + /** * * @author North @@ -107,7 +103,7 @@ class MarshCasualtiesEffect extends ContinuousEffectImpl public void init(Ability source, Game game) { super.init(source, game); if (this.affectedObjectsSet) { - List creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget()); + List creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget(), game); for (Permanent creature : creatures) { objects.add(creature.getId()); } @@ -116,7 +112,7 @@ class MarshCasualtiesEffect extends ContinuousEffectImpl @Override public boolean apply(Game game, Ability source) { - List creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget()); + List creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget(), game); for (Permanent creature : creatures) { if (!this.affectedObjectsSet || objects.contains(creature.getId())) { creature.addPower(power); diff --git a/Mage.Sets/src/mage/sets/zendikar/MindlessNull.java b/Mage.Sets/src/mage/sets/zendikar/MindlessNull.java index 0c923b0a8c4..217fbd38b3b 100644 --- a/Mage.Sets/src/mage/sets/zendikar/MindlessNull.java +++ b/Mage.Sets/src/mage/sets/zendikar/MindlessNull.java @@ -95,7 +95,7 @@ class MindlessNullEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - if (game.getBattlefield().countAll(filter, source.getControllerId()) == 0) { + if (game.getBattlefield().countAll(filter, source.getControllerId(), game) == 0) { return true; } return false; diff --git a/Mage.Sets/src/mage/sets/zendikar/NissaRevane.java b/Mage.Sets/src/mage/sets/zendikar/NissaRevane.java index a2a379cc997..a0f0ba471b8 100644 --- a/Mage.Sets/src/mage/sets/zendikar/NissaRevane.java +++ b/Mage.Sets/src/mage/sets/zendikar/NissaRevane.java @@ -114,7 +114,7 @@ class NissaRevaneGainLifeEffect extends OneShotEffect @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - int life = 2 * game.getBattlefield().countAll(filter); + int life = 2 * game.getBattlefield().countAll(filter, game); if (player != null) { player.gainLife(life, game); } diff --git a/Mage.Sets/src/mage/sets/zendikar/ScuteMob.java b/Mage.Sets/src/mage/sets/zendikar/ScuteMob.java index 0dd2ade001f..cb438cd109d 100644 --- a/Mage.Sets/src/mage/sets/zendikar/ScuteMob.java +++ b/Mage.Sets/src/mage/sets/zendikar/ScuteMob.java @@ -96,7 +96,7 @@ class ScuteMobAbility extends TriggeredAbilityImpl { @Override public boolean checkInterveningIfClause(Game game) { - return game.getBattlefield().countAll(filter, this.controllerId) >= 5; + return game.getBattlefield().countAll(filter, this.controllerId, game) >= 5; } @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/SoulbondKeywordTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/SoulbondKeywordTest.java index e1a668f9517..7c8bffe3ca0 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/SoulbondKeywordTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/SoulbondKeywordTest.java @@ -5,7 +5,6 @@ import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; import mage.abilities.keyword.LifelinkAbility; import mage.filter.Filter; -import org.junit.Assert; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -352,7 +351,18 @@ public class SoulbondKeywordTest extends CardTestPlayerBase { @Test public void testExileAndReturnBack() { - //TODO: Soulbond + Soulshift - Assert.assertTrue(false); + addCard(Constants.Zone.HAND, playerA, "Elite Vanguard"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Trusted Forcemage"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Plains", 2); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Elite Vanguard"); + castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Cloudshift", "Trusted Forcemage"); + + setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Trusted Forcemage", 1); + assertPowerToughness(playerA, "Trusted Forcemage", 3, 3); + assertPowerToughness(playerA, "Elite Vanguard", 3, 2); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/counterspell/SecondGuessTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/counterspell/SecondGuessTest.java new file mode 100644 index 00000000000..137b95cdbc3 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/counterspell/SecondGuessTest.java @@ -0,0 +1,105 @@ +package org.mage.test.cards.abilities.oneshot.counterspell; + +import mage.Constants; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author noxx + */ +public class SecondGuessTest extends CardTestPlayerBase { + + @Test + public void testCounterFirstSpell() { + addCard(Constants.Zone.HAND, playerA, "Lightning Bolt"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 1); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 2); + addCard(Constants.Zone.HAND, playerA, "Second Guess"); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Second Guess", "Lightning Bolt"); + + setStopAt(1, Constants.PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 17); + + assertHandCount(playerA, 1); + } + + @Test + public void testCounterSecondSpell() { + addCard(Constants.Zone.HAND, playerA, "Lightning Bolt", 1); + addCard(Constants.Zone.HAND, playerA, "Shock", 1); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 2); + addCard(Constants.Zone.HAND, playerA, "Second Guess"); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Shock", playerB); + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Second Guess", "Lightning Bolt"); + + setStopAt(1, Constants.PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 17); + + assertHandCount(playerA, 0); + assertGraveyardCount(playerA, 3); + } + + @Test + public void testCounterThirdSpell() { + addCard(Constants.Zone.HAND, playerA, "Lightning Bolt", 2); + addCard(Constants.Zone.HAND, playerA, "Shock", 1); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 3); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 2); + addCard(Constants.Zone.HAND, playerA, "Second Guess"); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Shock", playerB); + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Second Guess", "Shock"); + + setStopAt(1, Constants.PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 12); + + assertHandCount(playerA, 0); + assertGraveyardCount(playerA, 4); + } + + /** + * Tests that spell are counted for all players + */ + @Test + public void testOverallCount() { + addCard(Constants.Zone.HAND, playerA, "Lightning Bolt"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 2); + addCard(Constants.Zone.HAND, playerA, "Second Guess"); + + addCard(Constants.Zone.HAND, playerB, "Shock"); + addCard(Constants.Zone.BATTLEFIELD, playerB, "Mountain"); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerB, "Shock", playerA); + castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Second Guess", "Shock"); + + setStopAt(1, Constants.PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 17); + + assertHandCount(playerA, 0); + assertGraveyardCount(playerA, 2); + assertHandCount(playerB, 0); + assertGraveyardCount(playerB, 1); + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index b65d4345434..9a821dfd60e 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -181,7 +181,7 @@ public class TestPlayer extends ComputerPlayer { public boolean choose(Constants.Outcome outcome, Target target, UUID sourceId, Game game, Map options) { if (!choices.isEmpty()) { if (target instanceof TargetPermanent) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents((FilterPermanent)target.getFilter())) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents((FilterPermanent)target.getFilter(), game)) { for (String choose2: choices) { if (permanent.getName().equals(choose2)) { if (((TargetPermanent)target).canTarget(playerId, permanent.getId(), null, game) && !target.getTargets().contains(permanent.getId())) { @@ -204,7 +204,7 @@ public class TestPlayer extends ComputerPlayer { } protected Permanent findPermanent(FilterPermanent filter, UUID controllerId, Game game) { - List permanents = game.getBattlefield().getAllActivePermanents(filter, controllerId); + List permanents = game.getBattlefield().getAllActivePermanents(filter, controllerId, game); if (permanents.size() > 0) return permanents.get(0); return null; diff --git a/Mage/src/mage/abilities/common/DiesAnotherCreatureTriggeredAbility.java b/Mage/src/mage/abilities/common/DiesAnotherCreatureTriggeredAbility.java index ba8796f5a0d..43087c828a3 100644 --- a/Mage/src/mage/abilities/common/DiesAnotherCreatureTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/DiesAnotherCreatureTriggeredAbility.java @@ -70,7 +70,7 @@ public class DiesAnotherCreatureTriggeredAbility extends TriggeredAbilityImpl this.count; + conditionApplies = game.getBattlefield().countAll(filter, source.getControllerId(), game) > this.count; break; case EQUAL_TO: - conditionApplies = game.getBattlefield().countAll(filter, source.getControllerId()) == this.count; + conditionApplies = game.getBattlefield().countAll(filter, source.getControllerId(), game) == this.count; break; } diff --git a/Mage/src/mage/abilities/condition/common/MetalcraftCondition.java b/Mage/src/mage/abilities/condition/common/MetalcraftCondition.java index f915fd43eca..eb587fcbda0 100644 --- a/Mage/src/mage/abilities/condition/common/MetalcraftCondition.java +++ b/Mage/src/mage/abilities/condition/common/MetalcraftCondition.java @@ -27,6 +27,6 @@ public class MetalcraftCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - return game.getBattlefield().contains(filter, source.getControllerId(), 3); + return game.getBattlefield().contains(filter, source.getControllerId(), 3, game); } } diff --git a/Mage/src/mage/abilities/condition/common/NoControlledCreatureCondition.java b/Mage/src/mage/abilities/condition/common/NoControlledCreatureCondition.java index 47545371703..adc589bd990 100644 --- a/Mage/src/mage/abilities/condition/common/NoControlledCreatureCondition.java +++ b/Mage/src/mage/abilities/condition/common/NoControlledCreatureCondition.java @@ -47,6 +47,6 @@ public class NoControlledCreatureCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - return game.getBattlefield().countAll(filter, source.getControllerId()) == 0; + return game.getBattlefield().countAll(filter, source.getControllerId(), game) == 0; } } diff --git a/Mage/src/mage/abilities/condition/common/NoCreatureCondition.java b/Mage/src/mage/abilities/condition/common/NoCreatureCondition.java index 76ba8e63982..9713c65ff2e 100644 --- a/Mage/src/mage/abilities/condition/common/NoCreatureCondition.java +++ b/Mage/src/mage/abilities/condition/common/NoCreatureCondition.java @@ -46,6 +46,6 @@ public class NoCreatureCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - return game.getBattlefield().countAll(filter) == 0; + return game.getBattlefield().countAll(filter, game) == 0; } } diff --git a/Mage/src/mage/abilities/condition/common/OneControlledCreatureCondition.java b/Mage/src/mage/abilities/condition/common/OneControlledCreatureCondition.java index ced47575db8..fe9e3e19202 100644 --- a/Mage/src/mage/abilities/condition/common/OneControlledCreatureCondition.java +++ b/Mage/src/mage/abilities/condition/common/OneControlledCreatureCondition.java @@ -47,6 +47,6 @@ public class OneControlledCreatureCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - return game.getBattlefield().countAll(filter, source.getControllerId()) == 1; + return game.getBattlefield().countAll(filter, source.getControllerId(), game) == 1; } } diff --git a/Mage/src/mage/abilities/condition/common/PermanentHasCounterCondition.java b/Mage/src/mage/abilities/condition/common/PermanentHasCounterCondition.java index d53778d9095..dcb8cc15962 100644 --- a/Mage/src/mage/abilities/condition/common/PermanentHasCounterCondition.java +++ b/Mage/src/mage/abilities/condition/common/PermanentHasCounterCondition.java @@ -63,7 +63,7 @@ public class PermanentHasCounterCondition implements Condition { @Override public boolean apply(Game game, Ability source) { boolean conditionApplies = false; - List permanents = game.getBattlefield().getAllActivePermanents(this.filter, source.getControllerId()); + List permanents = game.getBattlefield().getAllActivePermanents(this.filter, source.getControllerId(), game); for (Permanent permanent : permanents) { switch (this.type) { case FEWER_THAN: diff --git a/Mage/src/mage/abilities/costs/common/ControlPermanentCost.java b/Mage/src/mage/abilities/costs/common/ControlPermanentCost.java index efd62e6c8dc..8d1ce3e5fa9 100644 --- a/Mage/src/mage/abilities/costs/common/ControlPermanentCost.java +++ b/Mage/src/mage/abilities/costs/common/ControlPermanentCost.java @@ -22,7 +22,7 @@ public class ControlPermanentCost extends CostImpl { @Override public boolean canPay(UUID sourceId, UUID controllerId, Game game) { - return game.getBattlefield().contains(filter, controllerId, 1); + return game.getBattlefield().contains(filter, controllerId, 1, game); } @Override diff --git a/Mage/src/mage/abilities/costs/common/MetalcraftCost.java b/Mage/src/mage/abilities/costs/common/MetalcraftCost.java index d6708dc6873..f6c6f827e26 100644 --- a/Mage/src/mage/abilities/costs/common/MetalcraftCost.java +++ b/Mage/src/mage/abilities/costs/common/MetalcraftCost.java @@ -62,7 +62,7 @@ public class MetalcraftCost extends CostImpl { @Override public boolean canPay(UUID sourceId, UUID controllerId, Game game) { - return game.getBattlefield().contains(filter, controllerId, 3); + return game.getBattlefield().contains(filter, controllerId, 3, game); } @Override diff --git a/Mage/src/mage/abilities/effects/PlaneswalkerRedirectionEffect.java b/Mage/src/mage/abilities/effects/PlaneswalkerRedirectionEffect.java index aa60fd6295e..727c330cd3c 100644 --- a/Mage/src/mage/abilities/effects/PlaneswalkerRedirectionEffect.java +++ b/Mage/src/mage/abilities/effects/PlaneswalkerRedirectionEffect.java @@ -28,7 +28,6 @@ package mage.abilities.effects; -import java.util.UUID; import mage.Constants.Duration; import mage.Constants.Outcome; import mage.abilities.Ability; @@ -42,6 +41,8 @@ import mage.game.stack.StackObject; import mage.players.Player; import mage.target.TargetPermanent; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -72,11 +73,11 @@ public class PlaneswalkerRedirectionEffect extends RedirectionEffect 0 && player.chooseUse(outcome, "Redirect damage to planeswalker?", game)) { redirectTarget = new TargetPermanent(filter); if (numPlaneswalkers == 1) { - redirectTarget.add(game.getBattlefield().getAllActivePermanents(filter, target.getId()).get(0).getId(), game); + redirectTarget.add(game.getBattlefield().getAllActivePermanents(filter, target.getId(), game).get(0).getId(), game); } else { player.choose(Outcome.Damage, redirectTarget, null, game); diff --git a/Mage/src/mage/abilities/effects/common/CantCounterControlledEffect.java b/Mage/src/mage/abilities/effects/common/CantCounterControlledEffect.java index e20162eab45..b260e796dab 100644 --- a/Mage/src/mage/abilities/effects/common/CantCounterControlledEffect.java +++ b/Mage/src/mage/abilities/effects/common/CantCounterControlledEffect.java @@ -90,12 +90,12 @@ public class CantCounterControlledEffect extends ReplacementEffectImpl 0 && filter.match(card)) + if (numberToPick.calculate(game, source) > 0 && filter.match(card, game)) ++foundCardsToPick; } diff --git a/Mage/src/mage/abilities/effects/common/PreventAllDamageEffect.java b/Mage/src/mage/abilities/effects/common/PreventAllDamageEffect.java index 9249095e9f7..2bf8dae54bc 100644 --- a/Mage/src/mage/abilities/effects/common/PreventAllDamageEffect.java +++ b/Mage/src/mage/abilities/effects/common/PreventAllDamageEffect.java @@ -107,7 +107,7 @@ public class PreventAllDamageEffect extends PreventionEffectImpl { public boolean apply(Game game, Ability source) { List perms = new ArrayList(); for (Player player: game.getPlayers().values()) { - int numTargets = Math.min(amount, game.getBattlefield().countAll(filter, player.getId())); + int numTargets = Math.min(amount, game.getBattlefield().countAll(filter, player.getId(), game)); TargetControlledPermanent target = new TargetControlledPermanent(numTargets, numTargets, filter, false); if (target.canChoose(player.getId(), game)) { while (!target.isChosen()) { diff --git a/Mage/src/mage/abilities/effects/common/SacrificeEffect.java b/Mage/src/mage/abilities/effects/common/SacrificeEffect.java index bdb2ed92096..d2792ee5cde 100644 --- a/Mage/src/mage/abilities/effects/common/SacrificeEffect.java +++ b/Mage/src/mage/abilities/effects/common/SacrificeEffect.java @@ -82,7 +82,7 @@ public class SacrificeEffect extends OneShotEffect{ filter.setTargetController(Constants.TargetController.YOU); int amount = count.calculate(game, source); - int realCount = game.getBattlefield().countAll(filter, player.getId()); + int realCount = game.getBattlefield().countAll(filter, player.getId(), game); amount = Math.min(amount, realCount); Target target = new TargetControlledPermanent(amount, amount, filter, false); diff --git a/Mage/src/mage/abilities/effects/common/UntapAllControllerEffect.java b/Mage/src/mage/abilities/effects/common/UntapAllControllerEffect.java index d8b66044a85..6502a9a4957 100644 --- a/Mage/src/mage/abilities/effects/common/UntapAllControllerEffect.java +++ b/Mage/src/mage/abilities/effects/common/UntapAllControllerEffect.java @@ -61,7 +61,7 @@ public class UntapAllControllerEffect extends OneShotEffect opponents = game.getOpponents(source.getControllerId()); - for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter)) { + for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, game)) { if (opponents.contains(perm.getControllerId())) { objects.add(perm.getId()); } @@ -55,7 +55,7 @@ public class BoostOpponentsEffect extends ContinuousEffectImpl opponents = game.getOpponents(source.getControllerId()); - for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter)) { + for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, game)) { if (!this.affectedObjectsSet || objects.contains(perm.getId())) { if (opponents.contains(perm.getControllerId())) { perm.addPower(power); diff --git a/Mage/src/mage/abilities/effects/common/continious/GainAbilityAllEffect.java b/Mage/src/mage/abilities/effects/common/continious/GainAbilityAllEffect.java index 1f68e21bdfb..515fd59c77b 100644 --- a/Mage/src/mage/abilities/effects/common/continious/GainAbilityAllEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/GainAbilityAllEffect.java @@ -75,7 +75,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl { } filter.setTargetController(TargetController.YOU); - int amount = Math.min(count, game.getBattlefield().countAll(filter, player.getId())); + int amount = Math.min(count, game.getBattlefield().countAll(filter, player.getId(), game)); Target target = new TargetControlledPermanent(amount, amount, filter, false); //A spell or ability could have removed the only legal target this player diff --git a/Mage/src/mage/abilities/keyword/LandwalkAbility.java b/Mage/src/mage/abilities/keyword/LandwalkAbility.java index d16b8885663..f2bc3a7b842 100644 --- a/Mage/src/mage/abilities/keyword/LandwalkAbility.java +++ b/Mage/src/mage/abilities/keyword/LandwalkAbility.java @@ -74,7 +74,7 @@ class LandwalkEffect extends RestrictionEffect { @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { - return !game.getBattlefield().contains(filter, blocker.getControllerId(), 1); + return !game.getBattlefield().contains(filter, blocker.getControllerId(), 1, game); } @Override diff --git a/Mage/src/mage/abilities/keyword/ProtectionAbility.java b/Mage/src/mage/abilities/keyword/ProtectionAbility.java index 014f7d78630..b4b75c76e8b 100644 --- a/Mage/src/mage/abilities/keyword/ProtectionAbility.java +++ b/Mage/src/mage/abilities/keyword/ProtectionAbility.java @@ -32,11 +32,8 @@ import mage.Constants.Zone; import mage.MageObject; import mage.abilities.StaticAbility; import mage.cards.Card; -import mage.filter.Filter; -import mage.filter.FilterCard; -import mage.filter.FilterObject; -import mage.filter.FilterPermanent; -import mage.filter.FilterSpell; +import mage.filter.*; +import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.stack.Spell; @@ -68,24 +65,24 @@ public class ProtectionAbility extends StaticAbility { return "Protection from " + filter.getMessage(); } - public boolean canTarget(MageObject source) { + public boolean canTarget(MageObject source, Game game) { if (filter instanceof FilterPermanent) { if (source instanceof Permanent) - return !filter.match(source); + return !filter.match(source, game); return true; } if (filter instanceof FilterSpell) { if (source instanceof Spell) - return !filter.match(source); + return !filter.match(source, game); return true; } if (filter instanceof FilterCard) { if (source instanceof Card) - return !filter.match(source); + return !filter.match(source, game); return true; } if (filter instanceof FilterObject) { - return !filter.match(source); + return !filter.match(source, game); } return true; } diff --git a/Mage/src/mage/cards/CardsImpl.java b/Mage/src/mage/cards/CardsImpl.java index 60e848e32c7..61c7b943162 100644 --- a/Mage/src/mage/cards/CardsImpl.java +++ b/Mage/src/mage/cards/CardsImpl.java @@ -112,7 +112,7 @@ public class CardsImpl extends LinkedHashSet implements Cards, Serializabl public int count(FilterCard filter, Game game) { int result = 0; for (UUID card: this) { - if (filter.match(game.getCard(card))) + if (filter.match(game.getCard(card), game)) result++; } return result; @@ -132,7 +132,7 @@ public class CardsImpl extends LinkedHashSet implements Cards, Serializabl public Set getCards(FilterCard filter, Game game) { Set cards = new LinkedHashSet(); for (UUID card: this) { - boolean match = filter.match(game.getCard(card)); + boolean match = filter.match(game.getCard(card), game); if (match) cards.add(game.getCard(card)); } diff --git a/Mage/src/mage/filter/Filter.java b/Mage/src/mage/filter/Filter.java index 9e7360e22ad..eecfda94eb0 100644 --- a/Mage/src/mage/filter/Filter.java +++ b/Mage/src/mage/filter/Filter.java @@ -28,6 +28,8 @@ package mage.filter; +import mage.game.Game; + import java.io.Serializable; /** @@ -44,7 +46,7 @@ public interface Filter extends Serializable { Any, All } - public boolean match(E o); + public boolean match(E o, Game game); public String getMessage(); public void setMessage(String message); public void setNotFilter(boolean notFilter); diff --git a/Mage/src/mage/filter/FilterAbility.java b/Mage/src/mage/filter/FilterAbility.java index 9a3cfaaf1b0..72d81232c06 100644 --- a/Mage/src/mage/filter/FilterAbility.java +++ b/Mage/src/mage/filter/FilterAbility.java @@ -28,12 +28,14 @@ package mage.filter; -import java.util.ArrayList; -import java.util.List; import mage.Constants.AbilityType; import mage.Constants.Outcome; import mage.Constants.Zone; import mage.abilities.Ability; +import mage.game.Game; + +import java.util.ArrayList; +import java.util.List; /** * @@ -71,7 +73,7 @@ public class FilterAbility extends FilterImpl> extends FilterObject 0 && ownerId.contains(card.getOwnerId()) == notOwner) @@ -123,7 +123,7 @@ public class FilterCard> extends FilterObject> extends FilterObject filter(Set cards) { + public Set filter(Set cards, Game game) { Set filtered = new HashSet(); for (Card card: cards) { - if (match(card)) { + if (match(card, game)) { filtered.add(card); } } diff --git a/Mage/src/mage/filter/FilterObject.java b/Mage/src/mage/filter/FilterObject.java index 14c66db7eda..afdd575b207 100644 --- a/Mage/src/mage/filter/FilterObject.java +++ b/Mage/src/mage/filter/FilterObject.java @@ -28,8 +28,6 @@ package mage.filter; -import java.util.ArrayList; -import java.util.List; import mage.Constants.CardType; import mage.MageObject; import mage.ObjectColor; @@ -37,6 +35,10 @@ import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; import mage.abilities.Ability; import mage.abilities.keyword.ChangelingAbility; +import mage.game.Game; + +import java.util.ArrayList; +import java.util.List; /** * @@ -120,7 +122,7 @@ public class FilterObject> ex } @Override - public boolean match(E object) { + public boolean match(E object, Game game) { if (name.size() > 0) { if (name.contains(object.getName()) == notName) diff --git a/Mage/src/mage/filter/FilterPermanent.java b/Mage/src/mage/filter/FilterPermanent.java index ed33c34546a..d135caee44a 100644 --- a/Mage/src/mage/filter/FilterPermanent.java +++ b/Mage/src/mage/filter/FilterPermanent.java @@ -28,13 +28,14 @@ package mage.filter; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.Constants.TargetController; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -82,8 +83,8 @@ public class FilterPermanent> extends FilterObject< } @Override - public boolean match(Permanent permanent) { - if (!super.match(permanent)) + public boolean match(Permanent permanent, Game game) { + if (!super.match(permanent, game)) return notFilter; if (ownerId.size() > 0 && ownerId.contains(permanent.getOwnerId()) == notOwner) @@ -108,7 +109,7 @@ public class FilterPermanent> extends FilterObject< } public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { - if (!this.match(permanent)) + if (!this.match(permanent, game)) return notFilter; if (controller != TargetController.ANY && playerId != null) { diff --git a/Mage/src/mage/filter/FilterPlayer.java b/Mage/src/mage/filter/FilterPlayer.java index eed926c93a6..d9fd64c6c07 100644 --- a/Mage/src/mage/filter/FilterPlayer.java +++ b/Mage/src/mage/filter/FilterPlayer.java @@ -28,13 +28,13 @@ package mage.filter; +import mage.Constants.TargetController; +import mage.game.Game; +import mage.players.Player; + import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mage.Constants.TargetController; -import mage.abilities.Ability; -import mage.game.Game; -import mage.players.Player; /** * @@ -58,7 +58,7 @@ public class FilterPlayer extends FilterImpl implements Fi } @Override - public boolean match(Player player) { + public boolean match(Player player, Game game) { if (playerId.size() > 0 && playerId.contains(player.getId()) == notPlayer) return notFilter; @@ -67,7 +67,7 @@ public class FilterPlayer extends FilterImpl implements Fi } public boolean match(Player player, UUID sourceId, UUID playerId, Game game) { - if (!this.match(player)) + if (!this.match(player, game)) return notFilter; if (playerTarget != TargetController.ANY && playerId != null) { diff --git a/Mage/src/mage/filter/FilterSpell.java b/Mage/src/mage/filter/FilterSpell.java index f884b4255c2..7733130865b 100644 --- a/Mage/src/mage/filter/FilterSpell.java +++ b/Mage/src/mage/filter/FilterSpell.java @@ -28,17 +28,18 @@ package mage.filter; -import java.util.UUID; import mage.Constants.Zone; import mage.game.Game; import mage.game.stack.Spell; import mage.game.stack.StackObject; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com */ -public class FilterSpell extends FilterStackObject { +public class FilterSpell> extends FilterStackObject> { protected Zone fromZone = Zone.ALL; protected boolean notFromZone = false; @@ -53,27 +54,27 @@ public class FilterSpell extends FilterStackObject { public FilterSpell(final FilterSpell filter) { super(filter); - for (UUID cId: filter.controllerId) { - this.controllerId.add(cId); + for (Object cId: filter.getControllerId()) { + this.controllerId.add((UUID)cId); } this.notController = filter.notController; this.controller = filter.controller; } @Override - public boolean match(StackObject spell) { + public boolean match(StackObject spell, Game game) { if (!(spell instanceof Spell)) return notFilter; if (((Spell)spell).getFromZone().match(fromZone) == notFromZone) return notFilter; - return super.match(spell); + return super.match(spell, game); } @Override public boolean match(StackObject spell, UUID playerId, Game game) { - if (!this.match(spell)) + if (!this.match(spell, game)) return notFilter; return super.match(spell, playerId, game); diff --git a/Mage/src/mage/filter/FilterStackObject.java b/Mage/src/mage/filter/FilterStackObject.java index 5e456e87430..26c83e05ca9 100644 --- a/Mage/src/mage/filter/FilterStackObject.java +++ b/Mage/src/mage/filter/FilterStackObject.java @@ -28,13 +28,14 @@ package mage.filter; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.Constants.TargetController; import mage.game.Game; import mage.game.stack.StackObject; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -61,9 +62,9 @@ public class FilterStackObject> extends FilterObj } @Override - public boolean match(StackObject spell) { + public boolean match(StackObject spell, Game game) { - if (!super.match(spell)) + if (!super.match(spell, game)) return notFilter; if (controllerId.size() > 0 && controllerId.contains(spell.getControllerId()) == notController) @@ -73,7 +74,7 @@ public class FilterStackObject> extends FilterObj } public boolean match(StackObject spell, UUID playerId, Game game) { - if (!this.match(spell)) + if (!this.match(spell, game)) return notFilter; if (controller != TargetController.ANY && playerId != null) { diff --git a/Mage/src/mage/filter/common/FilterArtifactPermanent.java b/Mage/src/mage/filter/common/FilterArtifactPermanent.java index a33289e3942..73ae91d9ea9 100644 --- a/Mage/src/mage/filter/common/FilterArtifactPermanent.java +++ b/Mage/src/mage/filter/common/FilterArtifactPermanent.java @@ -30,6 +30,7 @@ package mage.filter.common; import mage.Constants.CardType; import mage.filter.FilterPermanent; +import mage.game.Game; import mage.game.permanent.Permanent; /** @@ -63,8 +64,8 @@ public class FilterArtifactPermanent> exten } @Override - public boolean match(Permanent permanent) { - if (!super.match(permanent)) + public boolean match(Permanent permanent, Game game) { + if (!super.match(permanent, game)) return notFilter; if (useAttacking && permanent.isAttacking() != attacking) diff --git a/Mage/src/mage/filter/common/FilterCreatureForAttack.java b/Mage/src/mage/filter/common/FilterCreatureForAttack.java index 7431bbbe229..78f0e6c513b 100644 --- a/Mage/src/mage/filter/common/FilterCreatureForAttack.java +++ b/Mage/src/mage/filter/common/FilterCreatureForAttack.java @@ -29,6 +29,7 @@ package mage.filter.common; import mage.abilities.keyword.DefenderAbility; +import mage.game.Game; import mage.game.permanent.Permanent; /** @@ -58,8 +59,8 @@ public class FilterCreatureForAttack extends FilterCreaturePermanent> exten } @Override - public boolean match(Permanent permanent) { - if (!super.match(permanent)) + public boolean match(Permanent permanent, Game game) { + if (!super.match(permanent, game)) return notFilter; if (useAttacking) { @@ -118,7 +119,7 @@ public class FilterCreaturePermanent> exten * during the current turn. Works also if the creature * was meanwhile regenerated during the turn. * - * @param useDamage + * @param useDamageDealt */ public void setUseDamageDealt ( boolean useDamageDealt ) { this.useDamageDealt = useDamageDealt; diff --git a/Mage/src/mage/filter/common/FilterNonTokenPermanent.java b/Mage/src/mage/filter/common/FilterNonTokenPermanent.java index 2ffe30ee9bc..323c679609f 100644 --- a/Mage/src/mage/filter/common/FilterNonTokenPermanent.java +++ b/Mage/src/mage/filter/common/FilterNonTokenPermanent.java @@ -29,6 +29,7 @@ package mage.filter.common; import mage.filter.FilterPermanent; +import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.permanent.PermanentToken; @@ -51,8 +52,8 @@ public class FilterNonTokenPermanent extends FilterPermanent> extends FilterCreaturePermane } @Override - public boolean match(Permanent permanent) { + public boolean match(Permanent permanent, Game game) { if (!(permanent instanceof PermanentToken)) return notFilter; - if (!super.match(permanent)) + if (!super.match(permanent, game)) return notFilter; return !notFilter; diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index dd3869c9051..0f362f22912 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -888,7 +888,7 @@ public abstract class GameImpl> implements Game, Serializa } planeswalkers.add(perm); } - if (filterAura.match(perm)) { + if (filterAura.match(perm, this)) { //20091005 - 704.5n, 702.14c if (perm.getAttachedTo() == null) { if (perm.moveToZone(Zone.GRAVEYARD, null, this, false)) @@ -904,7 +904,7 @@ public abstract class GameImpl> implements Game, Serializa } else { Filter auraFilter = perm.getSpellAbility().getTargets().get(0).getFilter(); - if (!auraFilter.match(attachedTo) || attachedTo.hasProtectionFrom(perm)) { + if (!auraFilter.match(attachedTo, this) || attachedTo.hasProtectionFrom(perm, this)) { if (perm.moveToZone(Zone.GRAVEYARD, null, this, false)) somethingHappened = true; } @@ -918,7 +918,7 @@ public abstract class GameImpl> implements Game, Serializa } else { Filter auraFilter = perm.getSpellAbility().getTargets().get(0).getFilter(); - if (!auraFilter.match(attachedTo) || attachedTo.hasProtectionFrom(perm)) { + if (!auraFilter.match(attachedTo, this) || attachedTo.hasProtectionFrom(perm, this)) { if (perm.moveToZone(Zone.GRAVEYARD, null, this, false)) somethingHappened = true; } @@ -926,28 +926,28 @@ public abstract class GameImpl> implements Game, Serializa } } } - if (filterLegendary.match(perm)) + if (filterLegendary.match(perm, this)) legendary.add(perm); - if (filterEquipment.match(perm)) { + if (filterEquipment.match(perm, this)) { //20091005 - 704.5p, 702.14d if (perm.getAttachedTo() != null) { Permanent creature = getPermanent(perm.getAttachedTo()); if (creature == null) { perm.attachTo(null, this); } - else if (!creature.getCardType().contains(CardType.CREATURE) || creature.hasProtectionFrom(perm)) { + else if (!creature.getCardType().contains(CardType.CREATURE) || creature.hasProtectionFrom(perm, this)) { if (creature.removeAttachment(perm.getId(), this)) somethingHappened = true; } } } - if (filterFortification.match(perm)) { + if (filterFortification.match(perm, this)) { if (perm.getAttachedTo() != null) { Permanent land = getPermanent(perm.getAttachedTo()); if (land == null) { perm.attachTo(null, this); } - else if (!land.getCardType().contains(CardType.LAND) || land.hasProtectionFrom(perm)) { + else if (!land.getCardType().contains(CardType.LAND) || land.hasProtectionFrom(perm, this)) { if (land.removeAttachment(perm.getId(), this)) somethingHappened = true; } diff --git a/Mage/src/mage/game/combat/Combat.java b/Mage/src/mage/game/combat/Combat.java index 9b87de9276c..ff3ca2c3a0b 100644 --- a/Mage/src/mage/game/combat/Combat.java +++ b/Mage/src/mage/game/combat/Combat.java @@ -246,7 +246,7 @@ public class Combat implements Serializable, Copyable { private void addDefender(UUID defenderId, Game game) { defenders.add(defenderId); - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filterPlaneswalker, defenderId)) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filterPlaneswalker, defenderId, game)) { defenders.add(permanent.getId()); } } diff --git a/Mage/src/mage/game/permanent/Battlefield.java b/Mage/src/mage/game/permanent/Battlefield.java index d4cfe4c7816..6f61ae55152 100644 --- a/Mage/src/mage/game/permanent/Battlefield.java +++ b/Mage/src/mage/game/permanent/Battlefield.java @@ -75,10 +75,10 @@ public class Battlefield implements Serializable { * @param filter * @return count */ - public int countAll(FilterPermanent filter) { + public int countAll(FilterPermanent filter, Game game) { int count = 0; for (Permanent permanent: field.values()) { - if (filter.match(permanent)) { + if (filter.match(permanent, game)) { count++; } } @@ -93,10 +93,10 @@ public class Battlefield implements Serializable { * @param controllerId * @return count */ - public int countAll(FilterPermanent filter, UUID controllerId) { + public int countAll(FilterPermanent filter, UUID controllerId, Game game) { int count = 0; for (Permanent permanent: field.values()) { - if (permanent.getControllerId().equals(controllerId) && filter.match(permanent)) { + if (permanent.getControllerId().equals(controllerId) && filter.match(permanent, game)) { count++; } } @@ -160,10 +160,10 @@ public class Battlefield implements Serializable { * @param filter * @return boolean */ - public boolean contains(FilterPermanent filter, int num) { + public boolean contains(FilterPermanent filter, int num, Game game) { int count = 0; for (Permanent permanent: field.values()) { - if (filter.match(permanent)) { + if (filter.match(permanent, game)) { count++; if (num == count) return true; @@ -181,10 +181,10 @@ public class Battlefield implements Serializable { * @param controllerId * @return boolean */ - public boolean contains(FilterPermanent filter, UUID controllerId, int num) { + public boolean contains(FilterPermanent filter, UUID controllerId, int num, Game game) { int count = 0; for (Permanent permanent: field.values()) { - if (permanent.getControllerId().equals(controllerId) && filter.match(permanent)) { + if (permanent.getControllerId().equals(controllerId) && filter.match(permanent, game)) { count++; if (num == count) return true; @@ -310,14 +310,15 @@ public class Battlefield implements Serializable { * Returns all {@link Permanent} on the battlefield that match the supplied filter. * This method ignores the range of influence. * - * @param filter - * @return a list of {@link Permanent} + * + * @param filter + * @return a list of {@link Permanent} * @see Permanent */ - public List getAllActivePermanents(FilterPermanent filter) { + public List getAllActivePermanents(FilterPermanent filter, Game game) { List active = new ArrayList(); for (Permanent perm: field.values()) { - if (perm.isPhasedIn() && filter.match(perm)) + if (perm.isPhasedIn() && filter.match(perm, game)) active.add(perm); } return active; @@ -332,10 +333,10 @@ public class Battlefield implements Serializable { * @return a list of {@link Permanent} * @see Permanent */ - public List getAllActivePermanents(FilterPermanent filter, UUID controllerId) { + public List getAllActivePermanents(FilterPermanent filter, UUID controllerId, Game game) { List active = new ArrayList(); for (Permanent perm: field.values()) { - if (perm.isPhasedIn() && perm.getControllerId().equals(controllerId) && filter.match(perm)) + if (perm.isPhasedIn() && perm.getControllerId().equals(controllerId) && filter.match(perm, game)) active.add(perm); } return active; diff --git a/Mage/src/mage/game/permanent/Permanent.java b/Mage/src/mage/game/permanent/Permanent.java index 517a6d6a1f8..030c9c78c7c 100644 --- a/Mage/src/mage/game/permanent/Permanent.java +++ b/Mage/src/mage/game/permanent/Permanent.java @@ -75,7 +75,7 @@ public interface Permanent extends Card { public UUID getControllerId(); public boolean changeControllerId(UUID controllerId, Game game); public boolean canBeTargetedBy(MageObject source, UUID controllerId, Game game); - public boolean hasProtectionFrom(MageObject source); + public boolean hasProtectionFrom(MageObject source, Game game); public boolean hasSummoningSickness(); public int getDamage(); public int damage(int damage, UUID sourceId, Game game, boolean preventable, boolean combat); diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index 0c9074a9653..ffe39f79691 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -549,7 +549,7 @@ public abstract class PermanentImpl> extends CardImpl */ private int damage(int damageAmount, UUID sourceId, Game game, boolean preventable, boolean combat, boolean markDamage) { int damageDone = 0; - if (damageAmount > 0 && canDamage(game.getObject(sourceId))) { + if (damageAmount > 0 && canDamage(game.getObject(sourceId), game)) { if (cardType.contains(CardType.PLANESWALKER)) { damageDone = damagePlaneswalker(damageAmount, sourceId, game, preventable, combat, markDamage); } else { @@ -661,7 +661,7 @@ public abstract class PermanentImpl> extends CardImpl if (abilities.containsKey(HexproofAbility.getInstance().getId())) if (game.getOpponents(controllerId).contains(sourceControllerId)) return false; - if (hasProtectionFrom(source)) + if (hasProtectionFrom(source, game)) return false; } @@ -669,16 +669,16 @@ public abstract class PermanentImpl> extends CardImpl } @Override - public boolean hasProtectionFrom(MageObject source) { + public boolean hasProtectionFrom(MageObject source, Game game) { for (ProtectionAbility ability : abilities.getProtectionAbilities()) { - if (!ability.canTarget(source)) + if (!ability.canTarget(source, game)) return true; } return false; } - protected boolean canDamage(MageObject source) { - return (!hasProtectionFrom(source)); + protected boolean canDamage(MageObject source, Game game) { + return (!hasProtectionFrom(source, game)); } @Override @@ -772,7 +772,7 @@ public abstract class PermanentImpl> extends CardImpl if (!effect.canBeBlocked(attacker, this, game.getContinuousEffects().getAbility(effect.getId()), game)) return false; } - if (attacker != null && attacker.hasProtectionFrom(this)) + if (attacker != null && attacker.hasProtectionFrom(this, game)) return false; return true; } diff --git a/Mage/src/mage/players/Library.java b/Mage/src/mage/players/Library.java index a590ed72620..d1cc412f710 100644 --- a/Mage/src/mage/players/Library.java +++ b/Mage/src/mage/players/Library.java @@ -28,24 +28,14 @@ package mage.players; -import java.io.Serializable; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Deque; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.UUID; import mage.Constants.Zone; import mage.cards.Card; import mage.filter.FilterCard; import mage.game.Game; +import java.io.Serializable; +import java.util.*; + /** * * @author BetaSteward_at_googlemail.com @@ -190,7 +180,7 @@ public class Library implements Serializable { public int count(FilterCard filter, Game game) { int result = 0; for (UUID card: library) { - if (filter.match(game.getCard(card))) + if (filter.match(game.getCard(card), game)) result++; } return result; diff --git a/Mage/src/mage/players/ManaPool.java b/Mage/src/mage/players/ManaPool.java index c33b2f28e7c..f59cec9092f 100644 --- a/Mage/src/mage/players/ManaPool.java +++ b/Mage/src/mage/players/ManaPool.java @@ -84,7 +84,7 @@ public class ManaPool implements Serializable { return true; } for (ManaPoolItem mana : manaItems) { - if (filter == null || filter.match(game.getObject(mana.getSourceId()))) { + if (filter == null || filter.match(game.getObject(mana.getSourceId()), game)) { if (mana.get(manaType) > 0) { game.fireEvent(new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getSourceId(), ability.getControllerId())); mana.remove(manaType); @@ -105,7 +105,7 @@ public class ManaPool implements Serializable { } for (ManaPoolItem mana : manaItems) { if (mana.isConditional() && mana.getConditionalMana().get(manaType) > 0 && mana.getConditionalMana().apply(ability, game, mana.getSourceId())) { - if (filter == null || filter.match(game.getObject(mana.getSourceId()))) + if (filter == null || filter.match(game.getObject(mana.getSourceId()), game)) return mana.getConditionalMana().get(manaType); } } diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index 431ec5ed9be..d5855f8213a 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -188,8 +188,8 @@ public interface Player extends MageItem, Copyable { public boolean playLand(Card card, Game game); public boolean activateAbility(ActivatedAbility ability, Game game); public boolean triggerAbility(TriggeredAbility ability, Game game); - public boolean canBeTargetedBy(MageObject source); - public boolean hasProtectionFrom(MageObject source); + public boolean canBeTargetedBy(MageObject source, Game game); + public boolean hasProtectionFrom(MageObject source, Game game); public boolean flipCoin(Game game); public void discard(int amount, Ability source, Game game); public void discardToMax(Game game); diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 4dc0d1b2cf3..23146e901f8 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -313,14 +313,14 @@ public abstract class PlayerImpl> implements Player, Ser } @Override - public boolean canBeTargetedBy(MageObject source) { + public boolean canBeTargetedBy(MageObject source, Game game) { if (this.hasLost() || this.hasLeft()) return false; if (source != null) { if (abilities.containsKey(ShroudAbility.getInstance().getId())) return false; - if (hasProtectionFrom(source)) + if (hasProtectionFrom(source, game)) return false; } @@ -328,9 +328,9 @@ public abstract class PlayerImpl> implements Player, Ser } @Override - public boolean hasProtectionFrom(MageObject source) { + public boolean hasProtectionFrom(MageObject source, Game game) { for (ProtectionAbility ability: abilities.getProtectionAbilities()) { - if (!ability.canTarget(source)) + if (!ability.canTarget(source, game)) return true; } return false; @@ -857,7 +857,7 @@ public abstract class PlayerImpl> implements Player, Ser @Override public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable) { - if (damage > 0 && canDamage(game.getObject(sourceId))) { + if (damage > 0 && canDamage(game.getObject(sourceId), game)) { GameEvent event = new DamagePlayerEvent(playerId, sourceId, playerId, damage, preventable, combatDamage); if (!game.replaceEvent(event)) { int actualDamage = event.getAmount(); @@ -896,9 +896,9 @@ public abstract class PlayerImpl> implements Player, Ser } } - protected boolean canDamage(MageObject source) { + protected boolean canDamage(MageObject source, Game game) { for (ProtectionAbility ability: abilities.getProtectionAbilities()) { - if (!ability.canTarget(source)) + if (!ability.canTarget(source, game)) return false; } return true; @@ -1129,7 +1129,7 @@ public abstract class PlayerImpl> implements Player, Ser @Override public List getAvailableAttackers(Game game) { FilterCreatureForCombat filter = new FilterCreatureForCombat(); - List attackers = game.getBattlefield().getAllActivePermanents(filter, playerId); + List attackers = game.getBattlefield().getAllActivePermanents(filter, playerId, game); for (Iterator i = attackers.iterator(); i.hasNext();) { Permanent entry = i.next(); if (!entry.canAttack(game)) @@ -1141,7 +1141,7 @@ public abstract class PlayerImpl> implements Player, Ser @Override public List getAvailableBlockers(Game game) { FilterCreatureForCombat blockFilter = new FilterCreatureForCombat(); - List blockers = game.getBattlefield().getAllActivePermanents(blockFilter, playerId); + List blockers = game.getBattlefield().getAllActivePermanents(blockFilter, playerId, game); return blockers; } diff --git a/Mage/src/mage/target/TargetCard.java b/Mage/src/mage/target/TargetCard.java index 6541b17bbc0..902511e7608 100644 --- a/Mage/src/mage/target/TargetCard.java +++ b/Mage/src/mage/target/TargetCard.java @@ -28,9 +28,6 @@ package mage.target; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.Constants.Zone; import mage.cards.Card; import mage.cards.Cards; @@ -38,6 +35,10 @@ import mage.filter.FilterCard; import mage.game.Game; import mage.players.Player; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -159,7 +160,7 @@ public class TargetCard> extends TargetObject> extends TargetObject> extends TargetImpl public boolean canTarget(UUID id, Game game) { MageObject object = game.getObject(id); if (object != null && game.getState().getZone(id).match(zone)) - return getFilter().match(object); + return getFilter().match(object, game); return false; } diff --git a/Mage/src/mage/target/TargetPlayer.java b/Mage/src/mage/target/TargetPlayer.java index be10550d7ab..64731c267b6 100644 --- a/Mage/src/mage/target/TargetPlayer.java +++ b/Mage/src/mage/target/TargetPlayer.java @@ -91,8 +91,8 @@ public class TargetPlayer> extends TargetImpl= this.minNumberOfTargets) return true; @@ -115,7 +115,7 @@ public class TargetPlayer> extends TargetImpl= this.minNumberOfTargets) return true; @@ -130,8 +130,8 @@ public class TargetPlayer> extends TargetImpl> extends TargetImpl possibleTargets = new HashSet(); for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && !player.hasLeft() && filter.match(player)) { + if (player != null && !player.hasLeft() && filter.match(player, game)) { possibleTargets.add(playerId); } } @@ -164,7 +164,7 @@ public class TargetPlayer> extends TargetImpl> extends TargetImpl { public boolean canChoose(UUID sourceControllerId, Game game) { int count = 0; for (StackObject stackObject: game.getStack()) { - if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject)) { + if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject, game)) { count++; if (count >= this.minNumberOfTargets) return true; } } for (Permanent permanent: game.getBattlefield().getActivePermanents(sourceControllerId, game)) { - if (filter.match(permanent)) { + if (filter.match(permanent, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -131,12 +132,12 @@ public class TargetSource extends TargetObject { public Set possibleTargets(UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet(); for (StackObject stackObject: game.getStack()) { - if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject)) { + if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject, game)) { possibleTargets.add(stackObject.getId()); } } for (Permanent permanent: game.getBattlefield().getActivePermanents(sourceControllerId, game)) { - if (filter.match(permanent)) { + if (filter.match(permanent, game)) { possibleTargets.add(permanent.getId()); } } diff --git a/Mage/src/mage/target/TargetSpell.java b/Mage/src/mage/target/TargetSpell.java index 6111dc0d37e..46c9625b859 100644 --- a/Mage/src/mage/target/TargetSpell.java +++ b/Mage/src/mage/target/TargetSpell.java @@ -85,7 +85,7 @@ public class TargetSpell extends TargetObject { } Spell spell = game.getStack().getSpell(id); if (spell != null) { - return filter.match(spell); + return filter.match(spell, game); } return false; } @@ -99,7 +99,7 @@ public class TargetSpell extends TargetObject { public boolean canChoose(UUID sourceControllerId, Game game) { int count = 0; for (StackObject stackObject: game.getStack()) { - if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match((Spell)stackObject)) { + if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match((Spell)stackObject, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -117,7 +117,7 @@ public class TargetSpell extends TargetObject { public Set possibleTargets(UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet(); for (StackObject stackObject: game.getStack()) { - if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match((Spell)stackObject)) { + if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match((Spell)stackObject, game)) { possibleTargets.add(stackObject.getId()); } } diff --git a/Mage/src/mage/target/TargetStackObject.java b/Mage/src/mage/target/TargetStackObject.java index c2e416f7439..52ffd2a723d 100644 --- a/Mage/src/mage/target/TargetStackObject.java +++ b/Mage/src/mage/target/TargetStackObject.java @@ -28,15 +28,16 @@ package mage.target; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.Constants.Zone; import mage.abilities.Ability; import mage.filter.FilterStackObject; import mage.game.Game; import mage.game.stack.StackObject; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -79,7 +80,7 @@ public class TargetStackObject extends TargetObject { public boolean canTarget(UUID id, Ability source, Game game) { StackObject stackObject = game.getStack().getStackObject(id); if (stackObject != null) { - return filter.match(stackObject); + return filter.match(stackObject, game); } return false; } @@ -93,7 +94,7 @@ public class TargetStackObject extends TargetObject { public boolean canChoose(UUID sourceControllerId, Game game) { int count = 0; for (StackObject stackObject: game.getStack()) { - if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject)) { + if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -111,7 +112,7 @@ public class TargetStackObject extends TargetObject { public Set possibleTargets(UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet(); for (StackObject stackObject: game.getStack()) { - if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject)) { + if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject, game)) { possibleTargets.add(stackObject.getId()); } } diff --git a/Mage/src/mage/target/common/TargetCardInExile.java b/Mage/src/mage/target/common/TargetCardInExile.java index 38856ee942f..da3f5131d6e 100644 --- a/Mage/src/mage/target/common/TargetCardInExile.java +++ b/Mage/src/mage/target/common/TargetCardInExile.java @@ -27,7 +27,6 @@ */ package mage.target.common; -import java.util.UUID; import mage.Constants.Zone; import mage.abilities.Ability; import mage.cards.Card; @@ -36,6 +35,8 @@ import mage.game.ExileZone; import mage.game.Game; import mage.target.TargetCard; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -70,7 +71,7 @@ public class TargetCardInExile extends TargetCard { exile = game.getExile().getPermanentExile(); } if (exile != null && exile.contains(id)) { - return filter.match(card); + return filter.match(card, game); } } return false; diff --git a/Mage/src/mage/target/common/TargetCardInGraveyard.java b/Mage/src/mage/target/common/TargetCardInGraveyard.java index 866d11d691f..bb6aa02e4a3 100644 --- a/Mage/src/mage/target/common/TargetCardInGraveyard.java +++ b/Mage/src/mage/target/common/TargetCardInGraveyard.java @@ -28,7 +28,6 @@ package mage.target.common; -import java.util.UUID; import mage.Constants.Zone; import mage.abilities.Ability; import mage.cards.Card; @@ -36,6 +35,8 @@ import mage.filter.FilterCard; import mage.game.Game; import mage.target.TargetCard; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -67,7 +68,7 @@ public class TargetCardInGraveyard extends TargetCard { public boolean canTarget(UUID id, Ability source, Game game) { Card card = game.getCard(id); if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) - return filter.match(card); + return filter.match(card, game); return false; } diff --git a/Mage/src/mage/target/common/TargetCardInHand.java b/Mage/src/mage/target/common/TargetCardInHand.java index c4b1d51e540..c06baa76576 100644 --- a/Mage/src/mage/target/common/TargetCardInHand.java +++ b/Mage/src/mage/target/common/TargetCardInHand.java @@ -67,7 +67,7 @@ public class TargetCardInHand extends TargetCard { public boolean canTarget(UUID id, Ability source, Game game) { Card card = game.getPlayer(source.getControllerId()).getHand().get(id, game); if (card != null) - return filter.match(card); + return filter.match(card, game); return false; } diff --git a/Mage/src/mage/target/common/TargetCardInLibrary.java b/Mage/src/mage/target/common/TargetCardInLibrary.java index c7e9922d206..ab72fbcb640 100644 --- a/Mage/src/mage/target/common/TargetCardInLibrary.java +++ b/Mage/src/mage/target/common/TargetCardInLibrary.java @@ -28,7 +28,6 @@ package mage.target.common; -import java.util.UUID; import mage.Constants.Outcome; import mage.Constants.Zone; import mage.abilities.Ability; @@ -39,6 +38,8 @@ import mage.game.Game; import mage.players.Player; import mage.target.TargetCard; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -92,7 +93,7 @@ public class TargetCardInLibrary extends TargetCard { public boolean canTarget(UUID id, Ability source, Game game) { Card card = game.getPlayer(source.getControllerId()).getLibrary().getCard(id, game); if (card != null) - return filter.match(card); + return filter.match(card, game); return false; } diff --git a/Mage/src/mage/target/common/TargetCardInOpponentsGraveyard.java b/Mage/src/mage/target/common/TargetCardInOpponentsGraveyard.java index 840f844e20e..ce0767a4736 100644 --- a/Mage/src/mage/target/common/TargetCardInOpponentsGraveyard.java +++ b/Mage/src/mage/target/common/TargetCardInOpponentsGraveyard.java @@ -30,7 +30,7 @@ public class TargetCardInOpponentsGraveyard extends TargetCard { public boolean canTarget(UUID id, Game game) { Permanent permanent = game.getPermanent(id); if (permanent != null) { - return filter.match(permanent); + return filter.match(permanent, game); } Player player = game.getPlayer(id); if (player != null) - return filter.match(player); + return filter.match(player, game); return false; } @@ -112,9 +112,9 @@ public class TargetCreatureOrPlayer extends TargetImpl { Player player = game.getPlayer(id); if (player != null) if (source != null) - return player.canBeTargetedBy(targetSource) && filter.match(player); + return player.canBeTargetedBy(targetSource, game) && filter.match(player, game); else - return filter.match(player); + return filter.match(player, game); return false; } @@ -133,7 +133,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { MageObject targetSource = game.getObject(sourceId); for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && player.canBeTargetedBy(targetSource) && filter.match(player)) { + if (player != null && player.canBeTargetedBy(targetSource, game) && filter.match(player, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -162,7 +162,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { int count = 0; for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && filter.match(player)) { + if (player != null && filter.match(player, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -184,7 +184,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { MageObject targetSource = game.getObject(sourceId); for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && player.canBeTargetedBy(targetSource) && filter.match(player)) { + if (player != null && player.canBeTargetedBy(targetSource, game) && filter.match(player, game)) { possibleTargets.add(playerId); } } @@ -201,7 +201,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { Set possibleTargets = new HashSet(); for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && filter.match(player)) { + if (player != null && filter.match(player, game)) { possibleTargets.add(playerId); } } diff --git a/Mage/src/mage/target/common/TargetCreatureOrPlayerAmount.java b/Mage/src/mage/target/common/TargetCreatureOrPlayerAmount.java index ed491e63023..3f4afe33cd0 100644 --- a/Mage/src/mage/target/common/TargetCreatureOrPlayerAmount.java +++ b/Mage/src/mage/target/common/TargetCreatureOrPlayerAmount.java @@ -28,9 +28,6 @@ package mage.target.common; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.Constants.Zone; import mage.MageObject; import mage.abilities.Ability; @@ -42,6 +39,10 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetAmount; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -71,11 +72,11 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount= this.minNumberOfTargets) return true; @@ -125,7 +126,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount= this.minNumberOfTargets) return true; @@ -147,7 +148,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount possibleTargets = new HashSet(); for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && filter.match(player)) { + if (player != null && filter.match(player, game)) { possibleTargets.add(playerId); } } diff --git a/Mage/src/mage/target/common/TargetCreaturePermanentAmount.java b/Mage/src/mage/target/common/TargetCreaturePermanentAmount.java index 9bb042d327c..5bad8b56876 100644 --- a/Mage/src/mage/target/common/TargetCreaturePermanentAmount.java +++ b/Mage/src/mage/target/common/TargetCreaturePermanentAmount.java @@ -27,9 +27,6 @@ */ package mage.target.common; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.Constants.Zone; import mage.MageObject; import mage.abilities.Ability; @@ -40,6 +37,10 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetAmount; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author North @@ -73,7 +74,7 @@ public class TargetCreaturePermanentAmount extends TargetAmount { MageObject targetSource = game.getObject(sourceId); for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && player.canBeTargetedBy(targetSource) && filter.match(player)) { + if (player != null && player.canBeTargetedBy(targetSource, game) && filter.match(player, game)) { count++; if (count >= this.minNumberOfTargets) return true; } } for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterPlaneswalkerPermanent(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent)) { + if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -106,14 +107,14 @@ public class TargetDefender extends TargetImpl { int count = 0; for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && filter.match(player)) { + if (player != null && filter.match(player, game)) { count++; if (count >= this.minNumberOfTargets) return true; } } for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterPlaneswalkerPermanent(), sourceControllerId, game)) { - if (filter.match(permanent)) { + if (filter.match(permanent, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -128,12 +129,12 @@ public class TargetDefender extends TargetImpl { MageObject targetSource = game.getObject(sourceId); for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && player.canBeTargetedBy(targetSource) && filter.match(player)) { + if (player != null && player.canBeTargetedBy(targetSource, game) && filter.match(player, game)) { possibleTargets.add(playerId); } } for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterPlaneswalkerPermanent(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent)) { + if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, game)) { possibleTargets.add(permanent.getId()); } } @@ -145,12 +146,12 @@ public class TargetDefender extends TargetImpl { Set possibleTargets = new HashSet(); for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && filter.match(player)) { + if (player != null && filter.match(player, game)) { possibleTargets.add(playerId); } } for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterPlaneswalkerPermanent(), sourceControllerId, game)) { - if (filter.match(permanent)) { + if (filter.match(permanent, game)) { possibleTargets.add(permanent.getId()); } } @@ -177,11 +178,11 @@ public class TargetDefender extends TargetImpl { public boolean canTarget(UUID id, Game game) { Player player = game.getPlayer(id); if (player != null) { - return filter.match(player); + return filter.match(player, game); } Permanent permanent = game.getPermanent(id); if (permanent != null) { - return filter.match(permanent); + return filter.match(permanent, game); } return false; } @@ -191,7 +192,7 @@ public class TargetDefender extends TargetImpl { Player player = game.getPlayer(id); MageObject targetSource = game.getObject(attackerId); if (player != null) { - return player.canBeTargetedBy(targetSource) && filter.match(player); + return player.canBeTargetedBy(targetSource, game) && filter.match(player, game); } Permanent permanent = game.getPermanent(id); if (permanent != null) { @@ -200,7 +201,7 @@ public class TargetDefender extends TargetImpl { if ( source != null ) { controllerId = source.getControllerId(); } - return permanent.canBeTargetedBy(targetSource, controllerId, game) && filter.match(permanent); + return permanent.canBeTargetedBy(targetSource, controllerId, game) && filter.match(permanent, game); } return false; } diff --git a/Mage/src/mage/target/common/TargetDiscard.java b/Mage/src/mage/target/common/TargetDiscard.java index f2e97414c5d..bf69290303b 100644 --- a/Mage/src/mage/target/common/TargetDiscard.java +++ b/Mage/src/mage/target/common/TargetDiscard.java @@ -28,7 +28,6 @@ package mage.target.common; -import java.util.UUID; import mage.Constants.Zone; import mage.abilities.Ability; import mage.cards.Card; @@ -36,6 +35,8 @@ import mage.filter.FilterCard; import mage.game.Game; import mage.target.TargetCard; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -73,7 +74,7 @@ public class TargetDiscard extends TargetCard { public boolean canTarget(UUID id, Ability source, Game game) { Card card = game.getPlayer(playerId).getHand().get(id, game); if (card != null) - return filter.match(card); + return filter.match(card, game); return false; } diff --git a/Mage/src/mage/target/common/TargetPermanentOrPlayer.java b/Mage/src/mage/target/common/TargetPermanentOrPlayer.java index 59e2de7b6d0..219799d35a9 100644 --- a/Mage/src/mage/target/common/TargetPermanentOrPlayer.java +++ b/Mage/src/mage/target/common/TargetPermanentOrPlayer.java @@ -93,11 +93,11 @@ public class TargetPermanentOrPlayer extends TargetImpl public boolean canTarget(UUID id, Game game) { Permanent permanent = game.getPermanent(id); if (permanent != null) { - return filter.match(permanent); + return filter.match(permanent, game); } Player player = game.getPlayer(id); if (player != null) - return filter.match(player); + return filter.match(player, game); return false; } @@ -109,14 +109,14 @@ public class TargetPermanentOrPlayer extends TargetImpl if (source != null) return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); else - return filter.match(permanent); + return filter.match(permanent, game); } Player player = game.getPlayer(id); if (player != null) if (source != null) - return player.canBeTargetedBy(targetSource) && filter.match(player); + return player.canBeTargetedBy(targetSource, game) && filter.match(player, game); else - return filter.match(player); + return filter.match(player, game); return false; } @@ -135,7 +135,7 @@ public class TargetPermanentOrPlayer extends TargetImpl MageObject targetSource = game.getObject(sourceId); for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && player.canBeTargetedBy(targetSource) && filter.match(player)) { + if (player != null && player.canBeTargetedBy(targetSource, game) && filter.match(player, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -164,14 +164,14 @@ public class TargetPermanentOrPlayer extends TargetImpl int count = 0; for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && filter.match(player)) { + if (player != null && filter.match(player, game)) { count++; if (count >= this.minNumberOfTargets) return true; } } for (Permanent permanent: game.getBattlefield().getActivePermanents(filterPermanent, sourceControllerId, game)) { - if (filter.match(permanent, null, sourceControllerId, game) && filter.match(permanent)) { + if (filter.match(permanent, null, sourceControllerId, game) && filter.match(permanent, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -186,7 +186,7 @@ public class TargetPermanentOrPlayer extends TargetImpl MageObject targetSource = game.getObject(sourceId); for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && player.canBeTargetedBy(targetSource) && filter.match(player)) { + if (player != null && player.canBeTargetedBy(targetSource, game) && filter.match(player, game)) { possibleTargets.add(playerId); } } @@ -203,7 +203,7 @@ public class TargetPermanentOrPlayer extends TargetImpl Set possibleTargets = new HashSet(); for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); - if (player != null && filter.match(player)) { + if (player != null && filter.match(player, game)) { possibleTargets.add(playerId); } } diff --git a/Mage/src/mage/target/common/TargetSpellOrPermanent.java b/Mage/src/mage/target/common/TargetSpellOrPermanent.java index 7d47856ac50..62aa48d2b9d 100644 --- a/Mage/src/mage/target/common/TargetSpellOrPermanent.java +++ b/Mage/src/mage/target/common/TargetSpellOrPermanent.java @@ -29,9 +29,6 @@ */ package mage.target.common; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.Constants.Zone; import mage.MageObject; import mage.abilities.Ability; @@ -45,6 +42,10 @@ import mage.game.stack.Spell; import mage.game.stack.StackObject; import mage.target.TargetImpl; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author LevelX @@ -99,11 +100,11 @@ public class TargetSpellOrPermanent extends TargetImpl { public boolean canTarget(UUID id, Game game) { Permanent permanent = game.getPermanent(id); if (permanent != null) { - return filter.match(permanent); + return filter.match(permanent, game); } Spell spell = game.getStack().getSpell(id); if (spell != null) - return filter.match(spell); + return filter.match(spell, game); return false; } @@ -115,11 +116,11 @@ public class TargetSpellOrPermanent extends TargetImpl { if (source != null) return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); else - return filter.match(permanent); + return filter.match(permanent, game); } Spell spell = game.getStack().getSpell(id); if (spell != null) - return filter.match(spell); + return filter.match(spell, game); return false; } @@ -167,14 +168,14 @@ public class TargetSpellOrPermanent extends TargetImpl { int count = 0; for (StackObject stackObject: game.getStack()) { Spell spell = game.getStack().getSpell(stackObject.getId()); - if (spell != null && filter.match(spell, null, sourceControllerId, game) && filter.match(spell)) { + if (spell != null && filter.match(spell, null, sourceControllerId, game) && filter.match(spell, game)) { count++; if (count >= this.minNumberOfTargets) return true; } } for (Permanent permanent: game.getBattlefield().getActivePermanents(filterPermanent, sourceControllerId, game)) { - if (filter.match(permanent, null, sourceControllerId, game) && filter.match(permanent)) { + if (filter.match(permanent, null, sourceControllerId, game) && filter.match(permanent, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -189,7 +190,7 @@ public class TargetSpellOrPermanent extends TargetImpl { MageObject targetSource = game.getObject(sourceId); for (StackObject stackObject: game.getStack()) { Spell spell = game.getStack().getSpell(stackObject.getId()); - if (spell != null && filter.match(spell, null, sourceControllerId, game) && filter.match(spell)) { + if (spell != null && filter.match(spell, null, sourceControllerId, game) && filter.match(spell, game)) { possibleTargets.add(spell.getId()); } } @@ -206,7 +207,7 @@ public class TargetSpellOrPermanent extends TargetImpl { Set possibleTargets = new HashSet(); for (StackObject stackObject: game.getStack()) { Spell spell = game.getStack().getSpell(stackObject.getId()); - if (spell != null && filter.match(spell, null, sourceControllerId, game) && filter.match(spell)) { + if (spell != null && filter.match(spell, null, sourceControllerId, game) && filter.match(spell, game)) { possibleTargets.add(spell.getId()); } } diff --git a/Mage/src/mage/watchers/common/CastSpellLastTurnWatcher.java b/Mage/src/mage/watchers/common/CastSpellLastTurnWatcher.java index ef65b5d84bc..94baa8e15be 100644 --- a/Mage/src/mage/watchers/common/CastSpellLastTurnWatcher.java +++ b/Mage/src/mage/watchers/common/CastSpellLastTurnWatcher.java @@ -31,12 +31,11 @@ package mage.watchers.common; import mage.Constants.WatcherScope; import mage.game.Game; import mage.game.events.GameEvent; +import mage.game.stack.Spell; import mage.watchers.WatcherImpl; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.UUID; /** * @@ -46,6 +45,7 @@ public class CastSpellLastTurnWatcher extends WatcherImpl amountOfSpellsCastOnPrevTurn = new HashMap(); private Map amountOfSpellsCastOnCurrentTurn = new HashMap(); + private List spellsCastThisTurnInOrder = new ArrayList(); public CastSpellLastTurnWatcher() { super("CastSpellLastTurnWatcher", WatcherScope.GAME); @@ -64,6 +64,7 @@ public class CastSpellLastTurnWatcher extends WatcherImpl getAmountOfSpellsCastOnPrevTurn() { return amountOfSpellsCastOnPrevTurn; } + public Map getAmountOfSpellsCastOnCurrentTurn() { + return amountOfSpellsCastOnCurrentTurn; + } + + public int getSpellOrder(Spell spell) { + int index = 0; + for (UUID uuid : spellsCastThisTurnInOrder) { + index++; + if (spell.getId().equals(uuid)) { + return index; + } + } + return 0; + } + @Override public CastSpellLastTurnWatcher copy() { return new CastSpellLastTurnWatcher(this);