mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 20:32:06 -08:00
[AVR] Second Guest + tests. Refactored filters.
This commit is contained in:
parent
3fac42fc3c
commit
32e29392d2
184 changed files with 823 additions and 562 deletions
|
|
@ -70,7 +70,7 @@ public class DiesAnotherCreatureTriggeredAbility extends TriggeredAbilityImpl<Di
|
|||
if (nontoken && permanent instanceof PermanentToken) {
|
||||
return false;
|
||||
}
|
||||
if (filter.match(permanent)) {
|
||||
if (filter.match(permanent, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class DiesAnotherCreatureYouControlTriggeredAbility extends TriggeredAbil
|
|||
if (permanent != null && permanent.getCardType().contains(Constants.CardType.CREATURE) &&
|
||||
zEvent.isDiesEvent() &&
|
||||
permanent.getControllerId().equals(this.getControllerId()) && filter != null &&
|
||||
filter.match(permanent)) {
|
||||
filter.match(permanent, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class DiesThisOrAnotherCreatureTriggeredAbility extends TriggeredAbilityI
|
|||
if (permanent.getId().equals(this.getSourceId())) {
|
||||
return true;
|
||||
} else {
|
||||
if (filter.match(permanent)) {
|
||||
if (filter.match(permanent, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class OpponentCastsSpellTriggeredAbility extends TriggeredAbilityImpl<Opp
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST && game.getOpponents(controllerId).contains(event.getPlayerId())) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && filter.match(spell)) {
|
||||
if (spell != null && filter.match(spell, game)) {
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ package mage.abilities.common;
|
|||
import mage.Constants.Zone;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
|
@ -76,7 +75,7 @@ public class SpellCastTriggeredAbility extends TriggeredAbilityImpl<SpellCastTri
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getPlayerId().equals(this.getControllerId())) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && filter.match(spell)) {
|
||||
if (spell != null && filter.match(spell, game)) {
|
||||
if (rememberSource) {
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,13 +97,13 @@ public class ControlsPermanentCondition implements Condition {
|
|||
|
||||
switch ( this.type ) {
|
||||
case FEWER_THAN:
|
||||
conditionApplies = game.getBattlefield().countAll(filter, source.getControllerId()) < this.count;
|
||||
conditionApplies = game.getBattlefield().countAll(filter, source.getControllerId(), game) < this.count;
|
||||
break;
|
||||
case MORE_THAN:
|
||||
conditionApplies = game.getBattlefield().countAll(filter, source.getControllerId()) > 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class PermanentHasCounterCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
boolean conditionApplies = false;
|
||||
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(this.filter, source.getControllerId());
|
||||
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(this.filter, source.getControllerId(), game);
|
||||
for (Permanent permanent : permanents) {
|
||||
switch (this.type) {
|
||||
case FEWER_THAN:
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class ControlPermanentCost extends CostImpl<ControlPermanentCost> {
|
|||
|
||||
@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
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class MetalcraftCost extends CostImpl<MetalcraftCost> {
|
|||
|
||||
@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
|
||||
|
|
|
|||
|
|
@ -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<Planeswalke
|
|||
Player target = game.getPlayer(event.getTargetId());
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (target != null && player != null) {
|
||||
int numPlaneswalkers = game.getBattlefield().countAll(filter, target.getId());
|
||||
int numPlaneswalkers = game.getBattlefield().countAll(filter, target.getId(), game);
|
||||
if (numPlaneswalkers > 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);
|
||||
|
|
|
|||
|
|
@ -90,12 +90,12 @@ public class CantCounterControlledEffect extends ReplacementEffectImpl<CantCount
|
|||
filterTarget.getControllerId().add(source.getControllerId());
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null) {
|
||||
if (filterTarget.match(spell)) {
|
||||
if (filterTarget.match(spell, game)) {
|
||||
if (filterSource == null)
|
||||
return true;
|
||||
else {
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (sourceObject != null && filterSource.match(sourceObject)) {
|
||||
if (sourceObject != null && filterSource.match(sourceObject, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class CantTargetControlledEffect extends ReplacementEffectImpl<CantTarget
|
|||
return true;
|
||||
else {
|
||||
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
|
||||
if (sourceObject != null && filterSource.match(sourceObject)) {
|
||||
if (sourceObject != null && filterSource.match(sourceObject, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class DamageAllControlledTargetEffect extends OneShotEffect<DamageAllCont
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget())) {
|
||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game)) {
|
||||
permanent.damage(amount, source.getId(), game, true, false);
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class DestroyAllControlledTargetEffect extends OneShotEffect<DestroyAllCo
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget())) {
|
||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game)) {
|
||||
permanent.destroy(source.getId(), game, false);
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
|
|||
@Override
|
||||
protected void cardLooked(Card card, Game game, Ability source) {
|
||||
|
||||
if (numberToPick.calculate(game, source) > 0 && filter.match(card))
|
||||
if (numberToPick.calculate(game, source) > 0 && filter.match(card, game))
|
||||
++foundCardsToPick;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public class PreventAllDamageEffect extends PreventionEffectImpl<PreventAllDamag
|
|||
return true;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(damageEvent.getSourceId());
|
||||
if (permanent != null && filter.match(permanent)) {
|
||||
if (permanent != null && filter.match(permanent, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,11 +28,7 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.TargetController;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
|
|
@ -41,6 +37,10 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -76,7 +76,7 @@ public class SacrificeAllEffect extends OneShotEffect<SacrificeAllEffect> {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
List<UUID> perms = new ArrayList<UUID>();
|
||||
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()) {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class SacrificeEffect extends OneShotEffect<SacrificeEffect>{
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class UntapAllControllerEffect extends OneShotEffect<UntapAllControllerEf
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
for (Permanent land: game.getBattlefield().getAllActivePermanents(filter, player.getId())) {
|
||||
for (Permanent land: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
|
||||
land.untap(game);
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class UntapAllLandsControllerEffect extends OneShotEffect<UntapAllLandsCo
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
for (Permanent land: game.getBattlefield().getAllActivePermanents(new FilterLandPermanent(), player.getId())) {
|
||||
for (Permanent land: game.getBattlefield().getAllActivePermanents(new FilterLandPermanent(), player.getId(), game)) {
|
||||
land.untap(game);
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledE
|
|||
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 (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
objects.add(perm.getId());
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledE
|
|||
|
||||
@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 (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
perm.addPower(power.calculate(game, source));
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class BoostOpponentsEffect extends ContinuousEffectImpl<BoostOpponentsEff
|
|||
super.init(source, game);
|
||||
if (this.affectedObjectsSet) {
|
||||
Set<UUID> 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<BoostOpponentsEff
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Set<UUID> 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);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl<GainAbilityAllEff
|
|||
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 (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
objects.add(perm.getId());
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl<GainAbilityAllEff
|
|||
|
||||
@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 (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
perm.addAbility(ability, game);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import mage.Constants.Outcome;
|
|||
import mage.Constants.SubLayer;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
|
@ -76,7 +75,7 @@ public class GainAbilityControlledEffect extends ContinuousEffectImpl<GainAbilit
|
|||
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 (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
objects.add(perm.getId());
|
||||
}
|
||||
|
|
@ -91,7 +90,7 @@ public class GainAbilityControlledEffect extends ContinuousEffectImpl<GainAbilit
|
|||
|
||||
@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 (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
perm.addAbility(ability, game);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class PlayTheTopCardEffect extends AsThoughEffectImpl<PlayTheTopCardEffec
|
|||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null && filter.match(card)) {
|
||||
if (card != null && filter.match(card, game)) {
|
||||
Player player = game.getPlayer(card.getOwnerId());
|
||||
if (player != null && card.equals(player.getLibrary().getFromTop(game))) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.TargetController;
|
||||
import mage.Constants.Zone;
|
||||
|
|
@ -44,6 +43,8 @@ import mage.players.Player;
|
|||
import mage.target.Target;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* TODO: Javadoc me
|
||||
*
|
||||
|
|
@ -114,7 +115,7 @@ class AnnihilatorEffect extends OneShotEffect<AnnihilatorEffect> {
|
|||
}
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class LandwalkEffect extends RestrictionEffect<LandwalkEffect> {
|
|||
|
||||
@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
|
||||
|
|
|
|||
|
|
@ -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<ProtectionAbility> {
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public class CardsImpl extends LinkedHashSet<UUID> 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<UUID> implements Cards, Serializabl
|
|||
public Set<Card> getCards(FilterCard filter, Game game) {
|
||||
Set<Card> cards = new LinkedHashSet<Card>();
|
||||
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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
package mage.filter;
|
||||
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
|
@ -44,7 +46,7 @@ public interface Filter<E> 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);
|
||||
|
|
|
|||
|
|
@ -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<T extends Ability> extends FilterImpl<T, FilterAbilit
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean match(T object) {
|
||||
public boolean match(T object, Game game) {
|
||||
|
||||
if (zone != null) {
|
||||
if (object.getZone().match(zone) == notZone)
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ public class FilterCard<T extends FilterCard<T>> extends FilterObject<Card, Filt
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Card card) {
|
||||
if (!super.match(card))
|
||||
public boolean match(Card card, Game game) {
|
||||
if (!super.match(card, game))
|
||||
return notFilter;
|
||||
|
||||
if (ownerId.size() > 0 && ownerId.contains(card.getOwnerId()) == notOwner)
|
||||
|
|
@ -123,7 +123,7 @@ public class FilterCard<T extends FilterCard<T>> extends FilterObject<Card, Filt
|
|||
}
|
||||
|
||||
public boolean match(Card card, UUID playerId, Game game) {
|
||||
if (!this.match(card))
|
||||
if (!this.match(card, game))
|
||||
return notFilter;
|
||||
|
||||
if (owner != TargetController.ANY && playerId != null) {
|
||||
|
|
@ -176,10 +176,10 @@ public class FilterCard<T extends FilterCard<T>> extends FilterObject<Card, Filt
|
|||
return true;
|
||||
}
|
||||
|
||||
public Set<Card> filter(Set<Card> cards) {
|
||||
public Set<Card> filter(Set<Card> cards, Game game) {
|
||||
Set<Card> filtered = new HashSet<Card>();
|
||||
for (Card card: cards) {
|
||||
if (match(card)) {
|
||||
if (match(card, game)) {
|
||||
filtered.add(card);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<E extends MageObject, T extends FilterObject<E, T>> ex
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean match(E object) {
|
||||
public boolean match(E object, Game game) {
|
||||
|
||||
if (name.size() > 0) {
|
||||
if (name.contains(object.getName()) == notName)
|
||||
|
|
|
|||
|
|
@ -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<T extends FilterPermanent<T>> 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<T extends FilterPermanent<T>> 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) {
|
||||
|
|
|
|||
|
|
@ -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<Player, FilterPlayer> 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<Player, FilterPlayer> 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) {
|
||||
|
|
|
|||
|
|
@ -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<FilterSpell> {
|
||||
public class FilterSpell<T extends FilterSpell<T>> extends FilterStackObject<FilterSpell<T>> {
|
||||
|
||||
protected Zone fromZone = Zone.ALL;
|
||||
protected boolean notFromZone = false;
|
||||
|
|
@ -53,27 +54,27 @@ public class FilterSpell extends FilterStackObject<FilterSpell> {
|
|||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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<T extends FilterStackObject<T>> 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<T extends FilterStackObject<T>> 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) {
|
||||
|
|
|
|||
|
|
@ -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<T extends FilterArtifactPermanent<T>> 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)
|
||||
|
|
|
|||
|
|
@ -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<FilterCreat
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Permanent permanent) {
|
||||
if (!super.match(permanent))
|
||||
public boolean match(Permanent permanent, Game game) {
|
||||
if (!super.match(permanent, game))
|
||||
return notFilter;
|
||||
|
||||
return permanent.canTap();
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.filter.common;
|
||||
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
|
|
@ -55,8 +56,8 @@ public class FilterCreatureForCombat extends FilterCreaturePermanent<FilterCreat
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Permanent permanent) {
|
||||
if (!super.match(permanent))
|
||||
public boolean match(Permanent permanent, Game game) {
|
||||
if (!super.match(permanent, game))
|
||||
return notFilter;
|
||||
|
||||
return permanent.getMaxBlocks() == 0 || permanent.getBlocking() < permanent.getMaxBlocks();
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@
|
|||
|
||||
package mage.filter.common;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.filter.FilterImpl;
|
||||
import mage.filter.FilterInPlay;
|
||||
import mage.filter.FilterPlayer;
|
||||
|
|
@ -37,6 +35,8 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -71,12 +71,12 @@ public class FilterCreatureOrPlayer extends FilterImpl<Object, FilterCreatureOrP
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Object o) {
|
||||
public boolean match(Object o, Game game) {
|
||||
if (o instanceof Player) {
|
||||
return playerFilter.match((Player)o);
|
||||
return playerFilter.match((Player)o, game);
|
||||
}
|
||||
else if (o instanceof Permanent) {
|
||||
return creatureFilter.match((Permanent)o);
|
||||
return creatureFilter.match((Permanent)o, game);
|
||||
}
|
||||
return notFilter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
@ -67,8 +68,8 @@ public class FilterCreaturePermanent<T extends FilterCreaturePermanent<T>> 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<T extends FilterCreaturePermanent<T>> 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;
|
||||
|
|
|
|||
|
|
@ -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<FilterNonTokenPerma
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Permanent permanent) {
|
||||
if (!super.match(permanent)) {
|
||||
public boolean match(Permanent permanent, Game game) {
|
||||
if (!super.match(permanent, game)) {
|
||||
return notFilter;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ public class FilterNotPairedControlledCreaturePermanent extends FilterControlled
|
|||
}
|
||||
|
||||
@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.getPairedCard() != null)
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@ public class FilterPermanentOrPlayer extends FilterImpl<Object, FilterPermanentO
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Object o) {
|
||||
public boolean match(Object o, Game game) {
|
||||
if (o instanceof Player) {
|
||||
return playerFilter.match((Player) o);
|
||||
return playerFilter.match((Player) o, game);
|
||||
} else if (o instanceof Permanent) {
|
||||
return permanentFilter.match((Permanent) o);
|
||||
return permanentFilter.match((Permanent) o, game);
|
||||
}
|
||||
return notFilter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class FilterPermanentOrPlayerWithCounter extends FilterPermanentOrPlayer
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Object o) {
|
||||
public boolean match(Object o, Game game) {
|
||||
if (o instanceof Player) {
|
||||
if (((Player)o).getCounters().size() == 0) {
|
||||
return false;
|
||||
|
|
@ -79,7 +79,7 @@ public class FilterPermanentOrPlayerWithCounter extends FilterPermanentOrPlayer
|
|||
return false;
|
||||
}
|
||||
}
|
||||
return super.match(o);
|
||||
return super.match(o, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -28,14 +28,16 @@
|
|||
|
||||
package mage.filter.common;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterImpl;
|
||||
import mage.filter.FilterPlayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -60,12 +62,12 @@ public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object, FilterPlanesw
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Object o) {
|
||||
public boolean match(Object o, Game game) {
|
||||
if (o instanceof Player) {
|
||||
return playerFilter.match((Player)o);
|
||||
return playerFilter.match((Player)o, game);
|
||||
}
|
||||
else if (o instanceof Permanent) {
|
||||
return planeswalkerFilter.match((Permanent)o);
|
||||
return planeswalkerFilter.match((Permanent)o, game);
|
||||
}
|
||||
return notFilter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
*/
|
||||
package mage.filter.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.filter.FilterImpl;
|
||||
import mage.filter.FilterInPlay;
|
||||
import mage.filter.FilterPermanent;
|
||||
|
|
@ -38,6 +37,8 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX
|
||||
|
|
@ -72,11 +73,11 @@ public class FilterSpellOrPermanent extends FilterImpl<Object, FilterPermanentOr
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Object o) {
|
||||
public boolean match(Object o, Game game) {
|
||||
if (o instanceof Spell) {
|
||||
return spellFilter.match((Spell) o);
|
||||
return spellFilter.match((Spell) o, game);
|
||||
} else if (o instanceof Permanent) {
|
||||
return permanentFilter.match((Permanent) o);
|
||||
return permanentFilter.match((Permanent) o, game);
|
||||
}
|
||||
return notFilter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.filter.common;
|
||||
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentToken;
|
||||
|
||||
|
|
@ -50,10 +51,10 @@ public class FilterToken<T extends FilterToken<T>> 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;
|
||||
|
|
|
|||
|
|
@ -888,7 +888,7 @@ public abstract class GameImpl<T extends GameImpl<T>> 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<T extends GameImpl<T>> 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<T extends GameImpl<T>> 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<T extends GameImpl<T>> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Permanent> getAllActivePermanents(FilterPermanent filter) {
|
||||
public List<Permanent> getAllActivePermanents(FilterPermanent filter, Game game) {
|
||||
List<Permanent> active = new ArrayList<Permanent>();
|
||||
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<Permanent> getAllActivePermanents(FilterPermanent filter, UUID controllerId) {
|
||||
public List<Permanent> getAllActivePermanents(FilterPermanent filter, UUID controllerId, Game game) {
|
||||
List<Permanent> active = new ArrayList<Permanent>();
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -549,7 +549,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> 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<T extends PermanentImpl<T>> 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<T extends PermanentImpl<T>> 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<T extends PermanentImpl<T>> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,8 +188,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -313,14 +313,14 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> 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<T extends PlayerImpl<T>> 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<T extends PlayerImpl<T>> 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<T extends PlayerImpl<T>> 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<T extends PlayerImpl<T>> implements Player, Ser
|
|||
@Override
|
||||
public List<Permanent> getAvailableAttackers(Game game) {
|
||||
FilterCreatureForCombat filter = new FilterCreatureForCombat();
|
||||
List<Permanent> attackers = game.getBattlefield().getAllActivePermanents(filter, playerId);
|
||||
List<Permanent> attackers = game.getBattlefield().getAllActivePermanents(filter, playerId, game);
|
||||
for (Iterator<Permanent> i = attackers.iterator(); i.hasNext();) {
|
||||
Permanent entry = i.next();
|
||||
if (!entry.canAttack(game))
|
||||
|
|
@ -1141,7 +1141,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
@Override
|
||||
public List<Permanent> getAvailableBlockers(Game game) {
|
||||
FilterCreatureForCombat blockFilter = new FilterCreatureForCombat();
|
||||
List<Permanent> blockers = game.getBattlefield().getAllActivePermanents(blockFilter, playerId);
|
||||
List<Permanent> blockers = game.getBattlefield().getAllActivePermanents(blockFilter, playerId, game);
|
||||
return blockers;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<T extends TargetCard<T>> extends TargetObject<TargetCard
|
|||
break;
|
||||
case LIBRARY:
|
||||
for (Card card: player.getLibrary().getUniqueCards(game)) {
|
||||
if (filter.match(card))
|
||||
if (filter.match(card, game))
|
||||
possibleTargets.add(card.getId());
|
||||
}
|
||||
break;
|
||||
|
|
@ -179,7 +180,7 @@ public class TargetCard<T extends TargetCard<T>> extends TargetObject<TargetCard
|
|||
public boolean canTarget(UUID id, Cards cards, Game game) {
|
||||
Card card = cards.get(id, game);
|
||||
if (card != null)
|
||||
return filter.match(card);
|
||||
return filter.match(card, game);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,12 +28,13 @@
|
|||
|
||||
package mage.target;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -77,7 +78,7 @@ public abstract class TargetObject<T extends TargetObject<T>> 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ public class TargetPlayer<T extends TargetPlayer<T>> extends TargetImpl<TargetPl
|
|||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.hasLeft() && filter.match(player)) {
|
||||
if (player.canBeTargetedBy(targetSource)) {
|
||||
if (player != null && !player.hasLeft() && filter.match(player, game)) {
|
||||
if (player.canBeTargetedBy(targetSource, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets)
|
||||
return true;
|
||||
|
|
@ -115,7 +115,7 @@ public class TargetPlayer<T extends TargetPlayer<T>> extends TargetImpl<TargetPl
|
|||
int count = 0;
|
||||
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)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets)
|
||||
return true;
|
||||
|
|
@ -130,8 +130,8 @@ public class TargetPlayer<T extends TargetPlayer<T>> extends TargetImpl<TargetPl
|
|||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.hasLeft() && filter.match(player)) {
|
||||
if (player.canBeTargetedBy(targetSource))
|
||||
if (player != null && !player.hasLeft() && filter.match(player, game)) {
|
||||
if (player.canBeTargetedBy(targetSource, game))
|
||||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ public class TargetPlayer<T extends TargetPlayer<T>> extends TargetImpl<TargetPl
|
|||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
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<T extends TargetPlayer<T>> extends TargetImpl<TargetPl
|
|||
public boolean canTarget(UUID id, Game game) {
|
||||
Player player = game.getPlayer(id);
|
||||
if (player != null) {
|
||||
return filter.match(player);
|
||||
return filter.match(player, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -174,9 +174,9 @@ public class TargetPlayer<T extends TargetPlayer<T>> extends TargetImpl<TargetPl
|
|||
Player player = game.getPlayer(id);
|
||||
if (player != null) {
|
||||
if (source != null)
|
||||
return player.canBeTargetedBy(game.getObject(source.getSourceId())) && filter.match(player);
|
||||
return player.canBeTargetedBy(game.getObject(source.getSourceId()), game) && filter.match(player, game);
|
||||
else
|
||||
return filter.match(player);
|
||||
return filter.match(player, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -39,6 +36,10 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -106,14 +107,14 @@ public class TargetSource extends TargetObject<TargetSource> {
|
|||
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<TargetSource> {
|
|||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class TargetSpell extends TargetObject<TargetSpell> {
|
|||
}
|
||||
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<TargetSpell> {
|
|||
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<TargetSpell> {
|
|||
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)) {
|
||||
possibleTargets.add(stackObject.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<TargetStackObject> {
|
|||
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<TargetStackObject> {
|
|||
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<TargetStackObject> {
|
|||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<TargetCardInExile> {
|
|||
exile = game.getExile().getPermanentExile();
|
||||
}
|
||||
if (exile != null && exile.contains(id)) {
|
||||
return filter.match(card);
|
||||
return filter.match(card, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -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<TargetCardInGraveyard> {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class TargetCardInHand extends TargetCard<TargetCardInHand> {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<TargetCardInLibrary> {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class TargetCardInOpponentsGraveyard extends TargetCard<TargetCardInOppon
|
|||
Card card = game.getCard(id);
|
||||
if (card != null && game.getState().getZone(card.getId()) == Constants.Zone.GRAVEYARD) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(card.getOwnerId())) {
|
||||
return filter.match(card);
|
||||
return filter.match(card, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class TargetCardInYourGraveyard extends TargetCard<TargetCardInYourGravey
|
|||
Card card = game.getCard(id);
|
||||
if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD)
|
||||
if (game.getPlayer(source.getControllerId()).getGraveyard().contains(id))
|
||||
return filter.match(card);
|
||||
return filter.match(card, game);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,11 +86,11 @@ public class TargetCreatureOrPlayer extends TargetImpl<TargetCreatureOrPlayer> {
|
|||
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<TargetCreatureOrPlayer> {
|
|||
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<TargetCreatureOrPlayer> {
|
|||
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<TargetCreatureOrPlayer> {
|
|||
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<TargetCreatureOrPlayer> {
|
|||
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<TargetCreatureOrPlayer> {
|
|||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<TargetCreatureOrP
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
@ -87,14 +88,14 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount<TargetCreatureOrP
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +105,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount<TargetCreatureOrP
|
|||
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;
|
||||
|
|
@ -125,7 +126,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount<TargetCreatureOrP
|
|||
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;
|
||||
|
|
@ -147,7 +148,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount<TargetCreatureOrP
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -164,7 +165,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount<TargetCreatureOrP
|
|||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<TargetCreaturePe
|
|||
public boolean canTarget(UUID id, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
return filter.match(permanent);
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -86,7 +87,7 @@ public class TargetCreaturePermanentAmount extends TargetAmount<TargetCreaturePe
|
|||
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);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -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.TargetImpl;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -85,14 +86,14 @@ public class TargetDefender extends TargetImpl<TargetDefender> {
|
|||
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<TargetDefender> {
|
|||
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<TargetDefender> {
|
|||
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<TargetDefender> {
|
|||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
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<TargetDefender> {
|
|||
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<TargetDefender> {
|
|||
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<TargetDefender> {
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<TargetDiscard> {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,11 +93,11 @@ public class TargetPermanentOrPlayer extends TargetImpl<TargetPermanentOrPlayer>
|
|||
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<TargetPermanentOrPlayer>
|
|||
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<TargetPermanentOrPlayer>
|
|||
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<TargetPermanentOrPlayer>
|
|||
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<TargetPermanentOrPlayer>
|
|||
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<TargetPermanentOrPlayer>
|
|||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<TargetSpellOrPermanent> {
|
|||
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<TargetSpellOrPermanent> {
|
|||
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<TargetSpellOrPermanent> {
|
|||
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<TargetSpellOrPermanent> {
|
|||
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<TargetSpellOrPermanent> {
|
|||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<CastSpellLastTurnWatch
|
|||
|
||||
private Map<UUID, Integer> amountOfSpellsCastOnPrevTurn = new HashMap<UUID, Integer>();
|
||||
private Map<UUID, Integer> amountOfSpellsCastOnCurrentTurn = new HashMap<UUID, Integer>();
|
||||
private List<UUID> spellsCastThisTurnInOrder = new ArrayList<UUID>();
|
||||
|
||||
public CastSpellLastTurnWatcher() {
|
||||
super("CastSpellLastTurnWatcher", WatcherScope.GAME);
|
||||
|
|
@ -64,6 +64,7 @@ public class CastSpellLastTurnWatcher extends WatcherImpl<CastSpellLastTurnWatch
|
|||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
spellsCastThisTurnInOrder.add(event.getTargetId());
|
||||
UUID playerId = event.getPlayerId();
|
||||
if (playerId != null) {
|
||||
Integer amount = amountOfSpellsCastOnCurrentTurn.get(playerId);
|
||||
|
|
@ -84,12 +85,28 @@ public class CastSpellLastTurnWatcher extends WatcherImpl<CastSpellLastTurnWatch
|
|||
amountOfSpellsCastOnPrevTurn.clear();
|
||||
amountOfSpellsCastOnPrevTurn.putAll(amountOfSpellsCastOnCurrentTurn);
|
||||
amountOfSpellsCastOnCurrentTurn.clear();
|
||||
spellsCastThisTurnInOrder.clear();
|
||||
}
|
||||
|
||||
public Map<UUID, Integer> getAmountOfSpellsCastOnPrevTurn() {
|
||||
return amountOfSpellsCastOnPrevTurn;
|
||||
}
|
||||
|
||||
public Map<UUID, Integer> 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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue