[AVR] Second Guest + tests. Refactored filters.

This commit is contained in:
magenoxx 2012-05-24 09:01:31 +04:00
parent 3fac42fc3c
commit 32e29392d2
184 changed files with 823 additions and 562 deletions

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -899,7 +899,7 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> 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<ComputerPlayer6> 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<ComputerPlayer6> 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

View file

@ -1411,7 +1411,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
protected List<Permanent> getOpponentBlockers(UUID opponentId, Game game) {
FilterCreatureForCombat blockFilter = new FilterCreatureForCombat();
List<Permanent> blockers = game.getBattlefield().getAllActivePermanents(blockFilter, opponentId);
List<Permanent> blockers = game.getBattlefield().getAllActivePermanents(blockFilter, opponentId, game);
return blockers;
}
@ -1515,7 +1515,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
protected List<Permanent> threats(UUID playerId, UUID sourceId, FilterPermanent filter, Game game, List<UUID> targets) {
List<Permanent> threats = playerId == null ?
game.getBattlefield().getAllActivePermanents(filter) :
game.getBattlefield().getAllActivePermanents(filter, game) :
game.getBattlefield().getActivePermanents(filter, playerId, sourceId, game);
Iterator<Permanent> it = threats.iterator();

View file

@ -92,7 +92,7 @@ class BogGnarrTriggeredAbility extends TriggeredAbilityImpl<BogGnarrTriggeredAbi
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && filter.match(spell)) {
if (spell != null && filter.match(spell, game)) {
return true;
}
}

View file

@ -27,15 +27,12 @@
*/
package mage.sets.apocalypse;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SpellCastTriggeredAbility;
import mage.abilities.effects.common.continious.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.filter.FilterCard;
@ -43,6 +40,8 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import java.util.UUID;
/**
* @author Loki
*/
@ -90,7 +89,7 @@ class GladeGnarrTriggeredAbility extends TriggeredAbilityImpl<GladeGnarrTriggere
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && filter.match(spell)) {
if (spell != null && filter.match(spell, game)) {
return true;
}
}

View file

@ -85,7 +85,7 @@ class TranquilPathEffect extends OneShotEffect<TranquilPathEffect> {
@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;

View file

@ -107,7 +107,7 @@ class AngelOfGlorysRiseEffect extends OneShotEffect<AngelOfGlorysRiseEffect> {
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)) {

View file

@ -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<BarterInBloodEffect> {
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)

View file

@ -94,7 +94,7 @@ class BonfireOfTheDamnedEffect extends OneShotEffect<BonfireOfTheDamnedEffect> {
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;

View file

@ -98,7 +98,7 @@ class DescendantsPathEffect extends OneShotEffect<DescendantsPathEffect> {
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)) {

View file

@ -83,7 +83,7 @@ class DevastationTideEffect extends OneShotEffect<DevastationTideEffect> {
@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;

View file

@ -89,7 +89,7 @@ class EssenceHarvestEffect extends OneShotEffect<EssenceHarvestEffect> {
Player player = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (player != null && targetPlayer != null) {
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId());
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game);
int amount = 0;
for (Permanent creature : creatures) {
int power = creature.getPower().getValue();

View file

@ -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<KillingWaveEffect> {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(filter, playerId);
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(filter, playerId, game);
int lifePaid = 0;
int playerLife = player.getLife();

View file

@ -104,7 +104,7 @@ class LoneRevenantTriggeredAbility extends TriggeredAbilityImpl<LoneRevenantTrig
if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER && event.getSourceId().equals(this.sourceId)
&& ((DamagedPlayerEvent) event).isCombatDamage()) {
Permanent permanent = game.getPermanent(event.getSourceId());
int number = game.getBattlefield().countAll(filter, controllerId);
int number = game.getBattlefield().countAll(filter, controllerId, game);
if (permanent != null && number != 1) {
return false;

View file

@ -157,7 +157,7 @@ class RidersOfGavonyGainAbilityControlledEffect extends ContinuousEffectImpl<Rid
}
}
if (protectionFilter != null) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
perm.addAbility(new ProtectionAbility(protectionFilter), game);
}
return true;

View file

@ -114,7 +114,7 @@ class RiteOfRuinEffect extends OneShotEffect<RiteOfRuinEffect> {
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);

View file

@ -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<SecondGuess> {
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<FilterSecondSpell> {
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;
}
}

View file

@ -96,7 +96,7 @@ class TyrantOfDiscordEffect extends OneShotEffect<TyrantOfDiscordEffect> {
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;

View file

@ -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<FinalJudgmentEffect> {
@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;

View file

@ -91,7 +91,7 @@ class CalltoGloryFirstEffect extends OneShotEffect<CalltoGloryFirstEffect> {
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;

View file

@ -110,7 +110,7 @@ class PainwrackerOniTriggeredAbility1 extends TriggeredAbilityImpl<PainwrackerOn
@Override
public boolean checkInterveningIfClause(Game game) {
return game.getBattlefield().countAll(filter, this.controllerId) < 1;
return game.getBattlefield().countAll(filter, this.controllerId, game) < 1;
}
@Override

View file

@ -76,7 +76,7 @@ class PartTheVeilEffect extends OneShotEffect<PartTheVeilEffect> {
@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;

View file

@ -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<TakenoSamuraiGener
public void init(Ability source, Game game) {
super.init(source, game);
if (this.affectedObjectsSet) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (!perm.getId().equals(source.getSourceId())) {
for (Ability ability : perm.getAbilities()) {
if (ability instanceof BushidoAbility) {
@ -113,7 +113,7 @@ class TakenoSamuraiGeneralEffect extends ContinuousEffectImpl<TakenoSamuraiGener
@Override
public boolean apply(Game game, Ability source) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
if (!perm.getId().equals(source.getSourceId())) {
for (Ability ability : perm.getAbilities()) {

View file

@ -28,7 +28,6 @@
package mage.sets.conflux;
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.game.events.GameEvent.EventType;
import java.util.UUID;
/**
*
* @author loki
@ -103,7 +104,7 @@ class BloodhallOozeTriggeredAbility1 extends TriggeredAbilityImpl<BloodhallOozeT
@Override
public boolean checkInterveningIfClause(Game game) {
return game.getBattlefield().countAll(filter, this.controllerId) >= 1;
return game.getBattlefield().countAll(filter, this.controllerId, game) >= 1;
}
@Override
@ -144,7 +145,7 @@ class BloodhallOozeTriggeredAbility2 extends TriggeredAbilityImpl<BloodhallOozeT
@Override
public boolean checkInterveningIfClause(Game game) {
return game.getBattlefield().countAll(filter, this.controllerId) >= 1;
return game.getBattlefield().countAll(filter, this.controllerId, game) >= 1;
}
@Override

View file

@ -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<Permanent> controlledArtifacts = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), source.getControllerId());
List<Permanent> controlledArtifacts = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), source.getControllerId(), game);
for (Permanent permanent : controlledArtifacts) {
if (!permanent.getId().equals(game.getObject(source.getSourceId()).getId())) {
return true;

View file

@ -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<DarkTemperEffect> {
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);

View file

@ -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<GleamOfResistanceEffect> {
@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);
}

View file

@ -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<ViewFromAboveEffect> {
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);

View file

@ -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<AlphaBrawlEffect> {
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;

View file

@ -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);

View file

@ -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<DiregrafCapta
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD) {
Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
if (p != null && p.getControllerId().equals(this.controllerId) && filter.match(p)) {
if (p != null && p.getControllerId().equals(this.controllerId) && filter.match(p, game)) {
return true;
}
}

View file

@ -27,7 +27,6 @@
*/
package mage.sets.darkascension;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
@ -43,6 +42,8 @@ import mage.filter.Filter;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import java.util.UUID;
/**
*
* @author BetaSteward
@ -109,7 +110,7 @@ class GravecrawlerPlayEffect extends AsThoughEffectImpl<GravecrawlerPlayEffect>
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;
}
}

View file

@ -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<ImmerwolfEffect> {
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;
}
}

View file

@ -94,7 +94,7 @@ class PyreheartWolfEffect extends OneShotEffect<PyreheartWolfEffect> {
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);

View file

@ -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<SuddenDisappearanceEffect>
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> perms = game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget());
List<Permanent> 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));

View file

@ -87,7 +87,7 @@ class SoulscourEffect extends OneShotEffect<SoulscourEffect> {
@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;

View file

@ -90,7 +90,7 @@ class BalefireDragonEffect extends OneShotEffect<BalefireDragonEffect> {
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);
}
}

View file

@ -60,7 +60,7 @@ public class BlasphemousAct extends CardImpl<BlasphemousAct> {
@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) {

View file

@ -116,7 +116,7 @@ class ControlFiveVampiresCost extends CostImpl<ControlFiveVampiresCost> {
@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

View file

@ -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<CurseOfDeathsHoldEffe
if (enchantment != null && enchantment.getAttachedTo() != null) {
Player player = game.getPlayer(enchantment.getAttachedTo());
if (player != null) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId())) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game)) {
perm.addPower(-1);
perm.addToughness(-1);
}

View file

@ -85,7 +85,7 @@ class HalfZombiesCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
int amount = game.getBattlefield().countAll(filter, sourceAbility.getControllerId()) / 2;
int amount = game.getBattlefield().countAll(filter, sourceAbility.getControllerId(), game) / 2;
return amount;
}

View file

@ -90,7 +90,7 @@ class EvilTwinFilter extends FilterCreaturePermanent<EvilTwinFilter> {
@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);

View file

@ -110,7 +110,7 @@ class FullMoonsRiseEffect extends OneShotEffect<FullMoonsRiseEffect> {
@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);

View file

@ -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<LilianaOfTheVeilEffect> {
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<Permanent> pile1 = new ArrayList<Permanent>();
if (player.choose(Outcome.Neutral, target, source.getSourceId(), game)) {

View file

@ -133,7 +133,7 @@ class MemorysJourneyTarget extends TargetCard<MemorysJourneyTarget> {
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;

View file

@ -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<UUID> 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;
}

View file

@ -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<FilterTheMonstrous> {
}
@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))

View file

@ -104,7 +104,7 @@ class UnbreathingHordeEffect1 extends OneShotEffect<UnbreathingHordeEffect1> {
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);

View file

@ -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<FilterSpiritOrEnchantmen
}
@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.ENCHANTMENT) && !permanent.hasSubtype("Spirit"))

View file

@ -28,8 +28,6 @@
package mage.sets.magic2010;
import java.util.List;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
@ -44,6 +42,9 @@ import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInLibrary;
import java.util.List;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -87,7 +88,7 @@ class HauntingEchoesEffect extends OneShotEffect<HauntingEchoesEffect> {
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());

View file

@ -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<MasterOfTheWildHuntEffect>
public boolean apply(Game game, Ability source) {
List<UUID> wolves = new ArrayList<UUID>();
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());

View file

@ -85,7 +85,7 @@ class PlanarCleansingEffect extends OneShotEffect<PlanarCleansingEffect> {
@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;

View file

@ -114,7 +114,7 @@ class SerpentOfTheEndlessSeaEffect extends ReplacementEffectImpl<SerpentOfTheEnd
FilterPermanent filter = new FilterPermanent();
filter.getSubtype().add("Island");
if (game.getBattlefield().countAll(filter, event.getTargetId()) == 0) {
if (game.getBattlefield().countAll(filter, event.getTargetId(), game) == 0) {
return true;
}
}

View file

@ -85,7 +85,7 @@ class SleepEffect extends OneShotEffect<SleepEffect> {
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);
}

View file

@ -83,7 +83,7 @@ class TempestOfLightEffect extends OneShotEffect<TempestOfLightEffect> {
@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;

View file

@ -97,7 +97,7 @@ class HarborSerpentEffect extends RestrictionEffect<HarborSerpentEffect> {
@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;

View file

@ -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<MassPolymorphEffect> {
@Override
public boolean apply(Game game, Ability source) {
int count;
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId());
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game);
count = creatures.size();
for (Permanent creature: creatures) {
creature.moveToExile(null, null, source.getId(), game);

View file

@ -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<OverwhelmingStampe
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
int maxPower = 0;
for (Permanent perm: game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId())) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) {
if (perm.getPower().getValue() > 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) {

View file

@ -165,7 +165,7 @@ class AdaptiveAutomatonBoostControlledEffect extends ContinuousEffectImpl<Adapti
if (permanent != null) {
String subtype = (String) game.getState().getValue(permanent.getId() + "_type");
if (subtype != null) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (!perm.getId().equals(source.getSourceId()) && perm.hasSubtype(subtype)) {
perm.addPower(1);
perm.addToughness(1);

View file

@ -27,9 +27,6 @@
*/
package mage.sets.magic2012;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
@ -45,6 +42,10 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author North
@ -95,7 +96,7 @@ class DoublingChantEffect extends OneShotEffect<DoublingChantEffect> {
if (player == null) {
return false;
}
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId());
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game);
for (Permanent creature : creatures) {
final String creatureName = creature.getName();
if (!namesFiltered.contains(creatureName)) {

View file

@ -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<ScrambleverseEffect> {
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);

View file

@ -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<TimelyReinforcementsEffec
boolean lessCreatures = false;
boolean lessLife = false;
FilterPermanent filter= new FilterCreaturePermanent();
int count = game.getBattlefield().countAll(filter, controller.getId());
int count = game.getBattlefield().countAll(filter, controller.getId(), game);
for (UUID uuid : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(uuid);
if (opponent != null) {
if (opponent.getLife() > controller.getLife()) {
lessLife = true;
}
if (game.getBattlefield().countAll(filter, uuid) > count) {
if (game.getBattlefield().countAll(filter, uuid, game) > count) {
lessCreatures = true;
}
}

View file

@ -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<Permanent> permanents = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId());
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game);
for (Permanent permanent : permanents) {
permanent.addAbility(CantBlockAbility.getInstance(), game);
affectedTargets++;

View file

@ -94,7 +94,7 @@ class ThopterAssemblyTriggeredAbility extends TriggeredAbilityImpl<ThopterAssemb
filter.getSubtype().add("Thopter");
filter.setScopeSubtype(Filter.ComparisonScope.Any);
filter.setAnother(true);
if (!game.getBattlefield().contains(filter, controllerId, 1)) {
if (!game.getBattlefield().contains(filter, controllerId, 1, game)) {
return true;
}
}

View file

@ -136,7 +136,7 @@ class CagedSunEffect2 extends ContinuousEffectImpl<CagedSunEffect2> {
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);

View file

@ -95,7 +95,7 @@ class UnwindingClockEffect extends ContinuousEffectImpl<UnwindingClockEffect> {
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);

View file

@ -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<WarReportEffect> {
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;

View file

@ -126,7 +126,7 @@ class XenograftAddSubtypeEffect extends ContinuousEffectImpl<XenograftAddSubtype
public boolean apply(Game game, Ability source) {
String subtype = (String) game.getState().getValue(source.getSourceId() + "_XenograftType");
if (subtype != null) {
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId());
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game);
for (Permanent permanent : permanents) {
if (permanent != null && !permanent.getSubtype().contains(subtype)) {
permanent.getSubtype().add(subtype);

View file

@ -88,7 +88,7 @@ class AkromasVengeanceEffect extends OneShotEffect<AkromasVengeanceEffect> {
@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;

View file

@ -88,7 +88,7 @@ class BroodBirthingEffect extends OneShotEffect<BroodBirthingEffect> {
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;
}

View file

@ -95,7 +95,7 @@ class DawnglareInvokerEffect extends OneShotEffect<DawnglareInvokerEffect> {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
List<Permanent> allCreatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId());
List<Permanent> allCreatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game);
for (Permanent creature : allCreatures) {
creature.tap(game);
}

View file

@ -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<HellionEruptionEffect> {
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId());
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game);
for (Permanent permanent : permanents) {
permanent.sacrifice(source.getSourceId(), game);
}

View file

@ -77,7 +77,7 @@ public class KhalniHydra extends CardImpl<KhalniHydra> {
@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<ManaCost> iter = ability.getManaCostsToPay().iterator();
while ( reductionAmount > 0 && iter.hasNext() ) {

View file

@ -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)

View file

@ -180,7 +180,7 @@ class SarkhanTheMadDragonDamageEffect extends OneShotEffect<SarkhanTheMadDragonD
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> dragons = game.getBattlefield().getAllActivePermanents(filter);
List<Permanent> dragons = game.getBattlefield().getAllActivePermanents(filter, game);
Player player = game.getPlayer(source.getTargets().getFirstTarget());
if ( player != null && dragons != null && !dragons.isEmpty() ) {
for ( Permanent dragon : dragons ) {

View file

@ -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;

View file

@ -88,7 +88,7 @@ class VeneratedTeacherEffect extends OneShotEffect<VeneratedTeacherEffect> {
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(filter, source.getControllerId());
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game);
if (!permanents.isEmpty()) {
for (Permanent permanent : permanents) {
for (Ability ability : permanent.getAbilities()) {

View file

@ -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<CerebralEruptionEffect1> {
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;

View file

@ -91,7 +91,7 @@ class ContagionEngineEffect extends OneShotEffect<ContagionEngineEffect> {
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;

View file

@ -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<ElspethTirelFirstEffect> {
@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);

View file

@ -174,7 +174,7 @@ class PrecursorGolemCopySpellEffect extends OneShotEffect<PrecursorGolemCopySpel
if (spell != null) {
SpellAbility sa = spell.getSpellAbility();
UUID targetedGolem = (UUID) getValue("targetedGolem");
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filterGolem)) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filterGolem, game)) {
if (permanent.getId().equals(targetedGolem)) {
continue; // copy only for other golems
}

View file

@ -68,7 +68,7 @@ public class ScrapdiverSerpent extends CardImpl<ScrapdiverSerpent> {
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;
}

View file

@ -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;
}

View file

@ -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<TurnAside> {
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<TurnAside> {
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<UUID>();
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());

View file

@ -102,7 +102,7 @@ class ControlTwoOrMoreBlackPermanentsCost extends CostImpl<ControlTwoOrMoreBlack
@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

View file

@ -117,7 +117,7 @@ class ElspethKnightErrantEffect extends ContinuousEffectImpl<ElspethKnightErrant
@Override
public boolean apply(Game game, Ability source) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
perm.addAbility(IndestructibleAbility.getInstance(), game);
}
return true;

View file

@ -28,7 +28,6 @@
package mage.sets.shardsofalara;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
@ -43,6 +42,8 @@ import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -99,9 +100,9 @@ class KnightOfTheWhiteOrchidAbility extends ZoneChangeTriggeredAbility<KnightOfT
@Override
public boolean checkInterveningIfClause(Game game) {
int numLands = game.getBattlefield().countAll(filter2, this.controllerId);
int numLands = game.getBattlefield().countAll(filter2, this.controllerId, game);
for (UUID opponentId: game.getOpponents(this.controllerId)) {
if (numLands < game.getBattlefield().countAll(filter2, opponentId)) {
if (numLands < game.getBattlefield().countAll(filter2, opponentId, game)) {
return true;
}
}

View file

@ -27,15 +27,7 @@
*/
package mage.sets.shardsofalara;
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.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.EntersBattlefieldAbility;
@ -57,6 +49,9 @@ import mage.players.Player;
import mage.target.common.TargetArtifactPermanent;
import mage.target.common.TargetCardInLibrary;
import java.util.List;
import java.util.UUID;
/**
*
* @author North
@ -157,7 +152,7 @@ class TezzeretTheSeekerEffect3 extends ContinuousEffectImpl<TezzeretTheSeekerEff
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), source.getControllerId());
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), source.getControllerId(), game);
for (Permanent permanent : permanents) {
if (permanent != null) {
switch (layer) {

View file

@ -83,7 +83,7 @@ class TranquilityEffect extends OneShotEffect<TranquilityEffect> {
@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;

View file

@ -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<TectonicEdgeCost> {
@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;
}
}

View file

@ -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<ArmamentMasterEffect> {
public void init(Ability source, Game game) {
super.init(source, game);
if (this.affectedObjectsSet) {
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(filter, source.getControllerId());
List<Permanent> 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<ArmamentMasterEffect> {
@Override
public boolean apply(Game game, Ability source) {
int count = countEquipment(game, source);
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(filter, source.getControllerId());
List<Permanent> 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())) {

View file

@ -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<EmeriaTheSky
@Override
public boolean checkInterveningIfClause(Game game) {
return game.getBattlefield().countAll(filter, this.controllerId) >= 7;
return game.getBattlefield().countAll(filter, this.controllerId, game) >= 7;
}
@Override

View file

@ -89,7 +89,7 @@ class FeastOfBloodCost extends CostImpl<FeastOfBloodCost> {
@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

View file

@ -107,7 +107,7 @@ class MalakirBloodwitchEffect extends OneShotEffect<MalakirBloodwitchEffect> {
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<UUID> opponents = game.getOpponents(source.getControllerId());
int total = 0;

View file

@ -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<MarshCasualtiesEffect>
public void init(Ability source, Game game) {
super.init(source, game);
if (this.affectedObjectsSet) {
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget());
List<Permanent> 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<MarshCasualtiesEffect>
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget());
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getFirstTarget(), game);
for (Permanent creature : creatures) {
if (!this.affectedObjectsSet || objects.contains(creature.getId())) {
creature.addPower(power);

View file

@ -95,7 +95,7 @@ class MindlessNullEffect extends RestrictionEffect<MindlessNullEffect> {
@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;

View file

@ -114,7 +114,7 @@ class NissaRevaneGainLifeEffect extends OneShotEffect<NissaRevaneGainLifeEffect>
@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);
}

View file

@ -96,7 +96,7 @@ class ScuteMobAbility extends TriggeredAbilityImpl<ScuteMobAbility> {
@Override
public boolean checkInterveningIfClause(Game game) {
return game.getBattlefield().countAll(filter, this.controllerId) >= 5;
return game.getBattlefield().countAll(filter, this.controllerId, game) >= 5;
}
@Override

View file

@ -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);
}
}

Some files were not shown because too many files have changed in this diff Show more