mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Fixed some bugs that prevent to select shroud or hexproof targets by not targeted effects (e.g. Proliferate).
This commit is contained in:
parent
5c2189fdd7
commit
66cf690968
8 changed files with 232 additions and 87 deletions
|
@ -58,9 +58,13 @@ public class ContagionEngine extends CardImpl {
|
||||||
public ContagionEngine (UUID ownerId) {
|
public ContagionEngine (UUID ownerId) {
|
||||||
super(ownerId, 145, "Contagion Engine", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{6}");
|
super(ownerId, 145, "Contagion Engine", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{6}");
|
||||||
this.expansionSetCode = "SOM";
|
this.expansionSetCode = "SOM";
|
||||||
|
|
||||||
|
// When Contagion Engine enters the battlefield, put a -1/-1 counter on each creature target player controls.
|
||||||
Ability ability = new EntersBattlefieldTriggeredAbility(new ContagionEngineEffect());
|
Ability ability = new EntersBattlefieldTriggeredAbility(new ContagionEngineEffect());
|
||||||
ability.addTarget(new TargetPlayer());
|
ability.addTarget(new TargetPlayer());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
|
// {4}, {T}: Proliferate, then proliferate again. (You choose any number of permanents and/or players with counters on them, then give each another counter of a kind already there. Then do it again.)
|
||||||
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ProliferateEffect(), new GenericManaCost(4));
|
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ProliferateEffect(), new GenericManaCost(4));
|
||||||
ability.addCost(new TapSourceCost());
|
ability.addCost(new TapSourceCost());
|
||||||
ability.addEffect(new ProliferateEffect());
|
ability.addEffect(new ProliferateEffect());
|
||||||
|
@ -90,10 +94,10 @@ class ContagionEngineEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player target = game.getPlayer(source.getFirstTarget());
|
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||||
if (target != null) {
|
if (targetPlayer != null) {
|
||||||
for (Permanent p : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), target.getId(), game)) {
|
for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), targetPlayer.getId(), game)) {
|
||||||
p.addCounters(CounterType.M1M1.createInstance(), game);
|
creature.addCounters(CounterType.M1M1.createInstance(), game);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package org.mage.test.cards.single;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.counters.CounterType;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ContagionEngineTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
// When Contagion Engine enters the battlefield, put a -1/-1 counter on each creature target player controls.
|
||||||
|
// {4}, {T}: Proliferate, then proliferate again. (You choose any number of permanents and/or players with
|
||||||
|
// counters on them, then give each another counter of a kind already there. Then do it again.)
|
||||||
|
@Test
|
||||||
|
public void testCountersArePut() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain",6);
|
||||||
|
addCard(Zone.HAND, playerA, "Contagion Engine");
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Pincher Beetles"); // 3/1 + Shroud
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Sacred Wolf"); // 3/1 + Hexproof
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Beloved Chaplain"); // 3/1 + Protection from creatures
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Contagion Engine");
|
||||||
|
addTarget(playerA, playerB);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertLife(playerA, 20);
|
||||||
|
assertLife(playerB, 20);
|
||||||
|
|
||||||
|
assertPowerToughness(playerB, "Silvercoat Lion", 1, 1);
|
||||||
|
|
||||||
|
assertGraveyardCount(playerB, "Sacred Wolf",1);
|
||||||
|
assertGraveyardCount(playerB, "Beloved Chaplain",1);
|
||||||
|
assertGraveyardCount(playerB, "Pincher Beetles",1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCountersDoubledByProliferate() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain",6);
|
||||||
|
addCard(Zone.HAND, playerA, "Contagion Engine");
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Ajani Goldmane");
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Wall of Frost"); // 0/7
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Kalonian Behemoth"); // 9/9 + Shroud
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Plated Slagwurm"); // 8/8 + Hexproof
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Teysa, Envoy of Ghosts"); // 4/4 + Protection from creatures
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Contagion Engine");
|
||||||
|
addTarget(playerA, playerB);
|
||||||
|
|
||||||
|
activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{4},{T}: Proliferate");
|
||||||
|
setChoice(playerA, "Wall of Frost^Kalonian Behemoth^Plated Slagwurm^Teysa, Envoy of Ghosts^Ajani Goldmane");
|
||||||
|
setChoice(playerA, "Wall of Frost^Kalonian Behemoth^Plated Slagwurm^Teysa, Envoy of Ghosts^Ajani Goldmane");
|
||||||
|
|
||||||
|
setStopAt(3, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertLife(playerA, 20);
|
||||||
|
assertLife(playerB, 20);
|
||||||
|
|
||||||
|
assertCounterCount("Ajani Goldmane", CounterType.LOYALTY, 6);
|
||||||
|
|
||||||
|
assertPowerToughness(playerB, "Kalonian Behemoth", 6, 6);
|
||||||
|
assertPowerToughness(playerB, "Plated Slagwurm", 5, 5);
|
||||||
|
assertPowerToughness(playerB, "Teysa, Envoy of Ghosts", 1, 1);
|
||||||
|
assertPowerToughness(playerB, "Wall of Frost", -3, 4);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -69,6 +69,7 @@ import mage.cards.Card;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.target.TargetSource;
|
import mage.target.TargetSource;
|
||||||
import mage.target.common.TargetCardInHand;
|
import mage.target.common.TargetCardInHand;
|
||||||
|
import mage.target.common.TargetPermanentOrPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -301,23 +302,40 @@ public class TestPlayer extends ComputerPlayer {
|
||||||
@Override
|
@Override
|
||||||
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map<String, Serializable> options) {
|
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map<String, Serializable> options) {
|
||||||
if (!choices.isEmpty()) {
|
if (!choices.isEmpty()) {
|
||||||
if (target instanceof TargetPermanent) {
|
if ((target instanceof TargetPermanent) || (target instanceof TargetPermanentOrPlayer)) { // player target not implemted yet
|
||||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents((FilterPermanent)target.getFilter(), game)) {
|
FilterPermanent filterPermanent;
|
||||||
for (String choose2: choices) {
|
if (target instanceof TargetPermanentOrPlayer) {
|
||||||
if (permanent.getName().equals(choose2)) {
|
filterPermanent = ((TargetPermanentOrPlayer) target).getFilterPermanent();
|
||||||
if (((TargetPermanent)target).canTarget(playerId, permanent.getId(), null, game) && !target.getTargets().contains(permanent.getId())) {
|
} else {
|
||||||
target.add(permanent.getId(), game);
|
filterPermanent = ((TargetPermanent) target).getFilter();
|
||||||
choices.remove(choose2);
|
}
|
||||||
return true;
|
for (String choose2: choices) {
|
||||||
|
String[] targetList = choose2.split("\\^");
|
||||||
|
boolean targetFound = false;
|
||||||
|
for (String targetName: targetList) {
|
||||||
|
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filterPermanent, game)) {
|
||||||
|
if (target.getTargets().contains(permanent.getId())) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
} else if ((permanent.getName()+"-"+permanent.getExpansionSetCode()).equals(choose2)) {
|
if (permanent.getName().equals(targetName)) {
|
||||||
if (((TargetPermanent)target).canTarget(playerId, permanent.getId(), null, game) && !target.getTargets().contains(permanent.getId())) {
|
if (target.isNotTarget() || ((TargetPermanent)target).canTarget(playerId, permanent.getId(), null, game)) {
|
||||||
target.add(permanent.getId(), game);
|
target.add(permanent.getId(), game);
|
||||||
choices.remove(choose2);
|
targetFound = true;
|
||||||
return true;
|
break;
|
||||||
|
}
|
||||||
|
} else if ((permanent.getName()+"-"+permanent.getExpansionSetCode()).equals(targetName)) {
|
||||||
|
if (target.isNotTarget() || ((TargetPermanent)target).canTarget(playerId, permanent.getId(), null, game)) {
|
||||||
|
target.add(permanent.getId(), game);
|
||||||
|
targetFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (targetFound) {
|
||||||
|
choices.remove(choose2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (target instanceof TargetPlayer) {
|
if (target instanceof TargetPlayer) {
|
||||||
|
@ -362,7 +380,7 @@ public class TestPlayer extends ComputerPlayer {
|
||||||
@Override
|
@Override
|
||||||
public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) {
|
public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) {
|
||||||
if (!targets.isEmpty()) {
|
if (!targets.isEmpty()) {
|
||||||
if (target instanceof TargetPermanent) {
|
if ((target instanceof TargetPermanent) || (target instanceof TargetPermanentOrPlayer)) {
|
||||||
for (String targetDefinition: targets) {
|
for (String targetDefinition: targets) {
|
||||||
String[] targetList = targetDefinition.split("\\^");
|
String[] targetList = targetDefinition.split("\\^");
|
||||||
boolean targetFound = false;
|
boolean targetFound = false;
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class ProliferateEffect extends OneShotEffect {
|
||||||
|
|
||||||
public ProliferateEffect() {
|
public ProliferateEffect() {
|
||||||
super(Outcome.Benefit);
|
super(Outcome.Benefit);
|
||||||
staticText = "Proliferate. (You choose any number of permanents and/or players with counters on them, then give each another counter of a kind already there.)";
|
staticText = "Proliferate. <i>(You choose any number of permanents and/or players with counters on them, then give each another counter of a kind already there.)</i>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProliferateEffect(ProliferateEffect effect) {
|
public ProliferateEffect(ProliferateEffect effect) {
|
||||||
|
@ -63,81 +63,71 @@ public class ProliferateEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
if (controller == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Target target = new TargetPermanentOrPlayerWithCounter(0, Integer.MAX_VALUE, true);
|
Target target = new TargetPermanentOrPlayerWithCounter(0, Integer.MAX_VALUE, true);
|
||||||
|
Map<String, Serializable> options = new HashMap<>();
|
||||||
|
options.put("UI.right.btn.text", "Done");
|
||||||
|
controller.choose(Outcome.Benefit, target, source.getSourceId(), game, options);
|
||||||
|
|
||||||
//A spell or ability could have removed the only legal target this player
|
for (int idx = 0; idx < target.getTargets().size(); idx++) {
|
||||||
//had, if thats the case this ability should fizzle.
|
UUID chosen = (UUID) target.getTargets().get(idx);
|
||||||
if (target.canChoose(controller.getId(), game)) {
|
Permanent permanent = game.getPermanent(chosen);
|
||||||
boolean abilityApplied = false;
|
if (permanent != null) {
|
||||||
Map<String, Serializable> options = new HashMap<>();
|
if (permanent.getCounters().size() > 0) {
|
||||||
options.put("UI.right.btn.text", "Done");
|
if (permanent.getCounters().size() == 1) {
|
||||||
while (target.canChoose(controller.getId(), game)) {
|
for (Counter counter : permanent.getCounters().values()) {
|
||||||
if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game, options)) {
|
permanent.addCounters(counter.getName(), 1, game);
|
||||||
break;
|
}
|
||||||
}
|
} else {
|
||||||
}
|
Choice choice = new ChoiceImpl(true);
|
||||||
|
Set<String> choices = new HashSet<>();
|
||||||
for (int idx = 0; idx < target.getTargets().size(); idx++) {
|
for (Counter counter : permanent.getCounters().values()) {
|
||||||
UUID chosen = (UUID) target.getTargets().get(idx);
|
choices.add(counter.getName());
|
||||||
Permanent permanent = game.getPermanent(chosen);
|
}
|
||||||
if (permanent != null) {
|
choice.setChoices(choices);
|
||||||
if (permanent.getCounters().size() > 0) {
|
choice.setMessage("Choose a counter to proliferate (" + permanent.getName() + ")");
|
||||||
if (permanent.getCounters().size() == 1) {
|
controller.choose(Outcome.Benefit, choice, game);
|
||||||
for (Counter counter : permanent.getCounters().values()) {
|
for (Counter counter : permanent.getCounters().values()) {
|
||||||
|
if (counter.getName().equals(choice.getChoice())) {
|
||||||
permanent.addCounters(counter.getName(), 1, game);
|
permanent.addCounters(counter.getName(), 1, game);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Player player = game.getPlayer(chosen);
|
||||||
|
if (player != null) {
|
||||||
|
if (player.getCounters().size() > 0) {
|
||||||
|
if (player.getCounters().size() == 1) {
|
||||||
|
for (Counter counter : player.getCounters().values()) {
|
||||||
|
Counter newCounter = new Counter(counter.getName());
|
||||||
|
player.addCounters(newCounter, game);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Choice choice = new ChoiceImpl(true);
|
Choice choice = new ChoiceImpl(true);
|
||||||
Set<String> choices = new HashSet<>();
|
Set<String> choices = new HashSet<>();
|
||||||
for (Counter counter : permanent.getCounters().values()) {
|
for (Counter counter : player.getCounters().values()) {
|
||||||
choices.add(counter.getName());
|
choices.add(counter.getName());
|
||||||
}
|
}
|
||||||
choice.setChoices(choices);
|
choice.setChoices(choices);
|
||||||
choice.setMessage("Choose a counter to proliferate (" + permanent.getName() + ")");
|
choice.setMessage("Choose a counter to proliferate (" + player.getName() + ")");
|
||||||
controller.choose(Outcome.Benefit, choice, game);
|
controller.choose(Outcome.Benefit, choice, game);
|
||||||
for (Counter counter : permanent.getCounters().values()) {
|
for (Counter counter : player.getCounters().values()) {
|
||||||
if (counter.getName().equals(choice.getChoice())) {
|
if (counter.getName().equals(choice.getChoice())) {
|
||||||
permanent.addCounters(counter.getName(), 1, game);
|
Counter newCounter = new Counter(counter.getName());
|
||||||
|
player.addCounters(newCounter, game);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Player player = game.getPlayer(chosen);
|
|
||||||
if (player != null) {
|
|
||||||
if (player.getCounters().size() > 0) {
|
|
||||||
if (player.getCounters().size() == 1) {
|
|
||||||
for (Counter counter : player.getCounters().values()) {
|
|
||||||
Counter newCounter = new Counter(counter.getName());
|
|
||||||
player.addCounters(newCounter, game);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Choice choice = new ChoiceImpl(true);
|
|
||||||
Set<String> choices = new HashSet<>();
|
|
||||||
for (Counter counter : player.getCounters().values()) {
|
|
||||||
choices.add(counter.getName());
|
|
||||||
}
|
|
||||||
choice.setChoices(choices);
|
|
||||||
choice.setMessage("Choose a counter to proliferate (" + player.getName() + ")");
|
|
||||||
controller.choose(Outcome.Benefit, choice, game);
|
|
||||||
for (Counter counter : player.getCounters().values()) {
|
|
||||||
if (counter.getName().equals(choice.getChoice())) {
|
|
||||||
Counter newCounter = new Counter(counter.getName());
|
|
||||||
player.addCounters(newCounter, game);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return abilityApplied;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,13 +40,21 @@ public class CounterPredicate implements Predicate<Permanent> {
|
||||||
|
|
||||||
private final CounterType counter;
|
private final CounterType counter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param counter if null any counter selects the permanent
|
||||||
|
*/
|
||||||
public CounterPredicate(CounterType counter) {
|
public CounterPredicate(CounterType counter) {
|
||||||
this.counter = counter;
|
this.counter = counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Permanent input, Game game) {
|
public boolean apply(Permanent input, Game game) {
|
||||||
return input.getCounters().containsKey(counter);
|
if (counter == null) {
|
||||||
|
return !input.getCounters().keySet().isEmpty();
|
||||||
|
} else {
|
||||||
|
return input.getCounters().containsKey(counter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class TargetPermanent extends TargetObject {
|
||||||
// second for protection from sources (e.g. protection from artifacts + equip ability)
|
// second for protection from sources (e.g. protection from artifacts + equip ability)
|
||||||
if (!isNotTarget()) {
|
if (!isNotTarget()) {
|
||||||
if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game) ||
|
if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game) ||
|
||||||
!permanent.canBeTargetedBy(game.getObject(source.getSourceId()), controllerId, game)) {
|
!permanent.canBeTargetedBy(game.getObject(source.getSourceId()), controllerId, game)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TargetPermanentOrPlayer(int minNumTargets, int maxNumTargets, boolean notTarget) {
|
public TargetPermanentOrPlayer(int minNumTargets, int maxNumTargets, boolean notTarget) {
|
||||||
this(minNumTargets, maxNumTargets);
|
this(minNumTargets, maxNumTargets);
|
||||||
this.notTarget = notTarget;
|
this.notTarget = notTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,10 +116,21 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
MageObject targetSource = game.getObject(source.getSourceId());
|
MageObject targetSource = game.getObject(source.getSourceId());
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
|
if (!isNotTarget()) {
|
||||||
|
if (!permanent.canBeTargetedBy(game.getObject(source.getId()), source.getControllerId(), game) ||
|
||||||
|
!permanent.canBeTargetedBy(game.getObject(source.getSourceId()), source.getControllerId(), game)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
|
||||||
}
|
}
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
return player.canBeTargetedBy(targetSource, game) && filter.match(player, game);
|
if (!isNotTarget()) {
|
||||||
|
if (!player.canBeTargetedBy(targetSource, game)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filter.match(player, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,12 +213,12 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (player != null && player.canBeTargetedBy(targetSource, game) && filter.match(player, game)) {
|
if (player != null && (notTarget || player.canBeTargetedBy(targetSource, game)) && filter.match(player, game)) {
|
||||||
possibleTargets.add(playerId);
|
possibleTargets.add(playerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterPermanent(), sourceControllerId, game)) {
|
for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterPermanent(), sourceControllerId, game)) {
|
||||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
|
if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(permanent, sourceId, sourceControllerId, game)) {
|
||||||
possibleTargets.add(permanent.getId());
|
possibleTargets.add(permanent.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,4 +263,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
||||||
return new TargetPermanentOrPlayer(this);
|
return new TargetPermanentOrPlayer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FilterPermanent getFilterPermanent() {
|
||||||
|
return filterPermanent.copy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,9 @@ import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.counters.CounterType;
|
||||||
|
import mage.filter.FilterPermanent;
|
||||||
|
import mage.filter.predicate.permanent.CounterPredicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -52,15 +55,15 @@ public class TargetPermanentOrPlayerWithCounter extends TargetPermanentOrPlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
public TargetPermanentOrPlayerWithCounter(int minNumTargets, int maxNumTargets) {
|
public TargetPermanentOrPlayerWithCounter(int minNumTargets, int maxNumTargets) {
|
||||||
super(minNumTargets, maxNumTargets);
|
this(minNumTargets, maxNumTargets, false);
|
||||||
this.filter = new FilterPermanentOrPlayerWithCounter();
|
|
||||||
this.targetName = filter.getMessage();
|
|
||||||
super.setFilter(this.filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TargetPermanentOrPlayerWithCounter(int minNumTargets, int maxNumTargets, boolean notTarget) {
|
public TargetPermanentOrPlayerWithCounter(int minNumTargets, int maxNumTargets, boolean notTarget) {
|
||||||
this(minNumTargets, maxNumTargets);
|
super(minNumTargets, maxNumTargets, notTarget);
|
||||||
this.notTarget = notTarget;
|
this.filter = new FilterPermanentOrPlayerWithCounter();
|
||||||
|
this.filterPermanent = new FilterPermanent();
|
||||||
|
this.filterPermanent.add(new CounterPredicate(null));
|
||||||
|
this.targetName = filter.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TargetPermanentOrPlayerWithCounter(final TargetPermanentOrPlayerWithCounter target) {
|
public TargetPermanentOrPlayerWithCounter(final TargetPermanentOrPlayerWithCounter target) {
|
||||||
|
|
Loading…
Reference in a new issue